Skip to content

Commit

Permalink
Update App.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Antenehden authored Aug 6, 2024
1 parent 6bd72c6 commit 67da7e8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/uta/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Vector;
import org.java_websocket.WebSocket;
import org.java_websocket.drafts.Draft;
Expand Down Expand Up @@ -59,18 +60,27 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {
List<Player> players = new ArrayList<>();
players.add(new Player("Player" + connectionId, PlayerType.HUMAN)); // Initialize at least one player
try {
game = new Game(players, "src/main/resources/words.txt", "src/main/resources/stakes.txt", new Statistics());
game = new Game(players, "src/main/resources/words.txt", "src/main/resources/stakes.txt", new Statistics(), new Scanner(System.in));
} catch (IOException e) {
e.printStackTrace();
return;
}
game.setGameId(gameId++);
activeGames.add(game);

System.out.println("Creating a new Game");
} else {
game.addPlayer(new Player("Player" + connectionId, PlayerType.HUMAN));
System.out.println("Joining an existing game");
if (game.getPlayers().size() == 2) {
game.isGameActive = true;
game.startGame();
}
}




conn.setAttachment(game); // Attach the game to the connection
Gson gson = new Gson();
String jsonString = gson.toJson(event);
Expand Down

0 comments on commit 67da7e8

Please sign in to comment.