Fix: Game Class and Test
This commit is contained in:
@@ -60,7 +60,9 @@ public class Game {
|
|||||||
public int getNPlayers() {
|
public int getNPlayers() {
|
||||||
return nPlayers;
|
return nPlayers;
|
||||||
}
|
}
|
||||||
public Game(int nPlayers) {
|
public Game(int nPlayers) throws IllegalArgumentException{
|
||||||
|
if(nPlayers < 0||nPlayers > 5)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
this.nPlayers = nPlayers;
|
this.nPlayers = nPlayers;
|
||||||
board=new Board(nPlayers);
|
board=new Board(nPlayers);
|
||||||
slotMap = new LinkedHashMap<>();
|
slotMap = new LinkedHashMap<>();
|
||||||
@@ -72,8 +74,16 @@ public class Game {
|
|||||||
playersList = new ArrayList<>();
|
playersList = new ArrayList<>();
|
||||||
OptionalCardQueue = new LinkedList<>();
|
OptionalCardQueue = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
public Game()
|
||||||
|
{
|
||||||
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addPlayer(Player player) {
|
public boolean addPlayer(Player player) {
|
||||||
|
if(this.nPlayers==0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(currentState.getGameStage()!= GameStages.WAITING)
|
if(currentState.getGameStage()!= GameStages.WAITING)
|
||||||
return false;
|
return false;
|
||||||
if(playersList.contains(player))
|
if(playersList.contains(player))
|
||||||
@@ -415,7 +425,13 @@ public class Game {
|
|||||||
currentState.GameStageUpdate(GameStages.ENDED);
|
currentState.GameStageUpdate(GameStages.ENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean setNPlayer(int nPlayers)
|
||||||
|
{
|
||||||
|
if(this.nPlayers!=0)
|
||||||
|
return false;
|
||||||
|
this.nPlayers=nPlayers;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package it.polimi.ingsw.gc14.Network;
|
||||||
|
|
||||||
|
public enum EventType {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user