Skip to content

Commit

Permalink
Update Lobby.java
Browse files Browse the repository at this point in the history
  • Loading branch information
odo3990 authored May 1, 2024
1 parent dfcfb70 commit b9676c7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/wordsearch/Lobby.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,32 @@ public boolean checkGameModeFull() {
}
return false;
}

public void createGame() {
System.out.println("GAME BOUT TO START");
Player player_1 = this.gameModeQueue.get(0);
Player player_2 = this.gameModeQueue.get(1);
Game game = new Game(UUIDGenerator.generateUUID(), this.getLobbyUUID());
this.addGame(game);
game.addPlayer(player_1);
game.addPlayer(player_2);

// REMOVE PLAYERS FROM GAMEMODE SO NEW CAN BE CREATED
this.gameModeQueue.remove(player_1);
this.gameModeQueue.remove(player_2);

// setting colors
List<Player> gamePlayerList = game.getPlayerList();
PlayerColors.Color[] allColors = PlayerColors.getAllColors();
List<PlayerColors.Color> colorList = Arrays.asList(allColors);
Collections.shuffle(colorList);
PlayerColors.Color[] shuffledColors = colorList.toArray(new PlayerColors.Color[0]);

for (int i = 0; i < gamePlayerList.size(); i++) {
Player player = gamePlayerList.get(i);
PlayerColors.Color color = shuffledColors[i];
player.setPlayerColor(color);
// System.out.println(player.getNick() + "=" + color);
}
}
}

0 comments on commit b9676c7

Please sign in to comment.