Atomically replaced player in the NPC
Atomically replaced player in the NPC
Hello. How i can atomically replaced player in the NPC? When user disconnected and game action falls on him, he is no longer in the game, and the game crashes. It is necessary at the moment of leaving the game the player put in its place a bot, is it possible?
Re: Atomically replaced player in the NPC
Hi,
atomically no, because of the very asynchronous nature of network games.
It's also not clear why this should happen. Shouldn't players be notified that the real player has left the Room and a different, automated NPC has taken his place?
cheers
atomically no, because of the very asynchronous nature of network games.
It's also not clear why this should happen. Shouldn't players be notified that the real player has left the Room and a different, automated NPC has taken his place?
cheers
Re: Atomically replaced player in the NPC
The problem is that when a player leaves the game (the game closes the window), it is no longer in the zone/room in DisconnectEventHandler intercepts this event and created NPC, which takes the place of the player.
But if the course of the game is the player who has left the game, and the NPC has not had time to sit down, the game may crash.
In other words, the situation can be described as follows:
There are 2 players, they sit at the table. 1st player - 1st place, 2nd player - 2nd place.
Then the points:
1. Start the game and player's turn at the 1st place.
2. Player 1 makes a move
3. 2nd player leaves the game
4. The course goes to the player at the 2nd place (but it is no longer in the game)
5. At the 2nd place to sit NPC
How can this problem be solved?
But if the course of the game is the player who has left the game, and the NPC has not had time to sit down, the game may crash.
In other words, the situation can be described as follows:
There are 2 players, they sit at the table. 1st player - 1st place, 2nd player - 2nd place.
Then the points:
1. Start the game and player's turn at the 1st place.
2. Player 1 makes a move
3. 2nd player leaves the game
4. The course goes to the player at the 2nd place (but it is no longer in the game)
5. At the 2nd place to sit NPC
How can this problem be solved?
Re: Atomically replaced player in the NPC
I think it is just a bit of programming logic that needs to be adjusted for your needs.
Wouldn't it be better if the error was caught and the turn skipped?
This is what I mean...
Player 1 is plays his move.
Now is Player 2 turn but he disconnects a few milliseconds before the turn change and the NPC is not ready yet... BOOM... error
My suggestion is to catch the error and gracefully handle it. For example you could simply send a message to the other players saying that the user has left the game and an NPC will take his place. This seems also necessary to keep the game fair for everyone. I think everyone should know that the human player has left and automated player is going to replace him.
In any case once the message has been sent you can either proceed by moving on with the next turn (Player 3) or wait for the NPC to be ready and then continue with the new Player 2 move.
Makes sense?
Wouldn't it be better if the error was caught and the turn skipped?
This is what I mean...
Player 1 is plays his move.
Now is Player 2 turn but he disconnects a few milliseconds before the turn change and the NPC is not ready yet... BOOM... error
My suggestion is to catch the error and gracefully handle it. For example you could simply send a message to the other players saying that the user has left the game and an NPC will take his place. This seems also necessary to keep the game fair for everyone. I think everyone should know that the human player has left and automated player is going to replace him.
In any case once the message has been sent you can either proceed by moving on with the next turn (Player 3) or wait for the NPC to be ready and then continue with the new Player 2 move.
Makes sense?
Re: Atomically replaced player in the NPC
Well, I do not think so, just thought there is a way to replace the player in the NPC, something like User#switchToNPC()
Re: Atomically replaced player in the NPC
No, I am sorry you can't do that because the two users are different objects.
The old User object is destroyed when he disconnects and the new NPC is a new User object with no physical socket connection.
The old User object is destroyed when he disconnects and the new NPC is a new User object with no physical socket connection.
Who is online
Users browsing this forum: No registered users and 147 guests