From 4f9e9a0e9a86e09bdffc3b46d96c4a2e7a546f22 Mon Sep 17 00:00:00 2001 From: Julian Kropff Date: Sat, 25 Apr 2026 16:26:54 +0200 Subject: [PATCH] Fix: Checkstyle --- .../ui/gameui/CasinoGameController.java | 118 +++++---- .../CasinoBrowserController.java | 236 ++++++++++-------- .../PlayerStatusController.java | 10 +- .../gameuicomponents/TaskbarController.java | 30 +-- .../get_game_state/GetGameStateHandler.java | 11 +- 5 files changed, 226 insertions(+), 179 deletions(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameController.java index 6307aff..696732c 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameController.java @@ -513,20 +513,7 @@ public class CasinoGameController { return; } - List community = (s.communityCards != null) ? s.communityCards : List.of(); - List myCards = getMyCards(players); - - java.util.List newCommunityKeys = cardKeys(community, TOTAL_SLOTS); - if (!newCommunityKeys.equals(lastCommunityKeys)) { - lastCommunityKeys = newCommunityKeys; - renderCommunityCards(community); - } - - java.util.List newMyCardKeys = cardKeys(myCards, PLAYER_SLOTS); - if (!newMyCardKeys.equals(lastMyCardKeys)) { - lastMyCardKeys = newMyCardKeys; - renderPlayerCards(myCards); - } + updateCards(s, players); if (s.pot != lastPot) { lastPot = s.pot; @@ -556,6 +543,32 @@ public class CasinoGameController { } } + /** + * Update the displayed community cards and the player's hole cards based on the current game + * state. + * + * @param s The current game state containing the community cards and the list of players, used + * to determine. + * @param players The list of players currently in the game, used to retrieve the player's hole + * cards for display. If null, it will be treated as an empty list. + */ + private void updateCards(GameState s, List players) { + List community = (s.communityCards != null) ? s.communityCards : List.of(); + List myCards = getMyCards(players); + + var newCommunityKeys = cardKeys(community, TOTAL_SLOTS); + if (!newCommunityKeys.equals(lastCommunityKeys)) { + lastCommunityKeys = newCommunityKeys; + renderCommunityCards(community); + } + + var newMyCardKeys = cardKeys(myCards, PLAYER_SLOTS); + if (!newMyCardKeys.equals(lastMyCardKeys)) { + lastMyCardKeys = newMyCardKeys; + renderPlayerCards(myCards); + } + } + /** * Synchronize the whisper chat targets with the current list of players. * @@ -733,7 +746,7 @@ public class CasinoGameController { } PlayerId pid = p.getId(); - boolean isMe = myPlayerId != null && myPlayerId.equals(pid); + boolean isMe = myPlayerId != null && myPlayerId.equals(pid); if (isMe) { meFound = true; @@ -809,9 +822,7 @@ public class CasinoGameController { setTaskbarTurnHighlight(false); } - /** - * Clear all visual highlights in the UI that indicate the active player's turn. - */ + /** Clear all visual highlights in the UI that indicate the active player's turn. */ private void clearActiveTurnHighlights() { if (player1Controller != null) { player1Controller.setTurnHighlighted(false); @@ -833,11 +844,11 @@ public class CasinoGameController { } /** - * Set the visual highlight state of the player's hole cards to indicate whether it is - * currently the player's turn in the game. + * Set the visual highlight state of the player's hole cards to indicate whether it is currently + * the player's turn in the game. * - * @param highlighted true to highlight the player's hole cards, indicating that it is their turn, - * or false to remove the highlight when it is not their turn. + * @param highlighted true to highlight the player's hole cards, indicating that it is their + * turn, or false to remove the highlight when it is not their turn. */ private void setPlayerCardsTurnHighlighted(boolean highlighted) { if (playerCardsBox == null) { @@ -852,12 +863,13 @@ public class CasinoGameController { } /** - * Update the visual highlights in the UI to indicate which player's turn it is based on the active. + * Update the visual highlights in the UI to indicate which player's turn it is based on the + * active. * - * @param players The list of players currently in the game, used to identify the active - * player and update the turn highlights accordingly. - * @param activePlayerIndex The index of the active player in the players list, which is used to determine - * whose turn it is and update the UI highlights to reflect that. + * @param players The list of players currently in the game, used to identify the active player + * and update the turn highlights accordingly. + * @param activePlayerIndex The index of the active player in the players list, which is used to + * determine whose turn it is and update the UI highlights to reflect that. */ private void updateActiveTurnHighlights(List players, int activePlayerIndex) { clearActiveTurnHighlights(); @@ -892,8 +904,8 @@ public class CasinoGameController { } /** - * Set the turn highlight state in the taskbar controller, which visually indicates whether - * it is the current player's turn in the game. + * Set the turn highlight state in the taskbar controller, which visually indicates whether it + * is the current player's turn in the game. * * @param highlighted true to highlight the turn in the taskbar, false to remove the highlight. */ @@ -910,7 +922,7 @@ public class CasinoGameController { * @param players The list of players from which to retrieve the player at the specified index. * @param index The index of the player to retrieve from the list. * @return The Player object at the specified index if it exists and is valid, or null if the - * index is out of bounds or if the players list is null or empty. + * index is out of bounds or if the players list is null or empty. */ private Player getPlayerAtIndex(List players, int index) { if (players == null || index < 0 || index >= players.size()) { @@ -923,10 +935,10 @@ public class CasinoGameController { /** * Resolve the winner of the hand based on the game state. * - * @param s The current game state, which may contain information about the players, - * their states, and the winner index. - * @return The Player object representing the winner if it can be determined from the - * game state, or null if the winner cannot be resolved or if the game is still in progress. + * @param s The current game state, which may contain information about the players, their + * states, and the winner index. + * @return The Player object representing the winner if it can be determined from the game + * state, or null if the winner cannot be resolved or if the game is still in progress. */ private Player resolveWinner(GameState s) { if (s == null || s.players == null || s.players.isEmpty()) { @@ -963,10 +975,10 @@ public class CasinoGameController { /** * Resolve the name of the winner based on the game state. * - * @param s The current game state, which may contain information about the players, - * their states, and the winner index. - * @return The name of the winner if it can be determined from the game state, - * or null if the winner cannot be resolved or if the game is still in progress. + * @param s The current game state, which may contain information about the players, their + * states, and the winner index. + * @return The name of the winner if it can be determined from the game state, or null if the + * winner cannot be resolved or if the game is still in progress. */ private String resolveWinnerName(GameState s) { Player winner = resolveWinner(s); @@ -987,14 +999,15 @@ public class CasinoGameController { } /** - * Determine if the game is in a finished state based on the game state and the presence of a winner name. + * Determine if the game is in a finished state based on the game state and the presence of a + * winner name. * - * @param s The current game state, which may be null or contain information about the phase, players, - * and winner index. - * @param winnerName The name of the winner, which may be null or blank if the winner is not yet determined - * or if the game is still in progress. - * @return true if the game is considered finished based on the provided state and winner information, - * false otherwise. + * @param s The current game state, which may be null or contain information about the phase, + * players, and winner index. + * @param winnerName The name of the winner, which may be null or blank if the winner is not yet + * determined or if the game is still in progress. + * @return true if the game is considered finished based on the provided state and winner + * information, false otherwise. */ private boolean isGameFinishedState(GameState s, String winnerName) { if (s == null) { @@ -1042,19 +1055,18 @@ public class CasinoGameController { } /** - * Determine if the current phase of the game is a terminal phase, such as "FINISHED" or "SHOWDOWN". + * Determine if the current phase of the game is a terminal phase, such as "FINISHED" or + * "SHOWDOWN". * * @param phase The current phase of the game, which may be null or blank. - * @return true if the phase is considered terminal, indicating that the hand has ended - * and a winner can be declared, false otherwise. + * @return true if the phase is considered terminal, indicating that the hand has ended and a + * winner can be declared, false otherwise. */ private boolean isTerminalPhase(String phase) { return "FINISHED".equalsIgnoreCase(phase) || "SHOWDOWN".equalsIgnoreCase(phase); } - /** - * Finish the game UI loop by stopping the timeline that updates the UI. - */ + /** Finish the game UI loop by stopping the timeline that updates the UI. */ private void finishGameUiLoop() { if (gameFinished) { return; @@ -1070,8 +1082,8 @@ public class CasinoGameController { * * @param node The JavaFX Node on which to toggle the style class. * @param styleClass The name of the CSS style class to toggle. - * @param active A boolean indicating whether to add (true) - * or remove (false) the style class from the node. + * @param active A boolean indicating whether to add (true) or remove (false) the style class + * from the node. */ private void toggleStyleClass(Node node, String styleClass, boolean active) { if (node == null || styleClass == null || styleClass.isBlank()) { diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/CasinoBrowserController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/CasinoBrowserController.java index cb04fa2..b6f7fb2 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/CasinoBrowserController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/CasinoBrowserController.java @@ -11,13 +11,17 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.ButtonType; +import javafx.scene.control.ContextMenu; import javafx.scene.control.Label; +import javafx.scene.control.MenuItem; import javafx.scene.control.TextField; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -32,10 +36,6 @@ import javafx.scene.web.WebView; import javafx.stage.Stage; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.MenuItem; /** * Experimental embedded browser for Casono. @@ -86,6 +86,7 @@ public class CasinoBrowserController { private static final int ALERT_HEIGHT = 300; private static final String LOGO_PATH = "/images/logoinverted.png"; private static final String LOGO_PATH_MAIN = "/images/logo.png"; + private static final int MAX_AUTOCOMPLETE_RESULTS = 5; static { CookieHandler.setDefault(COOKIE_MANAGER); @@ -112,43 +113,44 @@ public class CasinoBrowserController { TRUSTED_DOMAINS.add("startpage.com"); } - /** - * Aliases for common websites. - */ - private static final java.util.Map ALIASES = Map.ofEntries( - Map.entry("wiki", "wikipedia.org"), - Map.entry("yt", "youtube.com"), - Map.entry("bra", "search.brave.com"), - Map.entry("bs", "search.brave.com"), - Map.entry("gh", "github.com"), - Map.entry("google", "google.com"), - Map.entry("duck", "duckduckgo.com"), - Map.entry("bing", "bing.com"), - Map.entry("meta", "metager.de"), - Map.entry("mojeek", "mojeek.com"), - Map.entry("searx", "searx.be"), - Map.entry("startpage", "startpage.com"), - Map.entry("stack", "stackoverflow.com"), - Map.entry("so", "stackoverflow.com"), - Map.entry("oracle", "oracle.com"), - Map.entry("docs", "docs.oracle.com"), - Map.entry("mdn", "developer.mozilla.org"), - Map.entry("maven", "maven.apache.org"), - Map.entry("gradle", "gradle.org"), - Map.entry("spring", "spring.io"), - Map.entry("jetbrains", "jetbrains.com"), - Map.entry("uni", "unibas.ch") - ); + /** Aliases for common websites. */ + private static final java.util.Map ALIASES = + Map.ofEntries( + Map.entry("wiki", "wikipedia.org"), + Map.entry("yt", "youtube.com"), + Map.entry("bra", "search.brave.com"), + Map.entry("bs", "search.brave.com"), + Map.entry("gh", "github.com"), + Map.entry("google", "google.com"), + Map.entry("duck", "duckduckgo.com"), + Map.entry("bing", "bing.com"), + Map.entry("meta", "metager.de"), + Map.entry("mojeek", "mojeek.com"), + Map.entry("searx", "searx.be"), + Map.entry("startpage", "startpage.com"), + Map.entry("stack", "stackoverflow.com"), + Map.entry("so", "stackoverflow.com"), + Map.entry("oracle", "oracle.com"), + Map.entry("docs", "docs.oracle.com"), + Map.entry("mdn", "developer.mozilla.org"), + Map.entry("maven", "maven.apache.org"), + Map.entry("gradle", "gradle.org"), + Map.entry("spring", "spring.io"), + Map.entry("jetbrains", "jetbrains.com"), + Map.entry("uni", "unibas.ch")); /** * Resolves user input into a valid URL. * - * @param input User input from the URL field, which can be a full URL, a domain name, or an alias. - * @return A properly formatted URL string that can be loaded by the browser, or the original input - * if it cannot be resolved. + * @param input User input from the URL field, which can be a full URL, a domain name, or an + * alias. + * @return A properly formatted URL string that can be loaded by the browser, or the original + * input if it cannot be resolved. */ private static String resolveInputToUrl(String input) { - if (input == null || input.isBlank()) return input; + if (input == null || input.isBlank()) { + return input; + } input = input.trim(); @@ -271,7 +273,7 @@ public class CasinoBrowserController { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Popup blocked"); alert.setHeaderText(null); - alert.setContentText("The Casono browser has detected a threat and successfully blocked it."); + alert.setContentText("Casono Browser blocked a security threat."); try { var stream = CasinoBrowserController.class.getResourceAsStream(LOGO_PATH); @@ -349,67 +351,90 @@ public class CasinoBrowserController { urlField.getStyleClass().add("gray-input-field"); HBox.setHgrow(urlField, Priority.ALWAYS); - urlField.textProperty().addListener((obs, oldText, newText) -> { - if (newText == null || newText.isBlank()) { - autoCompleteMenu.hide(); - return; - } + urlField.textProperty() + .addListener( + (obs, oldText, newText) -> { + if (newText == null || newText.isBlank()) { + autoCompleteMenu.hide(); + return; + } - String input = newText.toLowerCase(); + String input = newText.toLowerCase(); - String aliasMatch = ALIASES.get(input); - if (aliasMatch != null) { - autoCompleteMenu.getItems().clear(); + String aliasMatch = ALIASES.get(input); + if (aliasMatch != null) { + autoCompleteMenu.getItems().clear(); - MenuItem item = new MenuItem(aliasMatch); - item.setOnAction(e -> { - urlField.setText("https://" + aliasMatch); - autoCompleteMenu.hide(); - }); + MenuItem item = new MenuItem(aliasMatch); + item.setOnAction( + e -> { + urlField.setText("https://" + aliasMatch); + autoCompleteMenu.hide(); + }); - autoCompleteMenu.getItems().add(item); - autoCompleteMenu.show(urlField, javafx.geometry.Side.BOTTOM, 0, 0); - return; - } + autoCompleteMenu.getItems().add(item); + autoCompleteMenu.show(urlField, javafx.geometry.Side.BOTTOM, 0, 0); + return; + } - autoCompleteMenu.getItems().clear(); - - URL_SUGGESTIONS.stream() - .filter(domain -> domain.toLowerCase().startsWith(input) - || domain.toLowerCase().contains(input)) - .sorted((a, b) -> { - boolean aStarts = a.startsWith(input); - boolean bStarts = b.startsWith(input); - return Boolean.compare(!aStarts, !bStarts); - }) - .limit(5) - .forEach(domain -> { - MenuItem item = new MenuItem(domain); - - item.setOnAction(e -> { - urlField.setText("https://" + domain); - autoCompleteMenu.hide(); + updateSuggestions(input, urlField); }); - autoCompleteMenu.getItems().add(item); - }); - - if (!autoCompleteMenu.getItems().isEmpty()) { - autoCompleteMenu.show(urlField, - javafx.geometry.Side.BOTTOM, - 0, 0); - } else { - autoCompleteMenu.hide(); - } - }); - - urlField.focusedProperty().addListener((obs, oldVal, newVal) -> { - if (!newVal) autoCompleteMenu.hide(); - }); + urlField.focusedProperty() + .addListener( + (obs, oldVal, newVal) -> { + if (!newVal) { + autoCompleteMenu.hide(); + } + }); return urlField; } + /** + * Updates the autocomplete suggestions based on the current input in the URL field. Suggestions + * are filtered from the list of trusted domains and sorted to prioritize those that start with + * the input. + * + * @param input The current text input from the URL field, used to filter and sort suggestions. + * @param urlField The TextField for the URL input, used to position the autocomplete menu and + * update its content. + */ + private static void updateSuggestions(String input, TextField urlField) { + autoCompleteMenu.getItems().clear(); + + URL_SUGGESTIONS.stream() + .filter( + domain -> + domain.toLowerCase().startsWith(input) + || domain.toLowerCase().contains(input)) + .sorted( + (a, b) -> { + boolean aStarts = a.startsWith(input); + boolean bStarts = b.startsWith(input); + return Boolean.compare(!aStarts, !bStarts); + }) + .limit(MAX_AUTOCOMPLETE_RESULTS) + .forEach( + domain -> { + MenuItem item = new MenuItem(domain); + + item.setOnAction( + e -> { + urlField.setText("https://" + domain); + autoCompleteMenu.hide(); + }); + + autoCompleteMenu.getItems().add(item); + }); + + if (!autoCompleteMenu.getItems().isEmpty()) { + autoCompleteMenu.show(urlField, javafx.geometry.Side.BOTTOM, 0, 0); + } else { + autoCompleteMenu.hide(); + } + } + /** * Security Label * @@ -534,15 +559,16 @@ public class CasinoBrowserController { */ public static void configureUrlEvents( WebEngine engine, TextField urlField, Label securityLabel) { - urlField.setOnKeyPressed(e -> { - if (e.getCode() == KeyCode.ENTER) { - if (!autoCompleteMenu.isShowing()) { - String resolved = resolveInputToUrl(urlField.getText()); - urlField.setText(resolved); - loadUrlSafely(engine, resolved, securityLabel); - } - } - }); + urlField.setOnKeyPressed( + e -> { + if (e.getCode() == KeyCode.ENTER) { + if (!autoCompleteMenu.isShowing()) { + String resolved = resolveInputToUrl(urlField.getText()); + urlField.setText(resolved); + loadUrlSafely(engine, resolved, securityLabel); + } + } + }); engine.locationProperty().addListener((obs, o, n) -> urlField.setText(n)); } @@ -608,13 +634,14 @@ public class CasinoBrowserController { String scheme = uri.getScheme(); if ("file".equalsIgnoreCase(scheme)) { - Path allowed = Paths.get( - System.getProperty("user.dir"), - "documents", - "docs", - "game-engine", - "manual.html" - ).normalize(); + Path allowed = + Paths.get( + System.getProperty("user.dir"), + "documents", + "docs", + "game-engine", + "manual.html") + .normalize(); Path requested = Paths.get(uri).normalize(); @@ -638,8 +665,9 @@ public class CasinoBrowserController { return; } - boolean trusted = TRUSTED_DOMAINS.stream() - .anyMatch(domain -> host.equals(domain) || host.endsWith("." + domain)); + boolean trusted = + TRUSTED_DOMAINS.stream() + .anyMatch(domain -> host.equals(domain) || host.endsWith("." + domain)); if (!trusted) { if (!showUnknownWebsiteAlert(host)) { diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/PlayerStatusController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/PlayerStatusController.java index 19cd340..13d2ce4 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/PlayerStatusController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/PlayerStatusController.java @@ -8,9 +8,9 @@ import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; -import javafx.scene.layout.HBox; /** * Controller for displaying a player's status in the poker game, including their name, chip count @@ -115,7 +115,10 @@ public class PlayerStatusController { * @return true if both represent the same player. */ public boolean hasPlayer(Player candidate) { - if (player == null || candidate == null || player.getId() == null || candidate.getId() == null) { + if (player == null + || candidate == null + || player.getId() == null + || candidate.getId() == null) { return false; } @@ -147,7 +150,8 @@ public class PlayerStatusController { } /** - * Update the visual style of the player status box to indicate whether it's currently this player's turn. + * Update the visual style of the player status box to indicate whether it's currently this + * player's turn. */ private void updateTurnHighlightStyle() { if (statusInnerBoxTop == null || statusInnerBoxBottom == null) { diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java index f868775..967879a 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java @@ -8,6 +8,8 @@ import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerId; import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerState; import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient; import ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui.Casinomainui; +import java.nio.file.Path; +import java.nio.file.Paths; import javafx.fxml.FXML; import javafx.scene.control.Alert; import javafx.scene.control.Button; @@ -20,9 +22,6 @@ import javafx.scene.layout.HBox; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.nio.file.Path; -import java.nio.file.Paths; - /** * Controller for the interactive taskbar within the poker UI. * @@ -930,7 +929,8 @@ public class TaskbarController { /** * Calculates the scaled width of the taskbar node based on its current bounds and scale factor. * - * @return The scaled width of the taskbar node, ensuring it is non-negative and accounts for the current scale applied to the node. + * @return The scaled width of the taskbar node, ensuring it is non-negative and accounts for + * the current scale applied to the node. */ private double scaledNodeWidth() { double width = taskbar.getBoundsInLocal().getWidth(); @@ -941,9 +941,11 @@ public class TaskbarController { } /** - * Calculates the scaled height of the taskbar node based on its current bounds and scale factor. + * Calculates the scaled height of the taskbar node based on its current bounds and scale + * factor. * - * @return The scaled height of the taskbar node, ensuring it is non-negative and accounts for the current scale applied to the node. + * @return The scaled height of the taskbar node, ensuring it is non-negative and accounts for + * the current scale applied to the node. */ private double scaledNodeHeight() { double height = taskbar.getBoundsInLocal().getHeight(); @@ -1141,18 +1143,18 @@ public class TaskbarController { /** * Opens the integrated Casono web browser. * - * once the content for strategies and support is available. + *

once the content for strategies and support is available. */ @FXML private void onBrowserButtonClick() { try { - Path path = Paths.get( - System.getProperty("user.dir"), - "documents", - "docs", - "game-engine", - "manual.html" // Tippfehler korrigiert! - ); + Path path = + Paths.get( + System.getProperty("user.dir"), + "documents", + "docs", + "game-engine", + "manual.html"); CasinoBrowserController.open(path.toUri().toString()); diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/game/get_game_state/GetGameStateHandler.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/game/get_game_state/GetGameStateHandler.java index 517f835..c0d00b9 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/game/get_game_state/GetGameStateHandler.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/game/get_game_state/GetGameStateHandler.java @@ -12,8 +12,8 @@ import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.response.ErrorRes import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.response.dispatcher.ResponseDispatcher; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; import java.util.logging.Level; +import java.util.logging.Logger; /** Handler for GET_GAME_STATE: returns pot, phase, community cards and per-player info. */ public class GetGameStateHandler extends CommandHandler { @@ -83,8 +83,7 @@ public class GetGameStateHandler extends CommandHandler { responseDispatcher.dispatch(new GetGameStateResponse(request.getContext(), game, username)); if (game.getState().getPhase() == GamePhase.FINISHED) { - CompletableFuture.delayedExecutor( - FINISHED_CLEANUP_DELAY_SECONDS, TimeUnit.SECONDS) + CompletableFuture.delayedExecutor(FINISHED_CLEANUP_DELAY_SECONDS, TimeUnit.SECONDS) .execute(() -> cleanupLobby(lobby, lobbyId)); } } @@ -104,8 +103,10 @@ public class GetGameStateHandler extends CommandHandler { } lobby.initGame(null); } catch (RuntimeException e) { - LOGGER.log(Level.WARNING, - "Failed to cleanup lobby " + lobbyId + " during FINISHED state", e); + LOGGER.log( + Level.WARNING, + "Failed to cleanup lobby " + lobbyId + " during FINISHED state", + e); } }