Fix: minor bug
This commit is contained in:
@@ -97,8 +97,8 @@ public class Game implements Serializable {
|
||||
|
||||
if(nextPlayer==null)
|
||||
{
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
||||
currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.playerUpdate(orderLogicCard.pull(),null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -108,12 +108,12 @@ public class Game implements Serializable {
|
||||
nextPlayer=totemChoiceQueue.poll();
|
||||
if(nextPlayer==null)
|
||||
{
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
||||
currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.playerUpdate(orderLogicCard.pull(),null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
currentState.PlayerUpdate(nextPlayer,null);
|
||||
currentState.playerUpdate(nextPlayer,null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class Game implements Serializable {
|
||||
} else {
|
||||
totemChoiceQueue.add(player);
|
||||
}
|
||||
currentState.PlayerUpdate(totemChoiceQueue.poll(), null);
|
||||
currentState.playerUpdate(totemChoiceQueue.poll(), null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class Game implements Serializable {
|
||||
/**
|
||||
* Clears the collection of disconnected players.
|
||||
*/
|
||||
public synchronized void ClearDisconnected()
|
||||
public synchronized void clearDisconnected()
|
||||
{
|
||||
disconnectedPlayers.clear();
|
||||
}
|
||||
@@ -428,8 +428,8 @@ public class Game implements Serializable {
|
||||
}
|
||||
|
||||
}
|
||||
currentState.PlayerUpdate(totemChoiceQueue.poll(),null);
|
||||
currentState.GameStageUpdate(GameStages.TOTEM_CHOICE);
|
||||
currentState.playerUpdate(totemChoiceQueue.poll(),null);
|
||||
currentState.gameStageUpdate(GameStages.TOTEM_CHOICE);
|
||||
}
|
||||
|
||||
//region Controller Methods
|
||||
@@ -444,7 +444,7 @@ public class Game implements Serializable {
|
||||
* @param slotIndex the index of the selected slot.
|
||||
* @return {@code true} if the slot choice succeeds, {@code false} otherwise.
|
||||
*/
|
||||
public boolean SlotChoiceByIndex(Player player, int slotIndex) {
|
||||
public boolean slotChoiceByIndex(Player player, int slotIndex) {
|
||||
if(slotIndex<0 || slotIndex>=slotMap.size())
|
||||
return false;
|
||||
if(currentState.getGameStage()!= GameStages.SLOT_CHOICE)
|
||||
@@ -481,7 +481,7 @@ public class Game implements Serializable {
|
||||
* @param cardIndex the index of the upper tribe card to draw.
|
||||
* @return {@code true} if the draw succeeds, {@code false} otherwise.
|
||||
*/
|
||||
public boolean DrawUpperTribeCardByIndex(Player player,int cardIndex) {
|
||||
public boolean drawUpperTribeCardByIndex(Player player,int cardIndex) {
|
||||
if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
|
||||
return false;
|
||||
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
|
||||
@@ -503,7 +503,7 @@ public class Game implements Serializable {
|
||||
board.removeUpperTribeCard(tempCard);
|
||||
if(currentState.getGameStage()==GameStages.RES_ACTIONS)
|
||||
{
|
||||
currentState.UpperDrawn();
|
||||
currentState.upperDrawn();
|
||||
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
|
||||
nextPlayerSetup();
|
||||
}
|
||||
@@ -540,9 +540,9 @@ public class Game implements Serializable {
|
||||
if(hasDrawableUp() && currentState.getNUpper()>0)
|
||||
return false;
|
||||
while(currentState.getNLower()>0)
|
||||
currentState.LowerDrawn();
|
||||
currentState.lowerDrawn();
|
||||
while(currentState.getNUpper()>0)
|
||||
currentState.UpperDrawn();
|
||||
currentState.upperDrawn();
|
||||
nextPlayerSetup();
|
||||
}
|
||||
else {
|
||||
@@ -564,7 +564,7 @@ public class Game implements Serializable {
|
||||
* @param cardIndex the index of the lower tribe card to draw.
|
||||
* @return {@code true} if the draw succeeds, {@code false} otherwise.
|
||||
*/
|
||||
public boolean DrawLowerTribeCardByIndex(Player player, int cardIndex) {
|
||||
public boolean drawLowerTribeCardByIndex(Player player, int cardIndex) {
|
||||
if( cardIndex<0 || cardIndex >=board.lowerListTribe.size())
|
||||
return false;
|
||||
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||
@@ -586,7 +586,7 @@ public class Game implements Serializable {
|
||||
Character tempCard = (Character) tribeCard;
|
||||
tempCard.insert(player);
|
||||
board.removeLowerTribeCard(tempCard);
|
||||
currentState.LowerDrawn();
|
||||
currentState.lowerDrawn();
|
||||
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
|
||||
nextPlayerSetup();
|
||||
return true;
|
||||
@@ -605,7 +605,7 @@ public class Game implements Serializable {
|
||||
* @param cardIndex the index of the upper building card to draw.
|
||||
* @return {@code true} if the draw succeeds, {@code false} otherwise.
|
||||
*/
|
||||
public boolean DrawUpperBuildingCardByIndex(Player player,int cardIndex) {
|
||||
public boolean drawUpperBuildingCardByIndex(Player player,int cardIndex) {
|
||||
if( cardIndex<0 || cardIndex >=board.upperListBuilding.size())
|
||||
return false;
|
||||
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
|
||||
@@ -626,7 +626,7 @@ public class Game implements Serializable {
|
||||
board.removeUpperBuildingCard(buildingCard);
|
||||
if(currentState.getGameStage().equals(GameStages.RES_ACTIONS))
|
||||
{
|
||||
currentState.UpperDrawn();
|
||||
currentState.upperDrawn();
|
||||
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
|
||||
nextPlayerSetup();
|
||||
}
|
||||
@@ -649,7 +649,7 @@ public class Game implements Serializable {
|
||||
* @param cardIndex the index of the lower building card to draw.
|
||||
* @return {@code true} if the draw succeeds, {@code false} otherwise.
|
||||
*/
|
||||
public boolean DrawLowerBuildingCardByIndex(Player player,int cardIndex) {
|
||||
public boolean drawLowerBuildingCardByIndex(Player player,int cardIndex) {
|
||||
if( cardIndex<0 || cardIndex >=board.lowerListBuilding.size())
|
||||
return false;
|
||||
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||
@@ -666,7 +666,7 @@ public class Game implements Serializable {
|
||||
return false;
|
||||
if(buildingCard.buy(player))
|
||||
{
|
||||
currentState.LowerDrawn();
|
||||
currentState.lowerDrawn();
|
||||
board.removeLowerBuildingCard(buildingCard);
|
||||
}
|
||||
else
|
||||
@@ -713,12 +713,12 @@ public class Game implements Serializable {
|
||||
if (!disconnectedPlayers.containsKey(tempPlayer) || !disconnectedPlayers.get(tempPlayer)) break;
|
||||
}
|
||||
if (tempPlayer != null) {
|
||||
currentState.PlayerUpdate(tempPlayer, null);
|
||||
currentState.playerUpdate(tempPlayer, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// All players have chosen a slot → switch to RES_ACTIONS
|
||||
currentState.GameStageUpdate(GameStages.RES_ACTIONS);
|
||||
currentState.gameStageUpdate(GameStages.RES_ACTIONS);
|
||||
|
||||
boolean anyAssigned = false;
|
||||
for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) {
|
||||
@@ -730,7 +730,7 @@ public class Game implements Serializable {
|
||||
entry.setValue(null);
|
||||
continue;
|
||||
}
|
||||
currentState.PlayerUpdate(entry.getValue(), entry.getKey());
|
||||
currentState.playerUpdate(entry.getValue(), entry.getKey());
|
||||
boolean hasDrawableLower = currentState.getNLower() > 0
|
||||
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty());
|
||||
boolean hasDrawableUpper = currentState.getNUpper() > 0
|
||||
@@ -766,7 +766,7 @@ public class Game implements Serializable {
|
||||
entry.setValue(null);
|
||||
continue;
|
||||
}
|
||||
currentState.PlayerUpdate(entry.getValue(), entry.getKey());
|
||||
currentState.playerUpdate(entry.getValue(), entry.getKey());
|
||||
boolean hasDrawableLower = currentState.getNLower() > 0
|
||||
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty());
|
||||
boolean hasDrawableUpper = currentState.getNUpper() > 0
|
||||
@@ -791,21 +791,21 @@ public class Game implements Serializable {
|
||||
Player optionalPlayer = OptionalCardQueue.poll();
|
||||
|
||||
if (optionalPlayer != null) {
|
||||
currentState.PlayerUpdate(optionalPlayer, null);
|
||||
currentState.playerUpdate(optionalPlayer, null);
|
||||
if(disconnectedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnectedPlayers.get(currentState.getCurrentPlayer())) {
|
||||
nextPlayerSetup();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
currentState.GameStageUpdate(GameStages.RES_EVENT);
|
||||
currentState.gameStageUpdate(GameStages.RES_EVENT);
|
||||
|
||||
if (currentState.getRound() < 10) {
|
||||
nextRound();
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(), null);
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.playerUpdate(orderLogicCard.pull(), null);
|
||||
currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
} else {
|
||||
currentState.GameStageUpdate(GameStages.ENDING);
|
||||
currentState.gameStageUpdate(GameStages.ENDING);
|
||||
endGame();
|
||||
}
|
||||
}
|
||||
@@ -819,7 +819,7 @@ public class Game implements Serializable {
|
||||
* is set to {@link GameStages#SLOT_CHOICE}; if round 10 has been completed, the game ends.
|
||||
*/
|
||||
private synchronized void transitionToOptionalOrNextRound() {
|
||||
currentState.GameStageUpdate(GameStages.OPT_CARD_E);
|
||||
currentState.gameStageUpdate(GameStages.OPT_CARD_E);
|
||||
|
||||
OptionalCardQueue = new LinkedList<>();
|
||||
for (Player p :playersList) {
|
||||
@@ -836,29 +836,25 @@ public class Game implements Serializable {
|
||||
Player optionalPlayer = OptionalCardQueue.poll();
|
||||
|
||||
if (optionalPlayer != null) {
|
||||
currentState.PlayerUpdate(optionalPlayer, null);
|
||||
currentState.playerUpdate(optionalPlayer, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentState.getRound() < 10) {
|
||||
nextRound();
|
||||
for(Map.Entry<Player,Boolean> entry: disconnectedPlayers.entrySet())
|
||||
{
|
||||
if(!entry.getValue())
|
||||
{
|
||||
for (Map.Entry<Player, Boolean> entry : new ArrayList<>(disconnectedPlayers.entrySet())) {
|
||||
if (!entry.getValue()) {
|
||||
orderLogicCard.pushNoEffect(entry.getKey());
|
||||
disconnectedPlayers.remove(entry.getKey());
|
||||
}
|
||||
else
|
||||
{
|
||||
orderLogicCard.players.removeIf(x->x.equals(entry.getKey()));
|
||||
orderLogicCard.playerList.removeIf(x->x.player.equals(entry.getKey()));
|
||||
} else {
|
||||
orderLogicCard.players.removeIf(x -> x.equals(entry.getKey()));
|
||||
orderLogicCard.playerList.removeIf(x -> x.player.equals(entry.getKey()));
|
||||
}
|
||||
}
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(), null);
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.playerUpdate(orderLogicCard.pull(), null);
|
||||
currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
} else {
|
||||
currentState.GameStageUpdate(GameStages.ENDING);
|
||||
currentState.gameStageUpdate(GameStages.ENDING);
|
||||
endGame();
|
||||
}
|
||||
}
|
||||
@@ -888,9 +884,9 @@ public class Game implements Serializable {
|
||||
* All pending events are activated on the player list.
|
||||
* Event cards of type {@code SUSTENANCE} are resolved after all other pending events.
|
||||
*/
|
||||
private void EventResolution() {
|
||||
private void eventResolution() {
|
||||
|
||||
currentState.GameStageUpdate(GameStages.RES_EVENT);
|
||||
currentState.gameStageUpdate(GameStages.RES_EVENT);
|
||||
Queue<EventCard> events;
|
||||
events=board.getPendingEvents();
|
||||
ArrayList<EventCard>sustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new));
|
||||
@@ -916,12 +912,12 @@ public class Game implements Serializable {
|
||||
*/
|
||||
private void nextRound() {
|
||||
|
||||
EventResolution();
|
||||
eventResolution();
|
||||
if(currentState.getEra()!= board.nextRound()) {
|
||||
currentState.EraUpdate();
|
||||
currentState.eraUpdate();
|
||||
}
|
||||
|
||||
currentState.RoundUpdate();
|
||||
currentState.roundUpdate();
|
||||
|
||||
}
|
||||
|
||||
@@ -942,7 +938,7 @@ public class Game implements Serializable {
|
||||
p.addPrestige(temp);
|
||||
});
|
||||
playersList.forEach(p->{
|
||||
int temp=(int) p.getInventors().stream().mapToInt(Inventor::Icon).distinct().count();
|
||||
int temp=(int) p.getInventors().stream().mapToInt(Inventor::getIcon).distinct().count();
|
||||
p.addPrestige(temp*p.getNType(CharacterType.INVENTOR));
|
||||
});
|
||||
playersList.forEach(p->{
|
||||
@@ -956,7 +952,7 @@ public class Game implements Serializable {
|
||||
p -> p.getBuildingCards().stream().filter(x -> x.getEffectType() == EffectType.FINAL).
|
||||
forEach(x -> x.applyEffect(p))
|
||||
);
|
||||
currentState.GameStageUpdate(GameStages.ENDED);
|
||||
currentState.gameStageUpdate(GameStages.ENDED);
|
||||
playerStanding=new ArrayList<>(playersList);
|
||||
playerStanding.sort((y,x)->x.getPrestigeValue()==y.getPrestigeValue()?Integer.compare(x.getFoodValue(),y.getFoodValue()):Integer.compare(x.getPrestigeValue(),y.getPrestigeValue()));
|
||||
|
||||
@@ -1006,7 +1002,7 @@ public class Game implements Serializable {
|
||||
.filter(x -> !disconnectedPlayers.containsKey(x) || !disconnectedPlayers.get(x))
|
||||
.findFirst().orElse(null);
|
||||
if (winner == null) return;
|
||||
currentState.GameStageUpdate(GameStages.ENDED);
|
||||
currentState.gameStageUpdate(GameStages.ENDED);
|
||||
playerStanding = new ArrayList<>(playersList);
|
||||
playerStanding.remove(winner);
|
||||
playerStanding.sort((y, x) -> x.getPrestigeValue() == y.getPrestigeValue()
|
||||
|
||||
Reference in New Issue
Block a user