Fix: TCP Reconnection system -> model too
This commit is contained in:
@@ -44,23 +44,15 @@ public class Game implements Serializable {
|
||||
//TODO
|
||||
Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
||||
//TODO
|
||||
public boolean SkipNotConnectedPlayer(Player player)
|
||||
public boolean DisconnectedPlayer(Player player)
|
||||
{
|
||||
if(currentState.getCurrentPlayer()!=player)
|
||||
if(disconnetedPlayers.containsKey(player) && disconnetedPlayers.get(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(currentState.getGameStage().equals(GameStages.SLOT_CHOICE))
|
||||
{
|
||||
disconnetedPlayers.put(player,true);
|
||||
if(currentState.getCurrentPlayer().equals(player))
|
||||
nextPlayerSetup();
|
||||
disconnetedPlayers.put(player,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPlayerSetup();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,13 +64,21 @@ public class Game implements Serializable {
|
||||
return false;
|
||||
}
|
||||
disconnetedPlayers.put(player,false);
|
||||
if(currentState.getGameStage().equals(GameStages.SLOT_CHOICE))
|
||||
if(currentState.getGameStage().equals(GameStages.SLOT_CHOICE) )
|
||||
{
|
||||
disconnetedPlayers.remove(player);
|
||||
orderLogicCard.pushNoEffect(player);
|
||||
if(!orderLogicCard.players.contains(player))
|
||||
{
|
||||
orderLogicCard.pushNoEffect(player);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClearDisconnected()
|
||||
{
|
||||
disconnetedPlayers.clear();
|
||||
}
|
||||
/**
|
||||
* Returns the current number of players participating in the game.
|
||||
* @return the current number of players.
|
||||
@@ -645,7 +645,10 @@ public class Game implements Serializable {
|
||||
|
||||
if (GameStages.SLOT_CHOICE == currentState.getGameStage()) {
|
||||
Player tempPlayer = orderLogicCard.pull();
|
||||
|
||||
if(disconnetedPlayers.containsKey(tempPlayer) && disconnetedPlayers.get(tempPlayer)) {
|
||||
nextPlayerSetup();
|
||||
return;
|
||||
}
|
||||
if (tempPlayer != null) {
|
||||
currentState.PlayerUpdate(tempPlayer, null);
|
||||
return;
|
||||
@@ -690,12 +693,15 @@ public class Game implements Serializable {
|
||||
for (Slot s : slotMap.keySet()) {
|
||||
if (slotMap.get(s) != null) {
|
||||
currentState.PlayerUpdate(slotMap.get(s), s);
|
||||
|
||||
if(disconnetedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnetedPlayers.get(currentState.getCurrentPlayer()))
|
||||
{
|
||||
slotMap.put(currentState.getSlot(), null);
|
||||
continue;
|
||||
}
|
||||
boolean hasDrawableLower = currentState.getNLower() > 0
|
||||
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty());
|
||||
boolean hasDrawableUpper = currentState.getNUpper() > 0
|
||||
&& (hasDrawableUp() || !getUpperListBuilding().isEmpty());
|
||||
|
||||
if (!hasDrawableLower && !hasDrawableUpper) {
|
||||
// This player also has nothing, skip and continue the loop
|
||||
orderLogicCard.push(currentState.getCurrentPlayer());
|
||||
@@ -717,6 +723,9 @@ public class Game implements Serializable {
|
||||
|
||||
if (optionalPlayer != null) {
|
||||
currentState.PlayerUpdate(optionalPlayer, null);
|
||||
if(disconnetedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnetedPlayers.get(currentState.getCurrentPlayer())) {
|
||||
nextPlayerSetup();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user