From 6d5c9526e3328528a4f0ecb7aa613786e42709c0 Mon Sep 17 00:00:00 2001
From: ThiML10 <157675695+ThiML10@users.noreply.github.com>
Date: Thu, 2 May 2024 02:53:59 +0000
Subject: [PATCH 1/6] cm
---
html/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html/index.html b/html/index.html
index 26c2037..432918c 100644
--- a/html/index.html
+++ b/html/index.html
@@ -18,7 +18,7 @@
Welcome to The Word Search Game
From 3dd48513407ba491ad7ba4ed8021506a3baddc02 Mon Sep 17 00:00:00 2001
From: antmorales1 <122925857+antmorales1@users.noreply.github.com>
Date: Thu, 2 May 2024 02:55:59 +0000
Subject: [PATCH 2/6] no duplicates
---
src/main/java/uta/cse3310/App.java | 9 ++++++---
src/main/java/uta/cse3310/Game.java | 27 +++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java
index 8e9ea34..fa8aba1 100644
--- a/src/main/java/uta/cse3310/App.java
+++ b/src/main/java/uta/cse3310/App.java
@@ -187,13 +187,16 @@ public void insertInnerMap(UserEvent U,HashMap usedColors;
private ArrayList playersList = new ArrayList();
public Player winner = null;
public boolean gameStatus;
@@ -22,6 +23,7 @@ public Game() {
this.gameMode = gameMode;
this.gameID = UUID.randomUUID().toString();
gameStatus = false;
+ usedColors = new HashSet<>();
}
public ArrayList getPlayersList() // I need to add this since Lobby class needs to access the game's player
@@ -182,6 +184,31 @@ public void displayRules() {
}
+ public boolean addPlayer(Player newPlayer) {
+ if (isUniquePlayerName(newPlayer.getNick())) {
+ if (isUniquePlayerColor(newPlayer.getColor())) {
+ playersList.add(newPlayer);
+ return true;
+ } else {
+ System.out.println("Color is already in use.");
+ }
+ } else {
+ System.out.println("Player name is already in use.");
+ }
+ return false;
+ }
+ private boolean isUniquePlayerName(String playerName) {
+ for (Player player : playersList) {
+ if (player.getNick().equals(playerName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isUniquePlayerColor(String playerColor) {
+ return !usedColors.contains(playerColor);
+ }
}
\ No newline at end of file
From ec714228cbc95c0d8352a25d09b9edc97f83bde1 Mon Sep 17 00:00:00 2001
From: ThiML10 <157675695+ThiML10@users.noreply.github.com>
Date: Thu, 2 May 2024 03:22:36 +0000
Subject: [PATCH 3/6] cm
---
html/index.html | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/html/index.html b/html/index.html
index 432918c..55d37d4 100644
--- a/html/index.html
+++ b/html/index.html
@@ -39,6 +39,14 @@ Timer: 30 seconds
@@ -39,14 +39,6 @@
Timer: 30 seconds