if(characterNames.size() == this.numPlayers){
// All of the players have selected their characters.
// Tell everyone to draw their board and determine who goes first.
server.sendAll(new DrawPawnsMessage(characterNames));
Player firstPlayer = null;
for(Player player : game.getPlayers()){
if(player.getCharacter()== CharacterName.MISS_SCARLET){
// Miss scarlet always goes first according to Clue rules.
firstPlayer = player;
}
}
if(firstPlayer == null){
// Miss Scarlet is not in play so just choose someone to go first.
firstPlayer = game.getPlayers().get(0);
}
currentPlayer = firstPlayer;
this.fireTextStatusEvent(new TextStatusEvent(this, "Player "+ firstPlayer.getCharacter().toString() + " will go first. "));
// Game on - start first turn.
HallwayName hallwy = BoardView.getDefaultHall(currentPlayer.getCharacter());
Hallway currHallwy = null;
for(Location space : game.getSpaces()){
if(space.getLocationType() == LocationType.HALLWAY_TYPE){
if(((Hallway)space).getHallwayName() == hallwy){
currHallwy = (Hallway)space;
}
}
}
server.send(currentPlayer, new AvailableMoveMessage(game.getValidMoves(currHallwy), currentPlayer.getCharacter()));
}
}
}else if(event.getMessage() instanceof EndTurnMessage){
if(isServer){
//Move to the next player when we receive this message
this.getNextPlayer();
//TODO: Send available move message? This still needs to be tested
for(Location location : game.getSpaces()){
Player player = location.getPlayer();
if(player != null){
if(player.getUUID().equals(currentPlayer.getUUID())){
server.send(currentPlayer, new AvailableMoveMessage(game.getValidMoves(location), currentPlayer.getCharacter()));
fireTextStatusEvent(new TextStatusEvent(this, "It is now " + currentPlayer.getCharacter() + "'s turn."));
}
}
}