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);
if(player==null)
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);
if(player==null)
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);
if(player==null)
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);
if(player==null)
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);
if(player==null)
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.
*/
public int getprestigeMul() {return prestigeMul;}
public int getPrestigeMul() {return prestigeMul;}
/**
* Creates a Building11 card with the specified era, price, prestige value,
@@ -79,7 +79,7 @@ public class Building11 extends BuildingCard {
*/
@Override
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 {
if(!player.getBuildingCards().contains(this))
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())
{
map.merge(inv.Icon(),1,Integer::sum);
map.merge(inv.getIcon(),1,Integer::sum);
}
numPair=0;
for(Integer i : map.values())
@@ -141,7 +141,7 @@ public class Building4 extends BuildingCard {
}
for(Inventor inv : player.getInventors())
{
map.merge(inv.Icon(),1,Integer::sum);
map.merge(inv.getIcon(),1,Integer::sum);
}
int temp=0;
for(Integer i : map.values())
@@ -20,7 +20,7 @@ public class Inventor extends Character {
*
* @return the icon value of this Inventor card.
*/
public int Icon() {
public int getIcon() {
return icon;
}
@@ -77,21 +77,21 @@ public class CavePaintings extends EventCard {
@Override
public void activateEvent (ArrayList <Player> playerList){
for (Player player : playerList){
int NArtists = player.getNType(CharacterType.ARTIST);
int NBuildings = 0;
int nArtists = player.getNType(CharacterType.ARTIST);
int nBuildings = 0;
ArrayList<BuildingCard> buildingCards = player.getBuildingCards();
for(BuildingCard card : buildingCards){
if(card.getEffectId() == 9){
NBuildings++;
nBuildings++;
}
}
player.addFood(NBuildings * NArtists);
if (NArtists < nLower){
player.addFood(nBuildings * nArtists);
if (nArtists < nLower){
player.removePrestige(nPrestigeRem);
}
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.
*/
public int getprestigeDebt() {
public int getPrestigeDebt() {
return prestigeDebt;
}
@@ -71,30 +71,30 @@ public class Sustenance extends EventCard {
@Override
public void activateEvent (ArrayList <Player> playerList) throws NullPointerException {
for(Player player : playerList){
int NChar = player.getTotCharacters();
int NGatherers = player.getNType(CharacterType.GATHERER);
int nChar = player.getTotCharacters();
int nGatherers = player.getNType(CharacterType.GATHERER);
int NCharDiscount = 0;
int nCharDiscount = 0;
for(BuildingCard b : player.getBuildingCards()){
if(b.getEffectId() == 1){
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;
}
if(player.getFoodValue() >= FoodDebt){
player.removeFood(FoodDebt);
if(player.getFoodValue() >= foodDebt){
player.removeFood(foodDebt);
}
else{
FoodDebt -= player.getFoodValue();
foodDebt -= player.getFoodValue();
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)
{
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()
@@ -49,7 +49,7 @@ public class CurrentState implements Serializable {
/**
* The current era of the game.
*/
private int Era;
private int era;
/**
* Returns the current era of the game.
@@ -57,7 +57,7 @@ public class CurrentState implements Serializable {
* @return the current era of the game.
*/
public int getEra(){
return Era;
return era;
}
/**
@@ -105,7 +105,7 @@ public class CurrentState implements Serializable {
/**
* The current stage of the game.
*/
private GameStages GameStage;
private GameStages gameStage;
/**
* Returns the current stage of the game.
@@ -113,7 +113,7 @@ public class CurrentState implements Serializable {
* @return the current stage of the game.
*/
public GameStages getGameStage(){
return GameStage;
return gameStage;
}
// endregion getters
@@ -123,28 +123,28 @@ public class CurrentState implements Serializable {
/**
* Increments the current era by 1.
*/
public void EraUpdate(){
Era++;
public void eraUpdate(){
era++;
}
/**
* Increments the current round by 1.
*/
public void RoundUpdate(){
public void roundUpdate(){
round++;
}
/**
* Decrements the number of upper cards by 1.
*/
public void UpperDrawn(){
public void upperDrawn(){
nUpper--;
}
/**
* Decrements the number of lower cards by 1.
*/
public void LowerDrawn(){
public void lowerDrawn(){
nLower--;
}
@@ -153,8 +153,8 @@ public class CurrentState implements Serializable {
*
* @param GameStage the new game stage.
*/
public void GameStageUpdate(GameStages GameStage){
this.GameStage = GameStage;
public void gameStageUpdate(GameStages gameStage){
this.gameStage = gameStage;
}
// endregion setters
@@ -168,11 +168,11 @@ public class CurrentState implements Serializable {
public CurrentState(){
this.player = null;
this.slot = null;
this.Era = 1;
this.era = 1;
this.round = 1;
this.nUpper = 0;
this.nLower = 0;
this.GameStage = GameStages.WAITING;
this.gameStage = GameStages.WAITING;
}
// endregion constructors
@@ -186,7 +186,7 @@ public class CurrentState implements Serializable {
* @param player the new current player.
* @param slot the new current slot.
*/
public void PlayerUpdate(Player player, Slot slot){
public void playerUpdate(Player player, Slot slot){
this.player = player;
this.slot = slot;
if(slot == null){
@@ -212,8 +212,8 @@ public class CurrentState implements Serializable {
List<String>values= new ArrayList<>();
values.add(player.getUserName());
values.add(Integer.toString(round));
values.add(Integer.toString(Era));
values.add(GameStage.toString());
values.add(Integer.toString(era));
values.add(gameStage.toString());
table.addRow(values);
return table.build();
}
@@ -25,7 +25,7 @@ public abstract class PlayableCard implements Serializable {
/**
* The era associated with this playable card.
*/
private int Era;
private int era;
/**
* Returns the era of this playable card.
@@ -33,7 +33,7 @@ public abstract class PlayableCard implements Serializable {
* @return the era of this playable card.
*/
public int getEra(){
return Era;
return era;
}
/**
@@ -45,7 +45,7 @@ public abstract class PlayableCard implements Serializable {
public PlayableCard (int Era) throws IllegalArgumentException{
idIMG="-1";
if (Era>0 && Era<4) {
this.Era = Era;
this.era = Era;
} else {
throw new IllegalArgumentException();
}
@@ -61,7 +61,7 @@ public abstract class PlayableCard implements Serializable {
public PlayableCard (String idIMG,int Era) throws IllegalArgumentException{
this.idIMG = idIMG;
if (Era>0 && Era<4) {
this.Era = Era;
this.era = Era;
} else {
throw new IllegalArgumentException();
}
@@ -34,14 +34,14 @@ public class Player implements Serializable {
* exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
* 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
*/
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.
* 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.
*/
public int getFoodValue() {
return FoodValue;
return foodValue;
}
/**
* 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.
*/
public int getPrestigeValue() {
return PrestigeValue;
return prestigeValue;
}
// endregion getters
@@ -136,14 +136,14 @@ public class Player implements Serializable {
/**
* 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
* (otherwise the method will subtract the absolute
* value of {@code Value}).
* @see #FoodValue
* @see #foodValue
*/
public void addFood(int Value){
this.FoodValue += Value;
public void addFood(int value){
this.foodValue += value;
}
/**
@@ -157,50 +157,50 @@ public class Player implements Serializable {
/**
* 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}
* 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
* (otherwise the method will add the absolute
* value of {@code Value}).
* @return {@code Boolean} - {@code true} if the Food is successfully removed,
* {@code false} otherwise.
* @see #FoodValue
* @see #foodValue
*/
public Boolean removeFood(int Value){
if(Value > this.FoodValue){
public Boolean removeFood(int value){
if(value > this.foodValue){
return false;
}
this.FoodValue -= Value;
this.foodValue -= value;
return true;
}
/**
* 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
* (otherwise the method will subtract the absolute
* 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.
* @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
* (otherwise the method will add the absolute
* 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
@@ -208,21 +208,21 @@ public class Player implements Serializable {
// 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},
* with message:
* <pre>{@code UserName is empty or exceeds maximum permitted length.}</pre>
*
* @see #UserName
* @see #userName
* @see #MAX_VALUE
*/
public Player(String UserName) throws IllegalArgumentException {
if(UserName.isEmpty() || UserName.length() > MAX_VALUE) {
public Player(String userName) throws IllegalArgumentException {
if(userName.isEmpty() || userName.length() > MAX_VALUE) {
throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length.");
}
this.UserName = UserName;
this.userName = userName;
this.inventors = new ArrayList <>();
this.builders = new ArrayList <>();
@@ -232,8 +232,8 @@ public class Player implements Serializable {
this.artists = new ArrayList<>();
this.buildingCards = new ArrayList<>();
this.FoodValue = 0;
this.PrestigeValue = 0;
this.foodValue = 0;
this.prestigeValue = 0;
this.totem = null;
}
// endregion constructors
@@ -244,20 +244,20 @@ public class Player implements Serializable {
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Player)) return false;
return UserName.equals(((Player) obj).UserName);
return userName.equals(((Player) obj).userName);
}
@Override
public int hashCode() {
return UserName.hashCode();
return userName.hashCode();
}
/**
* Prints the {@code Player}'s attributes for the {@code Board}'s representation.
* Uses the {@code UNICODE} border style.
* <p><b>Includes:</b>
* <li>{@link #FoodValue Food}
* <li>{@link #PrestigeValue Prestige}
* <li>{@link #foodValue Food}
* <li>{@link #prestigeValue Prestige}
* <li>{@link #artists Artists}
* <li>{@link #builders Builders}
* <li>{@link #gatherers Gatherers}
@@ -271,7 +271,7 @@ public class Player implements Serializable {
*/
@Override
public String toString() {
int Last = -1;
int last = -1;
var table = new AsciiTable(ROUNDED, 1);
@@ -280,55 +280,55 @@ public class Player implements Serializable {
table.addSeparator();
if(!this.hunters.isEmpty()){
Last = 6;
last = 6;
}
else if(!this.inventors.isEmpty()){
Last = 5;
last = 5;
}
else if(!this.shamans.isEmpty()){
Last = 4;
last = 4;
}
else if(!this.gatherers.isEmpty()){
Last = 3;
last = 3;
}
else if(!this.builders.isEmpty()){
Last = 2;
last = 2;
}
else if(!this.artists.isEmpty()){
Last = 1;
last = 1;
}
else{
Last = 0;
last = 0;
}
if(Last == 0){
if(last == 0){
table.addSeparator();
}
table.addRow("CHARACTERS");
if(!this.artists.isEmpty()){
table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size());
if(Last == 1){
if(last == 1){
table.addSeparator();
}
}
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());
if(Last == 2){
if(last == 2){
table.addSeparator();
}
}
if(!this.gatherers.isEmpty()){
table.addRow(this.gatherers.size() + " Gatherers: -\uD83E\uDD57:" + 3*this.gatherers.size());
if(Last == 3){
if(last == 3){
table.addSeparator();
}
}
if(!this.shamans.isEmpty()){
table.addRow(this.shamans.size() + " Shamans: " + "\uD83C\uDF1F:" + this.shamans.stream().mapToInt(Shaman::getIcon).sum());
if(Last == 4){
if(last == 4){
table.addSeparator();
}
}
@@ -336,14 +336,14 @@ public class Player implements Serializable {
if(!this.inventors.isEmpty()){
table.addRow(this.inventors.size() + " Inventors: " + this.inventors.stream()
.collect(Collectors.groupingBy(
Inventor::Icon,
Inventor::getIcon,
Collectors.counting()
))
.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(e -> e.getKey() + ":" + e.getValue())
.collect(Collectors.joining(", ")));
if(Last == 5){
if(last == 5){
table.addSeparator();
}
}
@@ -56,18 +56,17 @@ public class DisconnectedPlayer extends NetworkEvent implements Serializable{
*/
@Override
public boolean apply(MiniModel miniModel){
if (miniModel == null) return true;
synchronized (miniModel) {
if (isError)
return false;
if (miniModel != null) {
miniModel.setPlayers(playerList);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setAvailableTotems(availableTotems);
miniModel.setLastEvent(this);
}
miniModel.setPlayers(playerList);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setAvailableTotems(availableTotems);
miniModel.setLastEvent(this);
return true;
}
}
@@ -54,19 +54,16 @@ public class ReconnectPlayer extends NetworkEvent implements Serializable {
*/
@Override
public boolean apply(MiniModel miniModel) {
if (miniModel == null) return true;
synchronized (miniModel) {
if (isError)
return false;
if (miniModel != null) {
miniModel.setPlayers(playerList);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setLastEvent(this);
}
miniModel.setPlayers(playerList);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setDisconnectedPlayers(disconnectedPlayers);
miniModel.setLastEvent(this);
return true;
}
}
@@ -156,7 +156,7 @@ public class TCPClient implements IClient {
sender.shutdownNow();
}
}
private void disconnect() {
private synchronized void disconnect() {
if (!running) return;
running = false;
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
* added to the action queue, and the associated socket is closed.
*/
public void disconnect() {
public synchronized void disconnect() {
if (!running) return;
running = false;
clientHandlers.remove(this);
limitedMap.put(username, false);
@@ -182,6 +182,7 @@ public class GUI extends Application implements IView {
*/
public void render() {
Platform.runLater(() -> {
if (miniModel == null) return;
synchronized (miniModel) {
if (controller.miniModel.currentState.getGameStage() == TOTEM_CHOICE) {
controllerTotem.render();
@@ -260,10 +261,10 @@ public class GUI extends Application implements IView {
controllerLogin.showError(error);
fadeToScene(loginScene);
} else {
if (miniModel == null) return;
synchronized (miniModel) {
controllerMain.isError = true;
controllerMain.render();
}
}
});
@@ -249,13 +249,13 @@ public class MainFXMLController {
HBox prestigeBox = new HBox(1);
prestigeBox.setAlignment(Pos.CENTER);
ImageView PPIcon = new ImageView(loadImage("/GUIImages/Icons/PrestigePoint.png"));
PPIcon.setFitHeight(35);
PPIcon.setPreserveRatio(true);
ImageView ppIcon = new ImageView(loadImage("/GUIImages/Icons/PrestigePoint.png"));
ppIcon.setFitHeight(35);
ppIcon.setPreserveRatio(true);
Label prestigeLabel = new Label(String.valueOf(player.getPrestigeValue()));
prestigeLabel.getStyleClass().add("label-small");
prestigeLabels.put(player.getUserName(), prestigeLabel);
prestigeBox.getChildren().addAll(PPIcon, prestigeLabel);
prestigeBox.getChildren().addAll(ppIcon, prestigeLabel);
ImageView buildingIcon = new ImageView(loadImage("/GUIImages/Icons/Building.png"));
buildingIcon.setFitWidth(28);
@@ -30,7 +30,7 @@ class Building11Test {
assertEquals(EffectType.FINAL, b0.getEffectType());
assertEquals(11, b0.getEffectId());
assertEquals(ct, b0.getIcon());
assertEquals(pm, b0.getprestigeMul());
assertEquals(pm, b0.getPrestigeMul());
}
@Test
@@ -56,7 +56,7 @@ class Building11Test {
assertEquals(price, b1.getPrice());
assertEquals(prestigeValue, b1.getPrestigeValue());
assertEquals(ct, b1.getIcon());
assertEquals(pm, b1.getprestigeMul());
assertEquals(pm, b1.getPrestigeMul());
}
@Test
@@ -174,7 +174,7 @@ class Building11Test {
assertEquals(EffectType.FINAL, b11.getEffectType());
assertEquals(11, b11.getEffectId());
assertEquals(ct, b11.getIcon());
assertEquals(pm, b11.getprestigeMul());
assertEquals(pm, b11.getPrestigeMul());
}
@Test
@@ -12,7 +12,7 @@ class InventorTest {
void icon() {
Inventor i = new Inventor(1, 5);
assertEquals(5, i.Icon());
assertEquals(5, i.getIcon());
}
@Test
@@ -22,7 +22,7 @@ class InventorTest {
assertNotNull(s);
assertFalse(s.contains(CharacterType.INVENTOR.toString()));
assertEquals("ID:" + i.Icon(), s);
assertEquals("ID:" + i.getIcon(), s);
}
@Test
@@ -44,7 +44,7 @@ class InventorTest {
assertEquals(i.getIdIMG(), clone.getIdIMG());
assertEquals(i.getEra(), clone.getEra());
assertEquals(i.getType(), clone.getType());
assertEquals(i.Icon(), clone.Icon());
assertEquals(i.getIcon(), clone.getIcon());
assertEquals(i.getNMin(), clone.getNMin());
}
@@ -65,7 +65,7 @@ class InventorTest {
assertEquals(1, insertedInventor.getEra());
assertEquals(5, insertedInventor.getNMin());
assertEquals(CharacterType.INVENTOR, insertedInventor.getType());
assertEquals(5, insertedInventor.Icon());
assertEquals(5, insertedInventor.getIcon());
}
@Test
@@ -74,7 +74,7 @@ class InventorTest {
assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon());
assertEquals(5, i.getIcon());
assertEquals(0, i.getNMin());
assertFalse(i.isEventCard());
}
@@ -85,7 +85,7 @@ class InventorTest {
assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon());
assertEquals(5, i.getIcon());
assertEquals(3, i.getNMin());
assertFalse(i.isEventCard());
}
@@ -97,7 +97,7 @@ class InventorTest {
assertEquals("inventor1", i.getIdIMG());
assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon());
assertEquals(5, i.getIcon());
assertEquals(0, i.getNMin());
assertFalse(i.isEventCard());
}
@@ -109,7 +109,7 @@ class InventorTest {
assertEquals("inventor1", i.getIdIMG());
assertEquals(1, i.getEra());
assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon());
assertEquals(5, i.getIcon());
assertEquals(3, i.getNMin());
assertFalse(i.isEventCard());
}
@@ -24,7 +24,7 @@ class SustenanceTest {
// Gli attributi di Sustenance era e EventType vengono testati in EventCardTest.
Sustenance s = new Sustenance(era, prestigeDebt);
assertEquals(prestigeDebt, s.getprestigeDebt());
assertEquals(prestigeDebt, s.getPrestigeDebt());
}
@Test
@@ -147,7 +147,7 @@ class SustenanceTest {
assertEquals(era, s2.getEra());
assertEquals(EventType.SUSTENANCE, s2.getType());
assertEquals(prestigeDebt, s2.getprestigeDebt());
assertEquals(prestigeDebt, s2.getPrestigeDebt());
}
@Test
@@ -13,7 +13,7 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.playerUpdate(p, s);
assertEquals(p, curr.getCurrentPlayer());
}
@@ -22,7 +22,7 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.playerUpdate(p, s);
assertEquals(s, curr.getSlot());
}
@@ -31,8 +31,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.EraUpdate();
curr.playerUpdate(p, s);
curr.eraUpdate();
assertEquals(2, curr.getEra());
}
@@ -41,8 +41,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.RoundUpdate();
curr.playerUpdate(p, s);
curr.roundUpdate();
assertEquals(2, curr.getRound());
}
@@ -51,8 +51,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.UpperDrawn();
curr.playerUpdate(p, s);
curr.upperDrawn();
assertEquals(-1, curr.getNUpper());
}
@@ -61,8 +61,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.LowerDrawn();
curr.playerUpdate(p, s);
curr.lowerDrawn();
assertEquals(-1, curr.getNLower());
}
@@ -72,8 +72,8 @@ class CurrentStateTest {
Slot s = new Slot('A');
GameStages g = GameStages.RES_ACTIONS;
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.GameStageUpdate(g);
curr.playerUpdate(p, s);
curr.gameStageUpdate(g);
assertEquals(g, curr.getGameStage());
}
@@ -82,8 +82,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.EraUpdate();
curr.playerUpdate(p, s);
curr.eraUpdate();
assertEquals(2, curr.getEra());
}
@@ -92,8 +92,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.RoundUpdate();
curr.playerUpdate(p, s);
curr.roundUpdate();
assertEquals(2, curr.getRound());
}
@@ -102,8 +102,8 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.UpperDrawn();
curr.playerUpdate(p, s);
curr.upperDrawn();
assertEquals(-1, curr.getNUpper());
}
@@ -112,9 +112,9 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('A');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.LowerDrawn();
curr.LowerDrawn();
curr.playerUpdate(p, s);
curr.lowerDrawn();
curr.lowerDrawn();
assertEquals(-2, curr.getNLower());
}
@@ -125,8 +125,8 @@ class CurrentStateTest {
GameStages g = GameStages.RES_ACTIONS;
CurrentState curr = new CurrentState();
assertEquals(GameStages.WAITING, curr.getGameStage());
curr.PlayerUpdate(p, s);
curr.GameStageUpdate(g);
curr.playerUpdate(p, s);
curr.gameStageUpdate(g);
assertEquals(GameStages.RES_ACTIONS, curr.getGameStage());
}
@@ -135,7 +135,7 @@ class CurrentStateTest {
Player p = new Player("test");
Slot s = new Slot('C');
CurrentState curr = new CurrentState();
curr.PlayerUpdate(p, s);
curr.playerUpdate(p, s);
assertEquals(p, curr.getCurrentPlayer());
assertEquals(s, curr.getSlot());
}
@@ -52,7 +52,7 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer();
order.add(current);
assertTrue(game.SlotChoiceByIndex(current, i));
assertTrue(game.slotChoiceByIndex(current, i));
assertTrue(
game.getSlotMap().values().stream()
@@ -108,12 +108,12 @@ class GameTest {
int index = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
if (index != -1) {
assertTrue(game.DrawLowerTribeCardByIndex(current, index));
assertTrue(game.drawLowerTribeCardByIndex(current, index));
return;
}
if (!game.getLowerListBuilding().isEmpty()
&& game.DrawLowerBuildingCardByIndex(current, 0)) {
&& game.drawLowerBuildingCardByIndex(current, 0)) {
return;
}
@@ -129,12 +129,12 @@ class GameTest {
int index = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
if (index != -1) {
assertTrue(game.DrawUpperTribeCardByIndex(current, index));
assertTrue(game.drawUpperTribeCardByIndex(current, index));
return;
}
if (!game.getUpperListBuilding().isEmpty()
&& game.DrawUpperBuildingCardByIndex(current, 0)) {
&& game.drawUpperBuildingCardByIndex(current, 0)) {
return;
}
@@ -424,16 +424,16 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer();
assertFalse(game.SlotChoiceByIndex(current, -1));
assertFalse(game.SlotChoiceByIndex(current, 999));
assertFalse(game.slotChoiceByIndex(current, -1));
assertFalse(game.slotChoiceByIndex(current, 999));
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();
assertFalse(game.SlotChoiceByIndex(next, 0));
assertFalse(game.slotChoiceByIndex(next, 0));
}
@Test
@@ -453,7 +453,7 @@ class GameTest {
Queue<Player> players = new LinkedList<>();
for (int i = 0; i < game.getNPlayers(); i++) {
players.add(game.getCurrentState().getCurrentPlayer());
assertTrue(game.SlotChoiceByIndex(game.getCurrentState().getCurrentPlayer(), i));
assertTrue(game.slotChoiceByIndex(game.getCurrentState().getCurrentPlayer(), i));
}
Player temp_player;
@@ -464,7 +464,7 @@ class GameTest {
List<TribeCard> cards = game.getLowerListTribeCards();
index = firstNonEventIndex(cards);
assertTrue(game.DrawLowerTribeCardByIndex(temp_player, index));
assertTrue(game.drawLowerTribeCardByIndex(temp_player, index));
temp_player = players.poll();
assertEquals(temp_player, game.getCurrentState().getCurrentPlayer());
@@ -483,7 +483,7 @@ class GameTest {
TribeCard temp_card = cards.get(index);
assertEquals(nCards - countCards, game.getUpperListTribeCards().size());
assertTrue(game.DrawUpperTribeCardByIndex(temp_player, index));
assertTrue(game.drawUpperTribeCardByIndex(temp_player, index));
drawTribeTest(nCardsByType, temp_card, temp_player);
countCards++;
}
@@ -491,7 +491,7 @@ class GameTest {
int eventIndex = firstEventIndexOrMinusOne(cards);
if (eventIndex != -1) {
assertFalse(game.DrawUpperTribeCardByIndex(temp_player, eventIndex));
assertFalse(game.drawUpperTribeCardByIndex(temp_player, eventIndex));
}
assertFalse(game.getUpperListBuilding().isEmpty());
@@ -502,11 +502,11 @@ class GameTest {
BuildingCard selectedBuilding = game.getUpperListBuilding().get(index);
temp_player.addFood(selectedBuilding.getPrice());
assertTrue(game.DrawUpperBuildingCardByIndex(temp_player, index));
assertTrue(game.drawUpperBuildingCardByIndex(temp_player, index));
int remainingTribeIndex = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
if (remainingTribeIndex != -1) {
assertFalse(game.DrawUpperTribeCardByIndex(temp_player, remainingTribeIndex));
assertFalse(game.drawUpperTribeCardByIndex(temp_player, remainingTribeIndex));
}
Player thirdPlayer = players.poll();
@@ -578,7 +578,7 @@ class GameTest {
int charactersBefore = current.getTotCharacters();
assertTrue(game.DrawUpperTribeCardByIndex(current, index));
assertTrue(game.drawUpperTribeCardByIndex(current, index));
assertEquals(charactersBefore + 1, current.getTotCharacters());
}
@@ -616,7 +616,7 @@ class GameTest {
int upperBuildingsBefore = game.getUpperListBuilding().size();
int foodBefore = current.getFoodValue();
assertTrue(game.DrawUpperBuildingCardByIndex(current, 0));
assertTrue(game.drawUpperBuildingCardByIndex(current, 0));
assertEquals(buildingsBefore + 1, current.getBuildingCards().size());
assertEquals(upperBuildingsBefore - 1, game.getUpperListBuilding().size());
@@ -711,7 +711,7 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current);
assertFalse(game.SlotChoiceByIndex(current, 0));
assertFalse(game.slotChoiceByIndex(current, 0));
}
@Test
@@ -733,10 +733,10 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current);
assertFalse(game.DrawLowerTribeCardByIndex(current, 0));
assertFalse(game.DrawUpperTribeCardByIndex(current, 0));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0));
assertFalse(game.DrawLowerBuildingCardByIndex(current, 0));
assertFalse(game.drawLowerTribeCardByIndex(current, 0));
assertFalse(game.drawUpperTribeCardByIndex(current, 0));
assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
assertFalse(game.drawLowerBuildingCardByIndex(current, 0));
/*
* The totem choice phase and the slot choice phase are completed,
@@ -749,30 +749,30 @@ class GameTest {
Player wrongPlayer = current.equals(p1) ? p2 : p1;
assertFalse(game.DrawLowerTribeCardByIndex(current, -1));
assertFalse(game.DrawLowerTribeCardByIndex(current, 999));
assertFalse(game.drawLowerTribeCardByIndex(current, -1));
assertFalse(game.drawLowerTribeCardByIndex(current, 999));
assertFalse(game.DrawUpperTribeCardByIndex(current, -1));
assertFalse(game.DrawUpperTribeCardByIndex(current, 999));
assertFalse(game.drawUpperTribeCardByIndex(current, -1));
assertFalse(game.drawUpperTribeCardByIndex(current, 999));
assertFalse(game.DrawUpperBuildingCardByIndex(current, -1));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 999));
assertFalse(game.drawUpperBuildingCardByIndex(current, -1));
assertFalse(game.drawUpperBuildingCardByIndex(current, 999));
assertFalse(game.DrawLowerBuildingCardByIndex(current, -1));
assertFalse(game.DrawLowerBuildingCardByIndex(current, 999));
assertFalse(game.drawLowerBuildingCardByIndex(current, -1));
assertFalse(game.drawLowerBuildingCardByIndex(current, 999));
int lowerIndex = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
if (lowerIndex != -1) {
assertFalse(game.DrawLowerTribeCardByIndex(wrongPlayer, lowerIndex));
assertFalse(game.drawLowerTribeCardByIndex(wrongPlayer, lowerIndex));
}
int upperIndex = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
if (upperIndex != -1) {
assertFalse(game.DrawUpperTribeCardByIndex(wrongPlayer, upperIndex));
assertFalse(game.drawUpperTribeCardByIndex(wrongPlayer, upperIndex));
}
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();
assertNotNull(current);
assertFalse(game.DrawUpperTribeCardByIndex(current, 0));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0));
assertFalse(game.drawUpperTribeCardByIndex(current, 0));
assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
assertFalse(game.skipTurn(current));
}
@@ -806,15 +806,15 @@ class GameTest {
Player wrongPlayer = current.equals(players.get(0)) ? players.get(1) : players.get(0);
assertFalse(game.DrawUpperTribeCardByIndex(wrongPlayer, 0));
assertFalse(game.DrawUpperBuildingCardByIndex(wrongPlayer, 0));
assertFalse(game.drawUpperTribeCardByIndex(wrongPlayer, 0));
assertFalse(game.drawUpperBuildingCardByIndex(wrongPlayer, 0));
assertFalse(game.skipTurn(wrongPlayer));
assertFalse(game.DrawUpperTribeCardByIndex(current, -1));
assertFalse(game.DrawUpperTribeCardByIndex(current, 999));
assertFalse(game.drawUpperTribeCardByIndex(current, -1));
assertFalse(game.drawUpperTribeCardByIndex(current, 999));
assertFalse(game.DrawUpperBuildingCardByIndex(current, -1));
assertFalse(game.DrawUpperBuildingCardByIndex(current, 999));
assertFalse(game.drawUpperBuildingCardByIndex(current, -1));
assertFalse(game.drawUpperBuildingCardByIndex(current, 999));
}
@@ -857,7 +857,7 @@ class GameTest {
Player current = game.getCurrentState().getCurrentPlayer();
assertNotNull(current);
assertTrue(game.SlotChoiceByIndex(current, 0));
assertTrue(game.slotChoiceByIndex(current, 0));
}
@Test
@@ -1009,7 +1009,7 @@ class GameTest {
"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
@@ -1044,7 +1044,7 @@ class GameTest {
int foodBefore = current.getFoodValue();
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."
);
@@ -1116,7 +1116,7 @@ class GameTest {
int buildingsBefore = current.getBuildingCards().size();
int upperBuildingsBefore = game.getUpperListBuilding().size();
assertFalse(game.DrawUpperBuildingCardByIndex(current, 0));
assertFalse(game.drawUpperBuildingCardByIndex(current, 0));
assertEquals(buildingsBefore, current.getBuildingCards().size());
assertEquals(upperBuildingsBefore, game.getUpperListBuilding().size());
@@ -1146,13 +1146,13 @@ class GameTest {
addPlayers(game, 3, "slot_order_");
Player firstChooser = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(firstChooser, 2));
assertTrue(game.slotChoiceByIndex(firstChooser, 2));
Player secondChooser = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(secondChooser, 0));
assertTrue(game.slotChoiceByIndex(secondChooser, 0));
Player thirdChooser = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(thirdChooser, 1));
assertTrue(game.slotChoiceByIndex(thirdChooser, 1));
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
@@ -1282,7 +1282,7 @@ class GameTest {
int charactersBefore = current.getTotCharacters();
int upperSizeBefore = game.getUpperListTribeCards().size();
assertFalse(game.DrawUpperTribeCardByIndex(current, eventIndex));
assertFalse(game.drawUpperTribeCardByIndex(current, eventIndex));
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
assertEquals(current, game.getCurrentState().getCurrentPlayer());
@@ -1384,7 +1384,7 @@ class GameTest {
assertTrue(game.disconnectedPlayer(current));
assertFalse(game.disconnectedPlayers.isEmpty());
game.ClearDisconnected();
game.clearDisconnected();
assertTrue(game.disconnectedPlayers.isEmpty());
}
@@ -1427,7 +1427,7 @@ class GameTest {
int buildingsBefore = current.getBuildingCards().size();
int lowerBuildingsBefore = game.getLowerListBuilding().size();
assertFalse(game.DrawLowerBuildingCardByIndex(current, 0));
assertFalse(game.drawLowerBuildingCardByIndex(current, 0));
assertEquals(buildingsBefore, current.getBuildingCards().size());
assertEquals(lowerBuildingsBefore, game.getLowerListBuilding().size());
@@ -1478,7 +1478,7 @@ class GameTest {
wrongPlayer.addFood(game.getLowerListBuilding().get(0).getPrice());
assertFalse(game.DrawLowerBuildingCardByIndex(wrongPlayer, 0));
assertFalse(game.drawLowerBuildingCardByIndex(wrongPlayer, 0));
return;
}
@@ -1534,12 +1534,12 @@ class GameTest {
int foodBefore = current.getFoodValue();
assertTrue(game.SlotChoiceByIndex(current, 0));
assertTrue(game.slotChoiceByIndex(current, 0));
for (int i = 1; i < game.getNPlayers(); i++) {
Player temp = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(temp, i));
assertTrue(game.slotChoiceByIndex(temp, i));
assertTrue(
game.getSlotMap().values().stream()
@@ -1552,12 +1552,12 @@ class GameTest {
resolveAllMandatoryActions(game);
foodBefore = current.getFoodValue();
assertTrue(game.SlotChoiceByIndex(current, 0));
assertTrue(game.slotChoiceByIndex(current, 0));
for (int i = 1; i < game.getNPlayers(); i++) {
Player temp = game.getCurrentState().getCurrentPlayer();
assertTrue(game.SlotChoiceByIndex(temp, i));
assertTrue(game.slotChoiceByIndex(temp, i));
assertTrue(
game.getSlotMap().values().stream()
@@ -1580,7 +1580,7 @@ class GameTest {
int foodBefore = current.getFoodValue();
assertTrue(game.SlotChoiceByIndex(current, 1));
assertTrue(game.slotChoiceByIndex(current, 1));
assertEquals(foodBefore, current.getFoodValue());
}