Fix: minor bug

This commit is contained in:
2026-06-12 20:18:51 +02:00
parent 053f0048bc
commit 9a931bfc1b
21 changed files with 268 additions and 274 deletions
@@ -106,7 +106,7 @@ public class GameController {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
if(player==null) if(player==null)
return false; return false;
return model.DrawUpperTribeCardByIndex(model.getPlayerByUsername(playerUsername),pos); return model.drawUpperTribeCardByIndex(model.getPlayerByUsername(playerUsername),pos);
} }
/** /**
@@ -122,7 +122,7 @@ public class GameController {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
if(player==null) if(player==null)
return false; return false;
return model.DrawLowerTribeCardByIndex(model.getPlayerByUsername(playerUsername), pos); return model.drawLowerTribeCardByIndex(model.getPlayerByUsername(playerUsername), pos);
} }
/** /**
@@ -138,7 +138,7 @@ public class GameController {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
if(player==null) if(player==null)
return false; return false;
return model.DrawUpperBuildingCardByIndex(model.getPlayerByUsername(playerUsername), pos); return model.drawUpperBuildingCardByIndex(model.getPlayerByUsername(playerUsername), pos);
} }
/** /**
@@ -154,7 +154,7 @@ public class GameController {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
if(player==null) if(player==null)
return false; return false;
return model.DrawLowerBuildingCardByIndex(model.getPlayerByUsername(playerUsername), pos); return model.drawLowerBuildingCardByIndex(model.getPlayerByUsername(playerUsername), pos);
} }
@@ -187,7 +187,7 @@ public class GameController {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
if(player==null) if(player==null)
return false; return false;
return model.SlotChoiceByIndex(model.getPlayerByUsername(playerUsername),pos); return model.slotChoiceByIndex(model.getPlayerByUsername(playerUsername),pos);
} }
/** /**
@@ -33,7 +33,7 @@ public class Building11 extends BuildingCard {
* *
* @return the prestige multiplier associated with this building card effect. * @return the prestige multiplier associated with this building card effect.
*/ */
public int getprestigeMul() {return prestigeMul;} public int getPrestigeMul() {return prestigeMul;}
/** /**
* Creates a Building11 card with the specified era, price, prestige value, * Creates a Building11 card with the specified era, price, prestige value,
@@ -79,7 +79,7 @@ public class Building11 extends BuildingCard {
*/ */
@Override @Override
public BuildingCard clone() { public BuildingCard clone() {
return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getprestigeMul()); return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getPrestigeMul());
} }
/** /**
@@ -94,7 +94,7 @@ public class Building11 extends BuildingCard {
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
player.addPrestige(player.getNType(getIcon()) * this.getprestigeMul()); player.addPrestige(player.getNType(getIcon()) * this.getPrestigeMul());
} }
/** /**
@@ -79,7 +79,7 @@ public class Building4 extends BuildingCard {
} }
for(Inventor inv : player.getInventors()) for(Inventor inv : player.getInventors())
{ {
map.merge(inv.Icon(),1,Integer::sum); map.merge(inv.getIcon(),1,Integer::sum);
} }
numPair=0; numPair=0;
for(Integer i : map.values()) for(Integer i : map.values())
@@ -141,7 +141,7 @@ public class Building4 extends BuildingCard {
} }
for(Inventor inv : player.getInventors()) for(Inventor inv : player.getInventors())
{ {
map.merge(inv.Icon(),1,Integer::sum); map.merge(inv.getIcon(),1,Integer::sum);
} }
int temp=0; int temp=0;
for(Integer i : map.values()) for(Integer i : map.values())
@@ -20,7 +20,7 @@ public class Inventor extends Character {
* *
* @return the icon value of this Inventor card. * @return the icon value of this Inventor card.
*/ */
public int Icon() { public int getIcon() {
return icon; return icon;
} }
@@ -77,21 +77,21 @@ public class CavePaintings extends EventCard {
@Override @Override
public void activateEvent (ArrayList <Player> playerList){ public void activateEvent (ArrayList <Player> playerList){
for (Player player : playerList){ for (Player player : playerList){
int NArtists = player.getNType(CharacterType.ARTIST); int nArtists = player.getNType(CharacterType.ARTIST);
int NBuildings = 0; int nBuildings = 0;
ArrayList<BuildingCard> buildingCards = player.getBuildingCards(); ArrayList<BuildingCard> buildingCards = player.getBuildingCards();
for(BuildingCard card : buildingCards){ for(BuildingCard card : buildingCards){
if(card.getEffectId() == 9){ if(card.getEffectId() == 9){
NBuildings++; nBuildings++;
} }
} }
player.addFood(NBuildings * NArtists); player.addFood(nBuildings * nArtists);
if (NArtists < nLower){ if (nArtists < nLower){
player.removePrestige(nPrestigeRem); player.removePrestige(nPrestigeRem);
} }
else{ else{
player.addPrestige(nPrestigeMul * NArtists); player.addPrestige(nPrestigeMul * nArtists);
} }
} }
} }
@@ -28,7 +28,7 @@ public class Sustenance extends EventCard {
* *
* @return the prestige penalty multiplier associated with this Sustenance event. * @return the prestige penalty multiplier associated with this Sustenance event.
*/ */
public int getprestigeDebt() { public int getPrestigeDebt() {
return prestigeDebt; return prestigeDebt;
} }
@@ -71,30 +71,30 @@ public class Sustenance extends EventCard {
@Override @Override
public void activateEvent (ArrayList <Player> playerList) throws NullPointerException { public void activateEvent (ArrayList <Player> playerList) throws NullPointerException {
for(Player player : playerList){ for(Player player : playerList){
int NChar = player.getTotCharacters(); int nChar = player.getTotCharacters();
int NGatherers = player.getNType(CharacterType.GATHERER); int nGatherers = player.getNType(CharacterType.GATHERER);
int NCharDiscount = 0; int nCharDiscount = 0;
for(BuildingCard b : player.getBuildingCards()){ for(BuildingCard b : player.getBuildingCards()){
if(b.getEffectId() == 1){ if(b.getEffectId() == 1){
CharacterType c = ((Building1)b).getIcon(); CharacterType c = ((Building1)b).getIcon();
NCharDiscount += player.getNType(c); nCharDiscount += player.getNType(c);
} }
} }
int FoodDebt = NChar - (FOOD_PER_GATHERER * NGatherers + NCharDiscount); int foodDebt = nChar - (FOOD_PER_GATHERER * nGatherers + nCharDiscount);
if(FoodDebt <= 0){ if(foodDebt <= 0){
continue; continue;
} }
if(player.getFoodValue() >= FoodDebt){ if(player.getFoodValue() >= foodDebt){
player.removeFood(FoodDebt); player.removeFood(foodDebt);
} }
else{ else{
FoodDebt -= player.getFoodValue(); foodDebt -= player.getFoodValue();
player.removeFood(player.getFoodValue()); // player.getFoodValue() == 0 player.removeFood(player.getFoodValue()); // player.getFoodValue() == 0
player.removePrestige(FoodDebt * prestigeDebt); player.removePrestige(foodDebt * prestigeDebt);
} }
} }
} }
@@ -97,8 +97,8 @@ public class Game implements Serializable {
if(nextPlayer==null) if(nextPlayer==null)
{ {
currentState.GameStageUpdate(GameStages.SLOT_CHOICE); currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
currentState.PlayerUpdate(orderLogicCard.pull(),null); currentState.playerUpdate(orderLogicCard.pull(),null);
} }
else else
{ {
@@ -108,12 +108,12 @@ public class Game implements Serializable {
nextPlayer=totemChoiceQueue.poll(); nextPlayer=totemChoiceQueue.poll();
if(nextPlayer==null) if(nextPlayer==null)
{ {
currentState.GameStageUpdate(GameStages.SLOT_CHOICE); currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
currentState.PlayerUpdate(orderLogicCard.pull(),null); currentState.playerUpdate(orderLogicCard.pull(),null);
return true; return true;
} }
} }
currentState.PlayerUpdate(nextPlayer,null); currentState.playerUpdate(nextPlayer,null);
} }
return true; return true;
} }
@@ -158,7 +158,7 @@ public class Game implements Serializable {
} else { } else {
totemChoiceQueue.add(player); totemChoiceQueue.add(player);
} }
currentState.PlayerUpdate(totemChoiceQueue.poll(), null); currentState.playerUpdate(totemChoiceQueue.poll(), null);
return true; return true;
} }
} }
@@ -204,7 +204,7 @@ public class Game implements Serializable {
/** /**
* Clears the collection of disconnected players. * Clears the collection of disconnected players.
*/ */
public synchronized void ClearDisconnected() public synchronized void clearDisconnected()
{ {
disconnectedPlayers.clear(); disconnectedPlayers.clear();
} }
@@ -428,8 +428,8 @@ public class Game implements Serializable {
} }
} }
currentState.PlayerUpdate(totemChoiceQueue.poll(),null); currentState.playerUpdate(totemChoiceQueue.poll(),null);
currentState.GameStageUpdate(GameStages.TOTEM_CHOICE); currentState.gameStageUpdate(GameStages.TOTEM_CHOICE);
} }
//region Controller Methods //region Controller Methods
@@ -444,7 +444,7 @@ public class Game implements Serializable {
* @param slotIndex the index of the selected slot. * @param slotIndex the index of the selected slot.
* @return {@code true} if the slot choice succeeds, {@code false} otherwise. * @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()) if(slotIndex<0 || slotIndex>=slotMap.size())
return false; return false;
if(currentState.getGameStage()!= GameStages.SLOT_CHOICE) 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. * @param cardIndex the index of the upper tribe card to draw.
* @return {@code true} if the draw succeeds, {@code false} otherwise. * @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()) if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
return false; return false;
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E) if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
@@ -503,7 +503,7 @@ public class Game implements Serializable {
board.removeUpperTribeCard(tempCard); board.removeUpperTribeCard(tempCard);
if(currentState.getGameStage()==GameStages.RES_ACTIONS) if(currentState.getGameStage()==GameStages.RES_ACTIONS)
{ {
currentState.UpperDrawn(); currentState.upperDrawn();
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
nextPlayerSetup(); nextPlayerSetup();
} }
@@ -540,9 +540,9 @@ public class Game implements Serializable {
if(hasDrawableUp() && currentState.getNUpper()>0) if(hasDrawableUp() && currentState.getNUpper()>0)
return false; return false;
while(currentState.getNLower()>0) while(currentState.getNLower()>0)
currentState.LowerDrawn(); currentState.lowerDrawn();
while(currentState.getNUpper()>0) while(currentState.getNUpper()>0)
currentState.UpperDrawn(); currentState.upperDrawn();
nextPlayerSetup(); nextPlayerSetup();
} }
else { else {
@@ -564,7 +564,7 @@ public class Game implements Serializable {
* @param cardIndex the index of the lower tribe card to draw. * @param cardIndex the index of the lower tribe card to draw.
* @return {@code true} if the draw succeeds, {@code false} otherwise. * @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()) if( cardIndex<0 || cardIndex >=board.lowerListTribe.size())
return false; return false;
if(currentState.getGameStage()!= GameStages.RES_ACTIONS) if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
@@ -586,7 +586,7 @@ public class Game implements Serializable {
Character tempCard = (Character) tribeCard; Character tempCard = (Character) tribeCard;
tempCard.insert(player); tempCard.insert(player);
board.removeLowerTribeCard(tempCard); board.removeLowerTribeCard(tempCard);
currentState.LowerDrawn(); currentState.lowerDrawn();
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
nextPlayerSetup(); nextPlayerSetup();
return true; return true;
@@ -605,7 +605,7 @@ public class Game implements Serializable {
* @param cardIndex the index of the upper building card to draw. * @param cardIndex the index of the upper building card to draw.
* @return {@code true} if the draw succeeds, {@code false} otherwise. * @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()) if( cardIndex<0 || cardIndex >=board.upperListBuilding.size())
return false; return false;
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E) if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
@@ -626,7 +626,7 @@ public class Game implements Serializable {
board.removeUpperBuildingCard(buildingCard); board.removeUpperBuildingCard(buildingCard);
if(currentState.getGameStage().equals(GameStages.RES_ACTIONS)) if(currentState.getGameStage().equals(GameStages.RES_ACTIONS))
{ {
currentState.UpperDrawn(); currentState.upperDrawn();
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
nextPlayerSetup(); nextPlayerSetup();
} }
@@ -649,7 +649,7 @@ public class Game implements Serializable {
* @param cardIndex the index of the lower building card to draw. * @param cardIndex the index of the lower building card to draw.
* @return {@code true} if the draw succeeds, {@code false} otherwise. * @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()) if( cardIndex<0 || cardIndex >=board.lowerListBuilding.size())
return false; return false;
if(currentState.getGameStage()!= GameStages.RES_ACTIONS) if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
@@ -666,7 +666,7 @@ public class Game implements Serializable {
return false; return false;
if(buildingCard.buy(player)) if(buildingCard.buy(player))
{ {
currentState.LowerDrawn(); currentState.lowerDrawn();
board.removeLowerBuildingCard(buildingCard); board.removeLowerBuildingCard(buildingCard);
} }
else else
@@ -713,12 +713,12 @@ public class Game implements Serializable {
if (!disconnectedPlayers.containsKey(tempPlayer) || !disconnectedPlayers.get(tempPlayer)) break; if (!disconnectedPlayers.containsKey(tempPlayer) || !disconnectedPlayers.get(tempPlayer)) break;
} }
if (tempPlayer != null) { if (tempPlayer != null) {
currentState.PlayerUpdate(tempPlayer, null); currentState.playerUpdate(tempPlayer, null);
return; return;
} }
// All players have chosen a slot → switch to RES_ACTIONS // All players have chosen a slot → switch to RES_ACTIONS
currentState.GameStageUpdate(GameStages.RES_ACTIONS); currentState.gameStageUpdate(GameStages.RES_ACTIONS);
boolean anyAssigned = false; boolean anyAssigned = false;
for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) { for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) {
@@ -730,7 +730,7 @@ public class Game implements Serializable {
entry.setValue(null); entry.setValue(null);
continue; continue;
} }
currentState.PlayerUpdate(entry.getValue(), entry.getKey()); currentState.playerUpdate(entry.getValue(), entry.getKey());
boolean hasDrawableLower = currentState.getNLower() > 0 boolean hasDrawableLower = currentState.getNLower() > 0
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty()); && (hasDrawableDown() || !getLowerListBuilding().isEmpty());
boolean hasDrawableUpper = currentState.getNUpper() > 0 boolean hasDrawableUpper = currentState.getNUpper() > 0
@@ -766,7 +766,7 @@ public class Game implements Serializable {
entry.setValue(null); entry.setValue(null);
continue; continue;
} }
currentState.PlayerUpdate(entry.getValue(), entry.getKey()); currentState.playerUpdate(entry.getValue(), entry.getKey());
boolean hasDrawableLower = currentState.getNLower() > 0 boolean hasDrawableLower = currentState.getNLower() > 0
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty()); && (hasDrawableDown() || !getLowerListBuilding().isEmpty());
boolean hasDrawableUpper = currentState.getNUpper() > 0 boolean hasDrawableUpper = currentState.getNUpper() > 0
@@ -791,21 +791,21 @@ public class Game implements Serializable {
Player optionalPlayer = OptionalCardQueue.poll(); Player optionalPlayer = OptionalCardQueue.poll();
if (optionalPlayer != null) { if (optionalPlayer != null) {
currentState.PlayerUpdate(optionalPlayer, null); currentState.playerUpdate(optionalPlayer, null);
if(disconnectedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnectedPlayers.get(currentState.getCurrentPlayer())) { if(disconnectedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnectedPlayers.get(currentState.getCurrentPlayer())) {
nextPlayerSetup(); nextPlayerSetup();
} }
return; return;
} }
currentState.GameStageUpdate(GameStages.RES_EVENT); currentState.gameStageUpdate(GameStages.RES_EVENT);
if (currentState.getRound() < 10) { if (currentState.getRound() < 10) {
nextRound(); nextRound();
currentState.PlayerUpdate(orderLogicCard.pull(), null); currentState.playerUpdate(orderLogicCard.pull(), null);
currentState.GameStageUpdate(GameStages.SLOT_CHOICE); currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
} else { } else {
currentState.GameStageUpdate(GameStages.ENDING); currentState.gameStageUpdate(GameStages.ENDING);
endGame(); 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. * is set to {@link GameStages#SLOT_CHOICE}; if round 10 has been completed, the game ends.
*/ */
private synchronized void transitionToOptionalOrNextRound() { private synchronized void transitionToOptionalOrNextRound() {
currentState.GameStageUpdate(GameStages.OPT_CARD_E); currentState.gameStageUpdate(GameStages.OPT_CARD_E);
OptionalCardQueue = new LinkedList<>(); OptionalCardQueue = new LinkedList<>();
for (Player p :playersList) { for (Player p :playersList) {
@@ -836,29 +836,25 @@ public class Game implements Serializable {
Player optionalPlayer = OptionalCardQueue.poll(); Player optionalPlayer = OptionalCardQueue.poll();
if (optionalPlayer != null) { if (optionalPlayer != null) {
currentState.PlayerUpdate(optionalPlayer, null); currentState.playerUpdate(optionalPlayer, null);
return; return;
} }
if (currentState.getRound() < 10) { if (currentState.getRound() < 10) {
nextRound(); nextRound();
for(Map.Entry<Player,Boolean> entry: disconnectedPlayers.entrySet()) for (Map.Entry<Player, Boolean> entry : new ArrayList<>(disconnectedPlayers.entrySet())) {
{ if (!entry.getValue()) {
if(!entry.getValue())
{
orderLogicCard.pushNoEffect(entry.getKey()); orderLogicCard.pushNoEffect(entry.getKey());
disconnectedPlayers.remove(entry.getKey()); disconnectedPlayers.remove(entry.getKey());
} } else {
else orderLogicCard.players.removeIf(x -> x.equals(entry.getKey()));
{ orderLogicCard.playerList.removeIf(x -> x.player.equals(entry.getKey()));
orderLogicCard.players.removeIf(x->x.equals(entry.getKey()));
orderLogicCard.playerList.removeIf(x->x.player.equals(entry.getKey()));
} }
} }
currentState.PlayerUpdate(orderLogicCard.pull(), null); currentState.playerUpdate(orderLogicCard.pull(), null);
currentState.GameStageUpdate(GameStages.SLOT_CHOICE); currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
} else { } else {
currentState.GameStageUpdate(GameStages.ENDING); currentState.gameStageUpdate(GameStages.ENDING);
endGame(); endGame();
} }
} }
@@ -888,9 +884,9 @@ public class Game implements Serializable {
* All pending events are activated on the player list. * All pending events are activated on the player list.
* Event cards of type {@code SUSTENANCE} are resolved after all other pending events. * 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; Queue<EventCard> events;
events=board.getPendingEvents(); events=board.getPendingEvents();
ArrayList<EventCard>sustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new)); 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() { private void nextRound() {
EventResolution(); eventResolution();
if(currentState.getEra()!= board.nextRound()) { 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); p.addPrestige(temp);
}); });
playersList.forEach(p->{ 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)); p.addPrestige(temp*p.getNType(CharacterType.INVENTOR));
}); });
playersList.forEach(p->{ playersList.forEach(p->{
@@ -956,7 +952,7 @@ public class Game implements Serializable {
p -> p.getBuildingCards().stream().filter(x -> x.getEffectType() == EffectType.FINAL). p -> p.getBuildingCards().stream().filter(x -> x.getEffectType() == EffectType.FINAL).
forEach(x -> x.applyEffect(p)) forEach(x -> x.applyEffect(p))
); );
currentState.GameStageUpdate(GameStages.ENDED); currentState.gameStageUpdate(GameStages.ENDED);
playerStanding=new ArrayList<>(playersList); playerStanding=new ArrayList<>(playersList);
playerStanding.sort((y,x)->x.getPrestigeValue()==y.getPrestigeValue()?Integer.compare(x.getFoodValue(),y.getFoodValue()):Integer.compare(x.getPrestigeValue(),y.getPrestigeValue())); 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)) .filter(x -> !disconnectedPlayers.containsKey(x) || !disconnectedPlayers.get(x))
.findFirst().orElse(null); .findFirst().orElse(null);
if (winner == null) return; if (winner == null) return;
currentState.GameStageUpdate(GameStages.ENDED); currentState.gameStageUpdate(GameStages.ENDED);
playerStanding = new ArrayList<>(playersList); playerStanding = new ArrayList<>(playersList);
playerStanding.remove(winner); playerStanding.remove(winner);
playerStanding.sort((y, x) -> x.getPrestigeValue() == y.getPrestigeValue() playerStanding.sort((y, x) -> x.getPrestigeValue() == y.getPrestigeValue()
@@ -49,7 +49,7 @@ public class CurrentState implements Serializable {
/** /**
* The current era of the game. * The current era of the game.
*/ */
private int Era; private int era;
/** /**
* Returns the current era of the game. * Returns the current era of the game.
@@ -57,7 +57,7 @@ public class CurrentState implements Serializable {
* @return the current era of the game. * @return the current era of the game.
*/ */
public int getEra(){ public int getEra(){
return Era; return era;
} }
/** /**
@@ -105,7 +105,7 @@ public class CurrentState implements Serializable {
/** /**
* The current stage of the game. * The current stage of the game.
*/ */
private GameStages GameStage; private GameStages gameStage;
/** /**
* Returns the current stage of the game. * Returns the current stage of the game.
@@ -113,7 +113,7 @@ public class CurrentState implements Serializable {
* @return the current stage of the game. * @return the current stage of the game.
*/ */
public GameStages getGameStage(){ public GameStages getGameStage(){
return GameStage; return gameStage;
} }
// endregion getters // endregion getters
@@ -123,28 +123,28 @@ public class CurrentState implements Serializable {
/** /**
* Increments the current era by 1. * Increments the current era by 1.
*/ */
public void EraUpdate(){ public void eraUpdate(){
Era++; era++;
} }
/** /**
* Increments the current round by 1. * Increments the current round by 1.
*/ */
public void RoundUpdate(){ public void roundUpdate(){
round++; round++;
} }
/** /**
* Decrements the number of upper cards by 1. * Decrements the number of upper cards by 1.
*/ */
public void UpperDrawn(){ public void upperDrawn(){
nUpper--; nUpper--;
} }
/** /**
* Decrements the number of lower cards by 1. * Decrements the number of lower cards by 1.
*/ */
public void LowerDrawn(){ public void lowerDrawn(){
nLower--; nLower--;
} }
@@ -153,8 +153,8 @@ public class CurrentState implements Serializable {
* *
* @param GameStage the new game stage. * @param GameStage the new game stage.
*/ */
public void GameStageUpdate(GameStages GameStage){ public void gameStageUpdate(GameStages gameStage){
this.GameStage = GameStage; this.gameStage = gameStage;
} }
// endregion setters // endregion setters
@@ -168,11 +168,11 @@ public class CurrentState implements Serializable {
public CurrentState(){ public CurrentState(){
this.player = null; this.player = null;
this.slot = null; this.slot = null;
this.Era = 1; this.era = 1;
this.round = 1; this.round = 1;
this.nUpper = 0; this.nUpper = 0;
this.nLower = 0; this.nLower = 0;
this.GameStage = GameStages.WAITING; this.gameStage = GameStages.WAITING;
} }
// endregion constructors // endregion constructors
@@ -186,7 +186,7 @@ public class CurrentState implements Serializable {
* @param player the new current player. * @param player the new current player.
* @param slot the new current slot. * @param slot the new current slot.
*/ */
public void PlayerUpdate(Player player, Slot slot){ public void playerUpdate(Player player, Slot slot){
this.player = player; this.player = player;
this.slot = slot; this.slot = slot;
if(slot == null){ if(slot == null){
@@ -212,8 +212,8 @@ public class CurrentState implements Serializable {
List<String>values= new ArrayList<>(); List<String>values= new ArrayList<>();
values.add(player.getUserName()); values.add(player.getUserName());
values.add(Integer.toString(round)); values.add(Integer.toString(round));
values.add(Integer.toString(Era)); values.add(Integer.toString(era));
values.add(GameStage.toString()); values.add(gameStage.toString());
table.addRow(values); table.addRow(values);
return table.build(); return table.build();
} }
@@ -25,7 +25,7 @@ public abstract class PlayableCard implements Serializable {
/** /**
* The era associated with this playable card. * The era associated with this playable card.
*/ */
private int Era; private int era;
/** /**
* Returns the era of this playable card. * Returns the era of this playable card.
@@ -33,7 +33,7 @@ public abstract class PlayableCard implements Serializable {
* @return the era of this playable card. * @return the era of this playable card.
*/ */
public int getEra(){ public int getEra(){
return Era; return era;
} }
/** /**
@@ -45,7 +45,7 @@ public abstract class PlayableCard implements Serializable {
public PlayableCard (int Era) throws IllegalArgumentException{ public PlayableCard (int Era) throws IllegalArgumentException{
idIMG="-1"; idIMG="-1";
if (Era>0 && Era<4) { if (Era>0 && Era<4) {
this.Era = Era; this.era = Era;
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@@ -61,7 +61,7 @@ public abstract class PlayableCard implements Serializable {
public PlayableCard (String idIMG,int Era) throws IllegalArgumentException{ public PlayableCard (String idIMG,int Era) throws IllegalArgumentException{
this.idIMG = idIMG; this.idIMG = idIMG;
if (Era>0 && Era<4) { if (Era>0 && Era<4) {
this.Era = Era; this.era = Era;
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@@ -34,14 +34,14 @@ public class Player implements Serializable {
* exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown * exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
* when the {@link #Player(String) constructor} is called. * when the {@link #Player(String) constructor} is called.
*/ */
private final String UserName; private final String userName;
/** /**
* Getter for the private attribute {@link #UserName}. * Getter for the private attribute {@link #userName}.
* @return {@code String} - The UserName * @return {@code String} - The UserName
*/ */
public String getUserName() { public String getUserName() {
return UserName; return userName;
} }
/** /**
@@ -107,27 +107,27 @@ public class Player implements Serializable {
* The current amount of {@code Food} the Player possesses. * The current amount of {@code Food} the Player possesses.
* Cannot be negative. * Cannot be negative.
*/ */
private int FoodValue; private int foodValue;
/** /**
* Getter for the private attribute {@link #FoodValue}. * Getter for the private attribute {@link #foodValue}.
* @return {@code int} - The amount of Food the player possesses. * @return {@code int} - The amount of Food the player possesses.
*/ */
public int getFoodValue() { public int getFoodValue() {
return FoodValue; return foodValue;
} }
/** /**
* The current amount of {@code Prestige} the Player possesses. * The current amount of {@code Prestige} the Player possesses.
*/ */
private int PrestigeValue; private int prestigeValue;
/** /**
* Getter for the private attribute {@link #PrestigeValue}. * Getter for the private attribute {@link #prestigeValue}.
* @return {@code int} - The amount of Prestige the Player possesses. * @return {@code int} - The amount of Prestige the Player possesses.
*/ */
public int getPrestigeValue() { public int getPrestigeValue() {
return PrestigeValue; return prestigeValue;
} }
// endregion getters // endregion getters
@@ -136,14 +136,14 @@ public class Player implements Serializable {
/** /**
* Adds {@code Value} amount of {@code Food} to the Player. * Adds {@code Value} amount of {@code Food} to the Player.
* @param Value The amount of {@code Food} to be added. * @param value The amount of {@code Food} to be added.
* Should be positive for expected results * Should be positive for expected results
* (otherwise the method will subtract the absolute * (otherwise the method will subtract the absolute
* value of {@code Value}). * value of {@code Value}).
* @see #FoodValue * @see #foodValue
*/ */
public void addFood(int Value){ public void addFood(int value){
this.FoodValue += Value; this.foodValue += value;
} }
/** /**
@@ -157,50 +157,50 @@ public class Player implements Serializable {
/** /**
* Removes {@code Value} amount of {@code Food} from the Player. * Removes {@code Value} amount of {@code Food} from the Player.
* Note: {@link #FoodValue} cannot be negative, so the method returns * Note: {@link #foodValue} cannot be negative, so the method returns
* {@code false} if {@code Value} is greater than the amount of {@code Food} * {@code false} if {@code Value} is greater than the amount of {@code Food}
* the Player possesses, and {@code true} otherwise. * the Player possesses, and {@code true} otherwise.
* *
* @param Value The amount of {@code Food} to be removed. * @param value The amount of {@code Food} to be removed.
* Should be positive for expected results * Should be positive for expected results
* (otherwise the method will add the absolute * (otherwise the method will add the absolute
* value of {@code Value}). * value of {@code Value}).
* @return {@code Boolean} - {@code true} if the Food is successfully removed, * @return {@code Boolean} - {@code true} if the Food is successfully removed,
* {@code false} otherwise. * {@code false} otherwise.
* @see #FoodValue * @see #foodValue
*/ */
public Boolean removeFood(int Value){ public Boolean removeFood(int value){
if(Value > this.FoodValue){ if(value > this.foodValue){
return false; return false;
} }
this.FoodValue -= Value; this.foodValue -= value;
return true; return true;
} }
/** /**
* Adds {@code Value} amount of {@code Prestige} to the Player. * Adds {@code Value} amount of {@code Prestige} to the Player.
* @param Value The amount of {@code Prestige} to be added. * @param value The amount of {@code Prestige} to be added.
* Should be positive for expected results * Should be positive for expected results
* (otherwise the method will subtract the absolute * (otherwise the method will subtract the absolute
* value of {@code Value}). * value of {@code Value}).
* @see #PrestigeValue * @see #prestigeValue
*/ */
public void addPrestige(int Value){ public void addPrestige(int value){
this.PrestigeValue += Value; this.prestigeValue += value;
} }
/** /**
* Removes {@code Value} amount of {@code Prestige} to the Player. * Removes {@code Value} amount of {@code Prestige} to the Player.
* @param Value The amount of {@code Prestige} to be removed. * @param value The amount of {@code Prestige} to be removed.
* Should be positive for expected results * Should be positive for expected results
* (otherwise the method will add the absolute * (otherwise the method will add the absolute
* value of {@code Value}). * value of {@code Value}).
* @see #PrestigeValue * @see #prestigeValue
*/ */
public void removePrestige(int Value){ public void removePrestige(int value){
this.PrestigeValue -= Value; this.prestigeValue -= value;
} }
// endregion setters // endregion setters
@@ -208,21 +208,21 @@ public class Player implements Serializable {
// region Constructors // region Constructors
/** /**
* Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #UserName}. * Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #userName}.
* *
* @param UserName Unique String identifier for a Player. * @param userName Unique String identifier for a Player.
* @throws IllegalArgumentException when {@code UserName} is empty or exceeds {@link #MAX_VALUE}, * @throws IllegalArgumentException when {@code UserName} is empty or exceeds {@link #MAX_VALUE},
* with message: * with message:
* <pre>{@code UserName is empty or exceeds maximum permitted length.}</pre> * <pre>{@code UserName is empty or exceeds maximum permitted length.}</pre>
* *
* @see #UserName * @see #userName
* @see #MAX_VALUE * @see #MAX_VALUE
*/ */
public Player(String UserName) throws IllegalArgumentException { public Player(String userName) throws IllegalArgumentException {
if(UserName.isEmpty() || UserName.length() > MAX_VALUE) { if(userName.isEmpty() || userName.length() > MAX_VALUE) {
throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length."); throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length.");
} }
this.UserName = UserName; this.userName = userName;
this.inventors = new ArrayList <>(); this.inventors = new ArrayList <>();
this.builders = new ArrayList <>(); this.builders = new ArrayList <>();
@@ -232,8 +232,8 @@ public class Player implements Serializable {
this.artists = new ArrayList<>(); this.artists = new ArrayList<>();
this.buildingCards = new ArrayList<>(); this.buildingCards = new ArrayList<>();
this.FoodValue = 0; this.foodValue = 0;
this.PrestigeValue = 0; this.prestigeValue = 0;
this.totem = null; this.totem = null;
} }
// endregion constructors // endregion constructors
@@ -244,20 +244,20 @@ public class Player implements Serializable {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true; if (this == obj) return true;
if (!(obj instanceof Player)) return false; if (!(obj instanceof Player)) return false;
return UserName.equals(((Player) obj).UserName); return userName.equals(((Player) obj).userName);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return UserName.hashCode(); return userName.hashCode();
} }
/** /**
* Prints the {@code Player}'s attributes for the {@code Board}'s representation. * Prints the {@code Player}'s attributes for the {@code Board}'s representation.
* Uses the {@code UNICODE} border style. * Uses the {@code UNICODE} border style.
* <p><b>Includes:</b> * <p><b>Includes:</b>
* <li>{@link #FoodValue Food} * <li>{@link #foodValue Food}
* <li>{@link #PrestigeValue Prestige} * <li>{@link #prestigeValue Prestige}
* <li>{@link #artists Artists} * <li>{@link #artists Artists}
* <li>{@link #builders Builders} * <li>{@link #builders Builders}
* <li>{@link #gatherers Gatherers} * <li>{@link #gatherers Gatherers}
@@ -271,7 +271,7 @@ public class Player implements Serializable {
*/ */
@Override @Override
public String toString() { public String toString() {
int Last = -1; int last = -1;
var table = new AsciiTable(ROUNDED, 1); var table = new AsciiTable(ROUNDED, 1);
@@ -280,55 +280,55 @@ public class Player implements Serializable {
table.addSeparator(); table.addSeparator();
if(!this.hunters.isEmpty()){ if(!this.hunters.isEmpty()){
Last = 6; last = 6;
} }
else if(!this.inventors.isEmpty()){ else if(!this.inventors.isEmpty()){
Last = 5; last = 5;
} }
else if(!this.shamans.isEmpty()){ else if(!this.shamans.isEmpty()){
Last = 4; last = 4;
} }
else if(!this.gatherers.isEmpty()){ else if(!this.gatherers.isEmpty()){
Last = 3; last = 3;
} }
else if(!this.builders.isEmpty()){ else if(!this.builders.isEmpty()){
Last = 2; last = 2;
} }
else if(!this.artists.isEmpty()){ else if(!this.artists.isEmpty()){
Last = 1; last = 1;
} }
else{ else{
Last = 0; last = 0;
} }
if(Last == 0){ if(last == 0){
table.addSeparator(); table.addSeparator();
} }
table.addRow("CHARACTERS"); table.addRow("CHARACTERS");
if(!this.artists.isEmpty()){ if(!this.artists.isEmpty()){
table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size()); table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size());
if(Last == 1){ if(last == 1){
table.addSeparator(); table.addSeparator();
} }
} }
if(!this.builders.isEmpty()){ if(!this.builders.isEmpty()){
table.addRow(this.builders.size() + " Builders: " + "\uD83D\uDD28:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum()); table.addRow(this.builders.size() + " Builders: " + "\uD83D\uDD28:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());
if(Last == 2){ if(last == 2){
table.addSeparator(); table.addSeparator();
} }
} }
if(!this.gatherers.isEmpty()){ if(!this.gatherers.isEmpty()){
table.addRow(this.gatherers.size() + " Gatherers: -\uD83E\uDD57:" + 3*this.gatherers.size()); table.addRow(this.gatherers.size() + " Gatherers: -\uD83E\uDD57:" + 3*this.gatherers.size());
if(Last == 3){ if(last == 3){
table.addSeparator(); table.addSeparator();
} }
} }
if(!this.shamans.isEmpty()){ if(!this.shamans.isEmpty()){
table.addRow(this.shamans.size() + " Shamans: " + "\uD83C\uDF1F:" + this.shamans.stream().mapToInt(Shaman::getIcon).sum()); table.addRow(this.shamans.size() + " Shamans: " + "\uD83C\uDF1F:" + this.shamans.stream().mapToInt(Shaman::getIcon).sum());
if(Last == 4){ if(last == 4){
table.addSeparator(); table.addSeparator();
} }
} }
@@ -336,14 +336,14 @@ public class Player implements Serializable {
if(!this.inventors.isEmpty()){ if(!this.inventors.isEmpty()){
table.addRow(this.inventors.size() + " Inventors: " + this.inventors.stream() table.addRow(this.inventors.size() + " Inventors: " + this.inventors.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
Inventor::Icon, Inventor::getIcon,
Collectors.counting() Collectors.counting()
)) ))
.entrySet().stream() .entrySet().stream()
.sorted(Map.Entry.comparingByKey()) .sorted(Map.Entry.comparingByKey())
.map(e -> e.getKey() + ":" + e.getValue()) .map(e -> e.getKey() + ":" + e.getValue())
.collect(Collectors.joining(", "))); .collect(Collectors.joining(", ")));
if(Last == 5){ if(last == 5){
table.addSeparator(); table.addSeparator();
} }
} }
@@ -56,18 +56,17 @@ public class DisconnectedPlayer extends NetworkEvent implements Serializable{
*/ */
@Override @Override
public boolean apply(MiniModel miniModel){ public boolean apply(MiniModel miniModel){
if (miniModel == null) return true;
synchronized (miniModel) { synchronized (miniModel) {
if (isError) if (isError)
return false; return false;
if (miniModel != null) { miniModel.setPlayers(playerList);
miniModel.setPlayers(playerList); miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setOrderLogicCard(orderLogicCard); miniModel.setCurrentState(currentState);
miniModel.setCurrentState(currentState); miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setSlotPlayerMap(slotPlayerMap); miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setDisconnectedPlayers(disconnectedPlayers); miniModel.setAvailableTotems(availableTotems);
miniModel.setAvailableTotems(availableTotems); miniModel.setLastEvent(this);
miniModel.setLastEvent(this);
}
return true; return true;
} }
} }
@@ -54,19 +54,16 @@ public class ReconnectPlayer extends NetworkEvent implements Serializable {
*/ */
@Override @Override
public boolean apply(MiniModel miniModel) { public boolean apply(MiniModel miniModel) {
if (miniModel == null) return true;
synchronized (miniModel) { synchronized (miniModel) {
if (isError) if (isError)
return false; return false;
miniModel.setPlayers(playerList);
if (miniModel != null) { miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setPlayers(playerList); miniModel.setCurrentState(currentState);
miniModel.setOrderLogicCard(orderLogicCard); miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setCurrentState(currentState); miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setSlotPlayerMap(slotPlayerMap); miniModel.setLastEvent(this);
miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setLastEvent(this);
}
return true; return true;
} }
} }
@@ -156,7 +156,7 @@ public class TCPClient implements IClient {
sender.shutdownNow(); sender.shutdownNow();
} }
} }
private void disconnect() { private synchronized void disconnect() {
if (!running) return; if (!running) return;
running = false; running = false;
try { communicationSocket.close(); } catch (IOException ignored) {} try { communicationSocket.close(); } catch (IOException ignored) {}
@@ -139,7 +139,8 @@ public class ClientHandler implements Runnable {
* The player is marked as disconnected, a {@link DisconnectedPlayer} event is * The player is marked as disconnected, a {@link DisconnectedPlayer} event is
* added to the action queue, and the associated socket is closed. * added to the action queue, and the associated socket is closed.
*/ */
public void disconnect() { public synchronized void disconnect() {
if (!running) return;
running = false; running = false;
clientHandlers.remove(this); clientHandlers.remove(this);
limitedMap.put(username, false); limitedMap.put(username, false);
@@ -182,6 +182,7 @@ public class GUI extends Application implements IView {
*/ */
public void render() { public void render() {
Platform.runLater(() -> { Platform.runLater(() -> {
if (miniModel == null) return;
synchronized (miniModel) { synchronized (miniModel) {
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) { if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
controllerTotem.render(); controllerTotem.render();
@@ -260,10 +261,10 @@ public class GUI extends Application implements IView {
controllerLogin.showError(error); controllerLogin.showError(error);
fadeToScene(loginScene); fadeToScene(loginScene);
} else { } else {
if (miniModel == null) return;
synchronized (miniModel) { synchronized (miniModel) {
controllerMain.isError = true; controllerMain.isError = true;
controllerMain.render(); controllerMain.render();
} }
} }
}); });
@@ -249,13 +249,13 @@ public class MainFXMLController {
HBox prestigeBox = new HBox(1); HBox prestigeBox = new HBox(1);
prestigeBox.setAlignment(Pos.CENTER); prestigeBox.setAlignment(Pos.CENTER);
ImageView PPIcon = new ImageView(loadImage("/GUIImages/Icons/PrestigePoint.png")); ImageView ppIcon = new ImageView(loadImage("/GUIImages/Icons/PrestigePoint.png"));
PPIcon.setFitHeight(35); ppIcon.setFitHeight(35);
PPIcon.setPreserveRatio(true); ppIcon.setPreserveRatio(true);
Label prestigeLabel = new Label(String.valueOf(player.getPrestigeValue())); Label prestigeLabel = new Label(String.valueOf(player.getPrestigeValue()));
prestigeLabel.getStyleClass().add("label-small"); prestigeLabel.getStyleClass().add("label-small");
prestigeLabels.put(player.getUserName(), prestigeLabel); prestigeLabels.put(player.getUserName(), prestigeLabel);
prestigeBox.getChildren().addAll(PPIcon, prestigeLabel); prestigeBox.getChildren().addAll(ppIcon, prestigeLabel);
ImageView buildingIcon = new ImageView(loadImage("/GUIImages/Icons/Building.png")); ImageView buildingIcon = new ImageView(loadImage("/GUIImages/Icons/Building.png"));
buildingIcon.setFitWidth(28); buildingIcon.setFitWidth(28);
@@ -30,7 +30,7 @@ class Building11Test {
assertEquals(EffectType.FINAL, b0.getEffectType()); assertEquals(EffectType.FINAL, b0.getEffectType());
assertEquals(11, b0.getEffectId()); assertEquals(11, b0.getEffectId());
assertEquals(ct, b0.getIcon()); assertEquals(ct, b0.getIcon());
assertEquals(pm, b0.getprestigeMul()); assertEquals(pm, b0.getPrestigeMul());
} }
@Test @Test
@@ -56,7 +56,7 @@ class Building11Test {
assertEquals(price, b1.getPrice()); assertEquals(price, b1.getPrice());
assertEquals(prestigeValue, b1.getPrestigeValue()); assertEquals(prestigeValue, b1.getPrestigeValue());
assertEquals(ct, b1.getIcon()); assertEquals(ct, b1.getIcon());
assertEquals(pm, b1.getprestigeMul()); assertEquals(pm, b1.getPrestigeMul());
} }
@Test @Test
@@ -174,7 +174,7 @@ class Building11Test {
assertEquals(EffectType.FINAL, b11.getEffectType()); assertEquals(EffectType.FINAL, b11.getEffectType());
assertEquals(11, b11.getEffectId()); assertEquals(11, b11.getEffectId());
assertEquals(ct, b11.getIcon()); assertEquals(ct, b11.getIcon());
assertEquals(pm, b11.getprestigeMul()); assertEquals(pm, b11.getPrestigeMul());
} }
@Test @Test
@@ -12,7 +12,7 @@ class InventorTest {
void icon() { void icon() {
Inventor i = new Inventor(1, 5); Inventor i = new Inventor(1, 5);
assertEquals(5, i.Icon()); assertEquals(5, i.getIcon());
} }
@Test @Test
@@ -22,7 +22,7 @@ class InventorTest {
assertNotNull(s); assertNotNull(s);
assertFalse(s.contains(CharacterType.INVENTOR.toString())); assertFalse(s.contains(CharacterType.INVENTOR.toString()));
assertEquals("ID:" + i.Icon(), s); assertEquals("ID:" + i.getIcon(), s);
} }
@Test @Test
@@ -44,7 +44,7 @@ class InventorTest {
assertEquals(i.getIdIMG(), clone.getIdIMG()); assertEquals(i.getIdIMG(), clone.getIdIMG());
assertEquals(i.getEra(), clone.getEra()); assertEquals(i.getEra(), clone.getEra());
assertEquals(i.getType(), clone.getType()); assertEquals(i.getType(), clone.getType());
assertEquals(i.Icon(), clone.Icon()); assertEquals(i.getIcon(), clone.getIcon());
assertEquals(i.getNMin(), clone.getNMin()); assertEquals(i.getNMin(), clone.getNMin());
} }
@@ -65,7 +65,7 @@ class InventorTest {
assertEquals(1, insertedInventor.getEra()); assertEquals(1, insertedInventor.getEra());
assertEquals(5, insertedInventor.getNMin()); assertEquals(5, insertedInventor.getNMin());
assertEquals(CharacterType.INVENTOR, insertedInventor.getType()); assertEquals(CharacterType.INVENTOR, insertedInventor.getType());
assertEquals(5, insertedInventor.Icon()); assertEquals(5, insertedInventor.getIcon());
} }
@Test @Test
@@ -74,7 +74,7 @@ class InventorTest {
assertEquals(1, i.getEra()); assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.getIcon());
assertEquals(0, i.getNMin()); assertEquals(0, i.getNMin());
assertFalse(i.isEventCard()); assertFalse(i.isEventCard());
} }
@@ -85,7 +85,7 @@ class InventorTest {
assertEquals(1, i.getEra()); assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.getIcon());
assertEquals(3, i.getNMin()); assertEquals(3, i.getNMin());
assertFalse(i.isEventCard()); assertFalse(i.isEventCard());
} }
@@ -97,7 +97,7 @@ class InventorTest {
assertEquals("inventor1", i.getIdIMG()); assertEquals("inventor1", i.getIdIMG());
assertEquals(1, i.getEra()); assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.getIcon());
assertEquals(0, i.getNMin()); assertEquals(0, i.getNMin());
assertFalse(i.isEventCard()); assertFalse(i.isEventCard());
} }
@@ -109,7 +109,7 @@ class InventorTest {
assertEquals("inventor1", i.getIdIMG()); assertEquals("inventor1", i.getIdIMG());
assertEquals(1, i.getEra()); assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.getIcon());
assertEquals(3, i.getNMin()); assertEquals(3, i.getNMin());
assertFalse(i.isEventCard()); assertFalse(i.isEventCard());
} }
@@ -24,7 +24,7 @@ class SustenanceTest {
// Gli attributi di Sustenance era e EventType vengono testati in EventCardTest. // Gli attributi di Sustenance era e EventType vengono testati in EventCardTest.
Sustenance s = new Sustenance(era, prestigeDebt); Sustenance s = new Sustenance(era, prestigeDebt);
assertEquals(prestigeDebt, s.getprestigeDebt()); assertEquals(prestigeDebt, s.getPrestigeDebt());
} }
@Test @Test
@@ -147,7 +147,7 @@ class SustenanceTest {
assertEquals(era, s2.getEra()); assertEquals(era, s2.getEra());
assertEquals(EventType.SUSTENANCE, s2.getType()); assertEquals(EventType.SUSTENANCE, s2.getType());
assertEquals(prestigeDebt, s2.getprestigeDebt()); assertEquals(prestigeDebt, s2.getPrestigeDebt());
} }
@Test @Test
@@ -13,7 +13,7 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
assertEquals(p, curr.getCurrentPlayer()); assertEquals(p, curr.getCurrentPlayer());
} }
@@ -22,7 +22,7 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
assertEquals(s, curr.getSlot()); assertEquals(s, curr.getSlot());
} }
@@ -31,8 +31,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.EraUpdate(); curr.eraUpdate();
assertEquals(2, curr.getEra()); assertEquals(2, curr.getEra());
} }
@@ -41,8 +41,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.RoundUpdate(); curr.roundUpdate();
assertEquals(2, curr.getRound()); assertEquals(2, curr.getRound());
} }
@@ -51,8 +51,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.UpperDrawn(); curr.upperDrawn();
assertEquals(-1, curr.getNUpper()); assertEquals(-1, curr.getNUpper());
} }
@@ -61,8 +61,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.LowerDrawn(); curr.lowerDrawn();
assertEquals(-1, curr.getNLower()); assertEquals(-1, curr.getNLower());
} }
@@ -72,8 +72,8 @@ class CurrentStateTest {
Slot s = new Slot('A'); Slot s = new Slot('A');
GameStages g = GameStages.RES_ACTIONS; GameStages g = GameStages.RES_ACTIONS;
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.GameStageUpdate(g); curr.gameStageUpdate(g);
assertEquals(g, curr.getGameStage()); assertEquals(g, curr.getGameStage());
} }
@@ -82,8 +82,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.EraUpdate(); curr.eraUpdate();
assertEquals(2, curr.getEra()); assertEquals(2, curr.getEra());
} }
@@ -92,8 +92,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.RoundUpdate(); curr.roundUpdate();
assertEquals(2, curr.getRound()); assertEquals(2, curr.getRound());
} }
@@ -102,8 +102,8 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.UpperDrawn(); curr.upperDrawn();
assertEquals(-1, curr.getNUpper()); assertEquals(-1, curr.getNUpper());
} }
@@ -112,9 +112,9 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('A'); Slot s = new Slot('A');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.LowerDrawn(); curr.lowerDrawn();
curr.LowerDrawn(); curr.lowerDrawn();
assertEquals(-2, curr.getNLower()); assertEquals(-2, curr.getNLower());
} }
@@ -125,8 +125,8 @@ class CurrentStateTest {
GameStages g = GameStages.RES_ACTIONS; GameStages g = GameStages.RES_ACTIONS;
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
assertEquals(GameStages.WAITING, curr.getGameStage()); assertEquals(GameStages.WAITING, curr.getGameStage());
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
curr.GameStageUpdate(g); curr.gameStageUpdate(g);
assertEquals(GameStages.RES_ACTIONS, curr.getGameStage()); assertEquals(GameStages.RES_ACTIONS, curr.getGameStage());
} }
@@ -135,7 +135,7 @@ class CurrentStateTest {
Player p = new Player("test"); Player p = new Player("test");
Slot s = new Slot('C'); Slot s = new Slot('C');
CurrentState curr = new CurrentState(); CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s); curr.playerUpdate(p, s);
assertEquals(p, curr.getCurrentPlayer()); assertEquals(p, curr.getCurrentPlayer());
assertEquals(s, curr.getSlot()); assertEquals(s, curr.getSlot());
} }
@@ -52,7 +52,7 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer(); Player current = game.getCurrentState().getCurrentPlayer();
order.add(current); order.add(current);
assertTrue(game.SlotChoiceByIndex(current, i)); assertTrue(game.slotChoiceByIndex(current, i));
assertTrue( assertTrue(
game.getSlotMap().values().stream() game.getSlotMap().values().stream()
@@ -108,12 +108,12 @@ class GameTest {
int index = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards()); int index = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
if (index != -1) { if (index != -1) {
assertTrue(game.DrawLowerTribeCardByIndex(current, index)); assertTrue(game.drawLowerTribeCardByIndex(current, index));
return; return;
} }
if (!game.getLowerListBuilding().isEmpty() if (!game.getLowerListBuilding().isEmpty()
&& game.DrawLowerBuildingCardByIndex(current, 0)) { && game.drawLowerBuildingCardByIndex(current, 0)) {
return; return;
} }
@@ -129,12 +129,12 @@ class GameTest {
int index = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards()); int index = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
if (index != -1) { if (index != -1) {
assertTrue(game.DrawUpperTribeCardByIndex(current, index)); assertTrue(game.drawUpperTribeCardByIndex(current, index));
return; return;
} }
if (!game.getUpperListBuilding().isEmpty() if (!game.getUpperListBuilding().isEmpty()
&& game.DrawUpperBuildingCardByIndex(current, 0)) { && game.drawUpperBuildingCardByIndex(current, 0)) {
return; return;
} }
@@ -424,16 +424,16 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer(); Player current = game.getCurrentState().getCurrentPlayer();
assertFalse(game.SlotChoiceByIndex(current, -1)); assertFalse(game.slotChoiceByIndex(current, -1));
assertFalse(game.SlotChoiceByIndex(current, 999)); assertFalse(game.slotChoiceByIndex(current, 999));
Player wrongPlayer = current.equals(p1) ? p2 : p1; Player wrongPlayer = current.equals(p1) ? p2 : p1;
assertFalse(game.SlotChoiceByIndex(wrongPlayer, 0)); assertFalse(game.slotChoiceByIndex(wrongPlayer, 0));
assertTrue(game.SlotChoiceByIndex(current, 0)); assertTrue(game.slotChoiceByIndex(current, 0));
Player next = game.getCurrentState().getCurrentPlayer(); Player next = game.getCurrentState().getCurrentPlayer();
assertFalse(game.SlotChoiceByIndex(next, 0)); assertFalse(game.slotChoiceByIndex(next, 0));
} }
@Test @Test
@@ -453,7 +453,7 @@ class GameTest {
Queue<Player> players = new LinkedList<>(); Queue<Player> players = new LinkedList<>();
for (int i = 0; i < game.getNPlayers(); i++) { for (int i = 0; i < game.getNPlayers(); i++) {
players.add(game.getCurrentState().getCurrentPlayer()); players.add(game.getCurrentState().getCurrentPlayer());
assertTrue(game.SlotChoiceByIndex(game.getCurrentState().getCurrentPlayer(), i)); assertTrue(game.slotChoiceByIndex(game.getCurrentState().getCurrentPlayer(), i));
} }
Player temp_player; Player temp_player;
@@ -464,7 +464,7 @@ class GameTest {
List<TribeCard> cards = game.getLowerListTribeCards(); List<TribeCard> cards = game.getLowerListTribeCards();
index = firstNonEventIndex(cards); index = firstNonEventIndex(cards);
assertTrue(game.DrawLowerTribeCardByIndex(temp_player, index)); assertTrue(game.drawLowerTribeCardByIndex(temp_player, index));
temp_player = players.poll(); temp_player = players.poll();
assertEquals(temp_player, game.getCurrentState().getCurrentPlayer()); assertEquals(temp_player, game.getCurrentState().getCurrentPlayer());
@@ -483,7 +483,7 @@ class GameTest {
TribeCard temp_card = cards.get(index); TribeCard temp_card = cards.get(index);
assertEquals(nCards - countCards, game.getUpperListTribeCards().size()); assertEquals(nCards - countCards, game.getUpperListTribeCards().size());
assertTrue(game.DrawUpperTribeCardByIndex(temp_player, index)); assertTrue(game.drawUpperTribeCardByIndex(temp_player, index));
drawTribeTest(nCardsByType, temp_card, temp_player); drawTribeTest(nCardsByType, temp_card, temp_player);
countCards++; countCards++;
} }
@@ -491,7 +491,7 @@ class GameTest {
int eventIndex = firstEventIndexOrMinusOne(cards); int eventIndex = firstEventIndexOrMinusOne(cards);
if (eventIndex != -1) { if (eventIndex != -1) {
assertFalse(game.DrawUpperTribeCardByIndex(temp_player, eventIndex)); assertFalse(game.drawUpperTribeCardByIndex(temp_player, eventIndex));
} }
assertFalse(game.getUpperListBuilding().isEmpty()); assertFalse(game.getUpperListBuilding().isEmpty());
@@ -502,11 +502,11 @@ class GameTest {
BuildingCard selectedBuilding = game.getUpperListBuilding().get(index); BuildingCard selectedBuilding = game.getUpperListBuilding().get(index);
temp_player.addFood(selectedBuilding.getPrice()); temp_player.addFood(selectedBuilding.getPrice());
assertTrue(game.DrawUpperBuildingCardByIndex(temp_player, index)); assertTrue(game.drawUpperBuildingCardByIndex(temp_player, index));
int remainingTribeIndex = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards()); int remainingTribeIndex = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
if (remainingTribeIndex != -1) { if (remainingTribeIndex != -1) {
assertFalse(game.DrawUpperTribeCardByIndex(temp_player, remainingTribeIndex)); assertFalse(game.drawUpperTribeCardByIndex(temp_player, remainingTribeIndex));
} }
Player thirdPlayer = players.poll(); Player thirdPlayer = players.poll();
@@ -578,7 +578,7 @@ class GameTest {
int charactersBefore = current.getTotCharacters(); int charactersBefore = current.getTotCharacters();
assertTrue(game.DrawUpperTribeCardByIndex(current, index)); assertTrue(game.drawUpperTribeCardByIndex(current, index));
assertEquals(charactersBefore + 1, current.getTotCharacters()); assertEquals(charactersBefore + 1, current.getTotCharacters());
} }
@@ -616,7 +616,7 @@ class GameTest {
int upperBuildingsBefore = game.getUpperListBuilding().size(); int upperBuildingsBefore = game.getUpperListBuilding().size();
int foodBefore = current.getFoodValue(); int foodBefore = current.getFoodValue();
assertTrue(game.DrawUpperBuildingCardByIndex(current, 0)); assertTrue(game.drawUpperBuildingCardByIndex(current, 0));
assertEquals(buildingsBefore + 1, current.getBuildingCards().size()); assertEquals(buildingsBefore + 1, current.getBuildingCards().size());
assertEquals(upperBuildingsBefore - 1, game.getUpperListBuilding().size()); assertEquals(upperBuildingsBefore - 1, game.getUpperListBuilding().size());
@@ -711,7 +711,7 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer(); Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current); assertNotNull(current);
assertFalse(game.SlotChoiceByIndex(current, 0)); assertFalse(game.slotChoiceByIndex(current, 0));
} }
@Test @Test
@@ -733,10 +733,10 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer(); Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current); assertNotNull(current);
assertFalse(game.DrawLowerTribeCardByIndex(current, 0)); assertFalse(game.drawLowerTribeCardByIndex(current, 0));
assertFalse(game.DrawUpperTribeCardByIndex(current, 0)); assertFalse(game.drawUpperTribeCardByIndex(current, 0));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0)); assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
assertFalse(game.DrawLowerBuildingCardByIndex(current, 0)); assertFalse(game.drawLowerBuildingCardByIndex(current, 0));
/* /*
* The totem choice phase and the slot choice phase are completed, * The totem choice phase and the slot choice phase are completed,
@@ -749,30 +749,30 @@ class GameTest {
Player wrongPlayer = current.equals(p1) ? p2 : p1; Player wrongPlayer = current.equals(p1) ? p2 : p1;
assertFalse(game.DrawLowerTribeCardByIndex(current, -1)); assertFalse(game.drawLowerTribeCardByIndex(current, -1));
assertFalse(game.DrawLowerTribeCardByIndex(current, 999)); assertFalse(game.drawLowerTribeCardByIndex(current, 999));
assertFalse(game.DrawUpperTribeCardByIndex(current, -1)); assertFalse(game.drawUpperTribeCardByIndex(current, -1));
assertFalse(game.DrawUpperTribeCardByIndex(current, 999)); assertFalse(game.drawUpperTribeCardByIndex(current, 999));
assertFalse(game.DrawUpperBuildingCardByIndex(current, -1)); assertFalse(game.drawUpperBuildingCardByIndex(current, -1));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 999)); assertFalse(game.drawUpperBuildingCardByIndex(current, 999));
assertFalse(game.DrawLowerBuildingCardByIndex(current, -1)); assertFalse(game.drawLowerBuildingCardByIndex(current, -1));
assertFalse(game.DrawLowerBuildingCardByIndex(current, 999)); assertFalse(game.drawLowerBuildingCardByIndex(current, 999));
int lowerIndex = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards()); int lowerIndex = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
if (lowerIndex != -1) { if (lowerIndex != -1) {
assertFalse(game.DrawLowerTribeCardByIndex(wrongPlayer, lowerIndex)); assertFalse(game.drawLowerTribeCardByIndex(wrongPlayer, lowerIndex));
} }
int upperIndex = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards()); int upperIndex = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
if (upperIndex != -1) { if (upperIndex != -1) {
assertFalse(game.DrawUpperTribeCardByIndex(wrongPlayer, upperIndex)); assertFalse(game.drawUpperTribeCardByIndex(wrongPlayer, upperIndex));
} }
if (!game.getUpperListBuilding().isEmpty()) { if (!game.getUpperListBuilding().isEmpty()) {
assertFalse(game.DrawUpperBuildingCardByIndex(wrongPlayer, 0)); assertFalse(game.drawUpperBuildingCardByIndex(wrongPlayer, 0));
} }
} }
@@ -785,8 +785,8 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer(); Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current); assertNotNull(current);
assertFalse(game.DrawUpperTribeCardByIndex(current, 0)); assertFalse(game.drawUpperTribeCardByIndex(current, 0));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0)); assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
assertFalse(game.skipTurn(current)); assertFalse(game.skipTurn(current));
} }
@@ -806,15 +806,15 @@ class GameTest {
Player wrongPlayer = current.equals(players.get(0)) ? players.get(1) : players.get(0); Player wrongPlayer = current.equals(players.get(0)) ? players.get(1) : players.get(0);
assertFalse(game.DrawUpperTribeCardByIndex(wrongPlayer, 0)); assertFalse(game.drawUpperTribeCardByIndex(wrongPlayer, 0));
assertFalse(game.DrawUpperBuildingCardByIndex(wrongPlayer, 0)); assertFalse(game.drawUpperBuildingCardByIndex(wrongPlayer, 0));
assertFalse(game.skipTurn(wrongPlayer)); assertFalse(game.skipTurn(wrongPlayer));
assertFalse(game.DrawUpperTribeCardByIndex(current, -1)); assertFalse(game.drawUpperTribeCardByIndex(current, -1));
assertFalse(game.DrawUpperTribeCardByIndex(current, 999)); assertFalse(game.drawUpperTribeCardByIndex(current, 999));
assertFalse(game.DrawUpperBuildingCardByIndex(current, -1)); assertFalse(game.drawUpperBuildingCardByIndex(current, -1));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 999)); assertFalse(game.drawUpperBuildingCardByIndex(current, 999));
} }
@@ -857,7 +857,7 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer(); Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current); assertNotNull(current);
assertTrue(game.SlotChoiceByIndex(current, 0)); assertTrue(game.slotChoiceByIndex(current, 0));
} }
@Test @Test
@@ -1009,7 +1009,7 @@ class GameTest {
"There must be at least one upper building card to test that the player cannot buy it." "There must be at least one upper building card to test that the player cannot buy it."
); );
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0)); assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
} }
@Test @Test
@@ -1044,7 +1044,7 @@ class GameTest {
int foodBefore = current.getFoodValue(); int foodBefore = current.getFoodValue();
assertTrue( assertTrue(
game.DrawLowerBuildingCardByIndex(current, 0), game.drawLowerBuildingCardByIndex(current, 0),
"DrawLowerBuildingCardByIndex should return true when lower building exists, player can draw lower, and player has food." "DrawLowerBuildingCardByIndex should return true when lower building exists, player can draw lower, and player has food."
); );
@@ -1116,7 +1116,7 @@ class GameTest {
int buildingsBefore = current.getBuildingCards().size(); int buildingsBefore = current.getBuildingCards().size();
int upperBuildingsBefore = game.getUpperListBuilding().size(); int upperBuildingsBefore = game.getUpperListBuilding().size();
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0)); assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
assertEquals(buildingsBefore, current.getBuildingCards().size()); assertEquals(buildingsBefore, current.getBuildingCards().size());
assertEquals(upperBuildingsBefore, game.getUpperListBuilding().size()); assertEquals(upperBuildingsBefore, game.getUpperListBuilding().size());
@@ -1146,13 +1146,13 @@ class GameTest {
addPlayers(game, 3, "slot_order_"); addPlayers(game, 3, "slot_order_");
Player firstChooser = game.getCurrentState().getCurrentPlayer(); Player firstChooser = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(firstChooser, 2)); assertTrue(game.slotChoiceByIndex(firstChooser, 2));
Player secondChooser = game.getCurrentState().getCurrentPlayer(); Player secondChooser = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(secondChooser, 0)); assertTrue(game.slotChoiceByIndex(secondChooser, 0));
Player thirdChooser = game.getCurrentState().getCurrentPlayer(); Player thirdChooser = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(thirdChooser, 1)); assertTrue(game.slotChoiceByIndex(thirdChooser, 1));
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage()); assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
@@ -1282,7 +1282,7 @@ class GameTest {
int charactersBefore = current.getTotCharacters(); int charactersBefore = current.getTotCharacters();
int upperSizeBefore = game.getUpperListTribeCards().size(); int upperSizeBefore = game.getUpperListTribeCards().size();
assertFalse(game.DrawUpperTribeCardByIndex(current, eventIndex)); assertFalse(game.drawUpperTribeCardByIndex(current, eventIndex));
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage()); assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
assertEquals(current, game.getCurrentState().getCurrentPlayer()); assertEquals(current, game.getCurrentState().getCurrentPlayer());
@@ -1384,7 +1384,7 @@ class GameTest {
assertTrue(game.disconnectedPlayer(current)); assertTrue(game.disconnectedPlayer(current));
assertFalse(game.disconnectedPlayers.isEmpty()); assertFalse(game.disconnectedPlayers.isEmpty());
game.ClearDisconnected(); game.clearDisconnected();
assertTrue(game.disconnectedPlayers.isEmpty()); assertTrue(game.disconnectedPlayers.isEmpty());
} }
@@ -1427,7 +1427,7 @@ class GameTest {
int buildingsBefore = current.getBuildingCards().size(); int buildingsBefore = current.getBuildingCards().size();
int lowerBuildingsBefore = game.getLowerListBuilding().size(); int lowerBuildingsBefore = game.getLowerListBuilding().size();
assertFalse(game.DrawLowerBuildingCardByIndex(current, 0)); assertFalse(game.drawLowerBuildingCardByIndex(current, 0));
assertEquals(buildingsBefore, current.getBuildingCards().size()); assertEquals(buildingsBefore, current.getBuildingCards().size());
assertEquals(lowerBuildingsBefore, game.getLowerListBuilding().size()); assertEquals(lowerBuildingsBefore, game.getLowerListBuilding().size());
@@ -1478,7 +1478,7 @@ class GameTest {
wrongPlayer.addFood(game.getLowerListBuilding().get(0).getPrice()); wrongPlayer.addFood(game.getLowerListBuilding().get(0).getPrice());
assertFalse(game.DrawLowerBuildingCardByIndex(wrongPlayer, 0)); assertFalse(game.drawLowerBuildingCardByIndex(wrongPlayer, 0));
return; return;
} }
@@ -1534,12 +1534,12 @@ class GameTest {
int foodBefore = current.getFoodValue(); int foodBefore = current.getFoodValue();
assertTrue(game.SlotChoiceByIndex(current, 0)); assertTrue(game.slotChoiceByIndex(current, 0));
for (int i = 1; i < game.getNPlayers(); i++) { for (int i = 1; i < game.getNPlayers(); i++) {
Player temp = game.getCurrentState().getCurrentPlayer(); Player temp = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(temp, i)); assertTrue(game.slotChoiceByIndex(temp, i));
assertTrue( assertTrue(
game.getSlotMap().values().stream() game.getSlotMap().values().stream()
@@ -1552,12 +1552,12 @@ class GameTest {
resolveAllMandatoryActions(game); resolveAllMandatoryActions(game);
foodBefore = current.getFoodValue(); foodBefore = current.getFoodValue();
assertTrue(game.SlotChoiceByIndex(current, 0)); assertTrue(game.slotChoiceByIndex(current, 0));
for (int i = 1; i < game.getNPlayers(); i++) { for (int i = 1; i < game.getNPlayers(); i++) {
Player temp = game.getCurrentState().getCurrentPlayer(); Player temp = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(temp, i)); assertTrue(game.slotChoiceByIndex(temp, i));
assertTrue( assertTrue(
game.getSlotMap().values().stream() game.getSlotMap().values().stream()
@@ -1580,7 +1580,7 @@ class GameTest {
int foodBefore = current.getFoodValue(); int foodBefore = current.getFoodValue();
assertTrue(game.SlotChoiceByIndex(current, 1)); assertTrue(game.slotChoiceByIndex(current, 1));
assertEquals(foodBefore, current.getFoodValue()); assertEquals(foodBefore, current.getFoodValue());
} }