Fixed:Client Resilience (TCP)
This commit is contained in:
@@ -40,6 +40,9 @@ public class Game implements Serializable {
|
||||
public List<Player> getPlayers() {
|
||||
return playersList;
|
||||
}
|
||||
|
||||
//TODO
|
||||
Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
||||
//TODO
|
||||
public boolean SkipNotConnectedPlayer(Player player)
|
||||
{
|
||||
@@ -47,9 +50,28 @@ public class Game implements Serializable {
|
||||
{
|
||||
return false;
|
||||
}
|
||||
nextPlayerSetup();
|
||||
return true;
|
||||
|
||||
|
||||
if(currentState.getGameStage().equals(GameStages.SLOT_CHOICE))
|
||||
{
|
||||
nextPlayerSetup();
|
||||
disconnetedPlayers.put(player,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPlayerSetup();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO
|
||||
public boolean ReconnectPlayer(Player player)
|
||||
{
|
||||
if(!disconnetedPlayers.containsKey(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return disconnetedPlayers.put(player,false);
|
||||
}
|
||||
/**
|
||||
* Returns the current number of players participating in the game.
|
||||
@@ -728,6 +750,14 @@ public class Game implements Serializable {
|
||||
|
||||
if (currentState.getRound() < 10) {
|
||||
nextRound();
|
||||
for(Map.Entry<Player,Boolean> entry: disconnetedPlayers.entrySet())
|
||||
{
|
||||
if(!entry.getValue())
|
||||
{
|
||||
orderLogicCard.pushNoEffect(entry.getKey());
|
||||
disconnetedPlayers.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(), null);
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
} else {
|
||||
|
||||
@@ -59,6 +59,20 @@ public abstract class OrderLogicCard implements Serializable {
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Adds the player to the end of the queue, without effects.
|
||||
*
|
||||
* @param player the player to be pushed into the queue.
|
||||
*/
|
||||
public void pushNoEffect(Player player){
|
||||
if(players.size()==0)
|
||||
{
|
||||
playerList=new ArrayList<>();
|
||||
|
||||
}
|
||||
playerList.add(new OrderPlayer(player,false));
|
||||
players.add(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and returns the first player in the queue.
|
||||
|
||||
Reference in New Issue
Block a user