Fix: Game UI to support server commands #277

Merged
j.kropff merged 3 commits from feat/game-ui-communication into main 2026-04-12 14:07:37 +02:00
Showing only changes of commit 8f3d0ab8a9 - Show all commits
@@ -39,6 +39,7 @@ public class GameService {
* @return The current GameState object representing the state of the game. * @return The current GameState object representing the state of the game.
*/ */
public int getPot() { public int getPot() {
ensureState();
return state.pot; return state.pot;
} }
@@ -48,6 +49,7 @@ public class GameService {
* @return The current GameState object representing the state of the game. * @return The current GameState object representing the state of the game.
*/ */
public List<Card> getCommunityCards() { public List<Card> getCommunityCards() {
ensureState();
return state.communityCards; return state.communityCards;
} }
@@ -57,6 +59,7 @@ public class GameService {
* @return A list of Player objects representing the players in the current game state. * @return A list of Player objects representing the players in the current game state.
*/ */
public List<Player> getPlayers() { public List<Player> getPlayers() {
ensureState();
return state.players; return state.players;
} }
@@ -98,10 +101,19 @@ public class GameService {
* yet. * yet.
*/ */
public Player getWinner() { public Player getWinner() {
ensureState();
if (state.winnerIndex < 0) { if (state.winnerIndex < 0) {
return null; return null;
} }
return state.players.get(state.winnerIndex); return state.players.get(state.winnerIndex);
} }
/** Ensure that the game state has been initialized before accessing it. */
private void ensureState() {
if (state == null) {
throw new IllegalStateException("Call refresh() first");
}
}
} }