Skip to content

Commit

Permalink
Update GameLogic.java
Browse files Browse the repository at this point in the history
for leaderboard
  • Loading branch information
Guerrero96 committed Apr 30, 2024
1 parent d29fe21 commit 19be925
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/uta/cse3310/GameLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
public class GameLogic {
private List<PlayerType> players;
private Broadcast broadcaster;
List<String> validWords;
private List<String> validWords;
private List<String> allWords;
private Leaderboard leaderboard;


private int gameId;
Expand All @@ -34,6 +35,7 @@ public GameLogic(List<PlayerType> players, Broadcast broadcaster) {
this.wordGrid = new char[35][35];
this.broadcaster = broadcaster;
this.validWords = new ArrayList<>();
this.leaderboard = new Leaderboard();
}

public int getGameId() {
Expand Down Expand Up @@ -362,6 +364,11 @@ public int calculatePoints(String word) {
return 0; // Invalid word length
}
}
public void updatePlayerScore(PlayerType player, String word) {
int points = calculatePoints(word); // Calculate points for the word
player.setScore(player.getScore() + points); // Update player's score
leaderboard.addOrUpdatePlayer(player, player.getScore()); // Update player's score in the leaderboard
}


// Method to check if the highlighted word matches any word in the word list
Expand Down

0 comments on commit 19be925

Please sign in to comment.