From 08a66525df17b8871b17bde29d03e3dee81f1f50 Mon Sep 17 00:00:00 2001 From: Samuel Mathew Vennalil Date: Wed, 1 May 2024 17:47:08 -0500 Subject: [PATCH] Fixed leaderboard --- src/main/java/uta/cse3310/App.java | 10 +++++++--- src/main/java/uta/cse3310/Game.java | 9 --------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java index 6c436cc..febc131 100644 --- a/src/main/java/uta/cse3310/App.java +++ b/src/main/java/uta/cse3310/App.java @@ -208,10 +208,14 @@ else if (U.ready == -1) U.color = color.pickColor(); //Add the person to the leaderboard - leaderboard.add(U.Handle,0); - + if (!leaderboard.LB.containsKey(U.Handle)) + { + leaderboard.add(U.Handle,0); + Players.put(U.Handle,U); + } //Add it to all players list - Players.put(U.Handle,U); + + conn.setAttachment(U.Handle); if (Players.get(U.Handle).GameType == 2) diff --git a/src/main/java/uta/cse3310/Game.java b/src/main/java/uta/cse3310/Game.java index 309301a..1b4e89a 100644 --- a/src/main/java/uta/cse3310/Game.java +++ b/src/main/java/uta/cse3310/Game.java @@ -49,15 +49,6 @@ char[][] createGrid() } - /*Random rand = new Random(); - - for (int i = 0; i < 20; i++) - { - for (int j = 0; j < 20; j++) - { - grid[i][j] = (char) (rand.nextInt(26) + 'A'); - } - }*/ return grid; }