Chore/conform ui to checkstyle #184
@@ -1,26 +1,25 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client;
|
package ch.unibas.dmi.dbis.cs108.casono.client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for the Casono client application.
|
* Entry point for the Casono client application. Handles client startup and connection parameters.
|
||||||
* Handles client startup and connection parameters.
|
|
||||||
*/
|
*/
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.Launcher;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.Launcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for the Casono client application.
|
* Entry point for the Casono client application. Handles client startup and connection parameters.
|
||||||
* Handles client startup and connection parameters.
|
*
|
||||||
* <p>
|
* <p>Standardkonstruktor für die Anwendung.
|
||||||
* Standardkonstruktor für die Anwendung.
|
|
||||||
*/
|
*/
|
||||||
public class ClientApp {
|
public class ClientApp {
|
||||||
|
|
||||||
/**
|
/** Standardkonstruktor. */
|
||||||
* Standardkonstruktor.
|
|
||||||
*/
|
|
||||||
public ClientApp() {
|
public ClientApp() {
|
||||||
// Standardkonstruktor
|
// Standardkonstruktor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the client application with the given address.
|
* Starts the client application with the given address.
|
||||||
|
*
|
||||||
* @param arg Address in the format "ip:port".
|
* @param arg Address in the format "ip:port".
|
||||||
* @throws IllegalArgumentException if the address format is invalid.
|
* @throws IllegalArgumentException if the address format is invalid.
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +31,8 @@ public class ClientApp {
|
|||||||
String host = parts[0];
|
String host = parts[0];
|
||||||
int port = Integer.parseInt(parts[1]);
|
int port = Integer.parseInt(parts[1]);
|
||||||
|
|
||||||
System.out.println("You've selected the client. It will connect port " + port + " at host " + host);
|
System.out.println(
|
||||||
|
"You've selected the client. It will connect port " + port + " at host " + host);
|
||||||
Launcher.main(new String[] {});
|
Launcher.main(new String[] {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui.Casinomainui;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launcher for the Casono main UI.
|
* Launcher for the Casono main UI.
|
||||||
* <p>
|
*
|
||||||
* Standardkonstruktor für die Anwendung.
|
* <p>Standardkonstruktor für die Anwendung.
|
||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
|
|
||||||
/**
|
/** Standardkonstruktor. */
|
||||||
* Standardkonstruktor.
|
|
||||||
*/
|
|
||||||
public Launcher() {
|
public Launcher() {
|
||||||
// Standardkonstruktor
|
// Standardkonstruktor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point for launching the UI.
|
* Main entry point for launching the UI.
|
||||||
|
*
|
||||||
* @param args Command line arguments
|
* @param args Command line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Application.launch(ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui.Casinomainui.class, args);
|
Application.launch(Casinomainui.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,41 +1,43 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
||||||
|
|
||||||
/**
|
/** Main UI application for Casono. Loads the main FXML layout and sets up the stage. */
|
||||||
* Main UI application for Casono.
|
import java.io.IOException;
|
||||||
* Loads the main FXML layout and sets up the stage.
|
|
||||||
*/
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JavaFX Application class for the Casono main UI.
|
* JavaFX Application class for the Casono main UI.
|
||||||
* <p>
|
*
|
||||||
* Standardkonstruktor für die Anwendung.
|
* <p>Standardkonstruktor für die Anwendung.
|
||||||
*/
|
*/
|
||||||
public class Casinomainui extends Application {
|
public class Casinomainui extends Application {
|
||||||
|
|
||||||
/**
|
/** Standardkonstruktor. */
|
||||||
* Standardkonstruktor.
|
|
||||||
*/
|
|
||||||
public Casinomainui() {
|
public Casinomainui() {
|
||||||
// Standardkonstruktor
|
// Standardkonstruktor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int SCENE_WIDTH = 1200;
|
||||||
|
private static final int SCENE_HEIGHT = 800;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
* Starts the JavaFX application and loads the main UI.
|
* Starts the JavaFX application and loads the main UI.
|
||||||
|
*
|
||||||
* @param stage The primary stage for this application.
|
* @param stage The primary stage for this application.
|
||||||
* @throws IOException If loading the FXML fails.
|
* @throws IOException If loading the FXML fails.
|
||||||
*/
|
*/
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ui-structure/Casinomainui.fxml"));
|
FXMLLoader fxmlLoader =
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 1200, 800);
|
new FXMLLoader(getClass().getResource("/ui-structure/Casinomainui.fxml"));
|
||||||
|
Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
|
||||||
stage.setTitle("Casono");
|
stage.setTitle("Casono");
|
||||||
|
javafx.scene.image.Image icon =
|
||||||
stage.getIcons().add(new javafx.scene.image.Image(getClass().getResource("/images/logoinverted.png").toExternalForm()));
|
new javafx.scene.image.Image(
|
||||||
|
getClass().getResource("/images/logoinverted.png").toExternalForm());
|
||||||
|
stage.getIcons().add(icon);
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setFullScreen(true);
|
stage.setFullScreen(true);
|
||||||
stage.show();
|
stage.show();
|
||||||
@@ -43,6 +45,7 @@ public class Casinomainui extends Application {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point for launching the application.
|
* Main entry point for launching the application.
|
||||||
|
*
|
||||||
* @param args Command line arguments
|
* @param args Command line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
+20
-32
@@ -2,34 +2,27 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
|||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/** Controller for the Casono main UI lobby. Handles UI initialization and user actions. */
|
||||||
* Controller for the Casono main UI lobby.
|
|
||||||
* Handles UI initialization and user actions.
|
|
||||||
*/
|
|
||||||
public class CasinomainuiController {
|
public class CasinomainuiController {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(CasinomainuiController.class);
|
||||||
|
|
||||||
@FXML
|
@FXML private AnchorPane rootPane;
|
||||||
private AnchorPane rootPane;
|
@FXML private Label titleLabel;
|
||||||
@FXML
|
@FXML private Label subtitleLabel;
|
||||||
private Label titleLabel;
|
@FXML private ImageView logoView;
|
||||||
@FXML
|
@FXML private Rectangle greenBox;
|
||||||
private Label subtitleLabel;
|
@FXML private Button exitbutton;
|
||||||
@FXML
|
@FXML private VBox casinoTable;
|
||||||
private ImageView logoView;
|
|
||||||
@FXML
|
|
||||||
private Rectangle greenBox;
|
|
||||||
@FXML
|
|
||||||
private Button exitbutton;
|
|
||||||
@FXML
|
|
||||||
private VBox casinoTable;
|
|
||||||
|
|
||||||
private LobbyButtonTranslationManager translationManager;
|
private LobbyButtonTranslationManager translationManager;
|
||||||
private LobbyButtonGridManager gridManager;
|
private LobbyButtonGridManager gridManager;
|
||||||
@@ -39,9 +32,7 @@ public class CasinomainuiController {
|
|||||||
// Default constructor
|
// Default constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Initializes the UI components and sets default values. */
|
||||||
* Initializes the UI components and sets default values.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
titleLabel.setText("Casono");
|
titleLabel.setText("Casono");
|
||||||
@@ -49,37 +40,34 @@ public class CasinomainuiController {
|
|||||||
logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm()));
|
logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm()));
|
||||||
|
|
||||||
translationManager = new LobbyButtonTranslationManager();
|
translationManager = new LobbyButtonTranslationManager();
|
||||||
gridManager = new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager);
|
gridManager =
|
||||||
|
new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager);
|
||||||
casinoTable.getChildren().clear();
|
casinoTable.getChildren().clear();
|
||||||
casinoTable.getChildren().add(gridManager.getGridPane());
|
casinoTable.getChildren().add(gridManager.getGridPane());
|
||||||
gridManager.renderLobbyButtons();
|
gridManager.renderLobbyButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Handles the exit button action to close the application. */
|
||||||
* Handles the exit button action to close the application.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleexitbutton() {
|
public void handleexitbutton() {
|
||||||
Platform.exit();
|
Platform.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Handles creation of a new lobby button. */
|
||||||
* Handles creation of a new lobby button.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleCreateLobbyButton() {
|
public void handleCreateLobbyButton() {
|
||||||
if (translationManager.isFull()) {
|
if (translationManager.isFull()) {
|
||||||
System.out.println("Grid voll! Keine weiteren Lobbys moeglich.");
|
LOGGER.warn("Grid voll! Keine weiteren Lobbys moeglich.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int buttonId = nextButtonId++;
|
int buttonId = nextButtonId++;
|
||||||
int lobbyId = gridManager.createLobby();
|
int lobbyId = gridManager.createLobby();
|
||||||
try {
|
try {
|
||||||
translationManager.addLobbyButton(buttonId, lobbyId);
|
translationManager.addLobbyButton(buttonId, lobbyId);
|
||||||
System.out.println("ButtonID: " + buttonId + ", LobbyID: " + lobbyId);
|
LOGGER.info("ButtonID: {}, LobbyID: {}", buttonId, lobbyId);
|
||||||
gridManager.renderLobbyButtons();
|
gridManager.renderLobbyButtons();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Fehler beim Hinzufügen: " + e.getMessage());
|
LOGGER.error("Fehler beim Hinzufügen: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-20
@@ -1,32 +1,41 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the grid for lobby buttons and rendering.
|
* Manages the grid for lobby buttons and rendering. Uses LobbyButtonTranslationManager for mapping
|
||||||
* Uses LobbyButtonTranslationManager for mapping ButtonID to LobbyID.
|
* ButtonID to LobbyID.
|
||||||
*/
|
*/
|
||||||
|
import java.util.Map;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import java.util.Map;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the grid for lobby buttons and rendering.
|
* Manages the grid for lobby buttons and rendering. Uses LobbyButtonTranslationManager for mapping
|
||||||
* Uses LobbyButtonTranslationManager for mapping ButtonID to LobbyID.
|
* ButtonID to LobbyID.
|
||||||
*/
|
*/
|
||||||
public class LobbyButtonGridManager {
|
public class LobbyButtonGridManager {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(LobbyButtonGridManager.class);
|
||||||
|
|
||||||
/** GridPane for the button grid. */
|
/** GridPane for the button grid. */
|
||||||
private final GridPane gridPane;
|
private final GridPane gridPane;
|
||||||
|
|
||||||
/** Manager for mapping ButtonID to LobbyID. */
|
/** Manager for mapping ButtonID to LobbyID. */
|
||||||
private final LobbyButtonTranslationManager translationManager;
|
private final LobbyButtonTranslationManager translationManager;
|
||||||
|
|
||||||
/** Number of rows in the grid. */
|
/** Number of rows in the grid. */
|
||||||
private final int rows = 2;
|
private static final int ROWS = 2;
|
||||||
|
|
||||||
/** Number of columns in the grid. */
|
/** Number of columns in the grid. */
|
||||||
private final int cols = 4;
|
private static final int COLS = 4;
|
||||||
|
|
||||||
/** Path to the button image. */
|
/** Path to the button image. */
|
||||||
private final String buttonImagePath = "/images/logo.png";
|
private static final String BUTTON_IMAGE_PATH = "/images/logo.png";
|
||||||
|
|
||||||
|
/** Max random lobby id. */
|
||||||
|
private static final int MAX_RANDOM_LOBBY_ID = 10000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the GridManager.
|
* Constructor for the GridManager.
|
||||||
@@ -34,14 +43,15 @@ public class LobbyButtonGridManager {
|
|||||||
* @param gridPane the GridPane for rendering
|
* @param gridPane the GridPane for rendering
|
||||||
* @param translationManager the manager for mapping ButtonID to LobbyID
|
* @param translationManager the manager for mapping ButtonID to LobbyID
|
||||||
*/
|
*/
|
||||||
public LobbyButtonGridManager(GridPane gridPane, LobbyButtonTranslationManager translationManager) {
|
public LobbyButtonGridManager(
|
||||||
|
GridPane gridPane, LobbyButtonTranslationManager translationManager) {
|
||||||
this.gridPane = gridPane;
|
this.gridPane = gridPane;
|
||||||
this.translationManager = translationManager;
|
this.translationManager = translationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders all lobby buttons in the grid.
|
* Renders all lobby buttons in the grid. Creates a button for each mapping with image and event
|
||||||
* Creates a button for each mapping with image and event handler.
|
* handler.
|
||||||
*/
|
*/
|
||||||
public void renderLobbyButtons() {
|
public void renderLobbyButtons() {
|
||||||
gridPane.getChildren().clear();
|
gridPane.getChildren().clear();
|
||||||
@@ -55,14 +65,17 @@ public class LobbyButtonGridManager {
|
|||||||
int buttonId = entry.getKey();
|
int buttonId = entry.getKey();
|
||||||
Button btn = new Button();
|
Button btn = new Button();
|
||||||
btn.setId("lobbyBtn-" + buttonId);
|
btn.setId("lobbyBtn-" + buttonId);
|
||||||
btn.setGraphic(new ImageView(new Image(getClass().getResourceAsStream(buttonImagePath))));
|
btn.setGraphic(
|
||||||
btn.setOnAction(e -> {
|
new ImageView(new Image(getClass().getResourceAsStream(BUTTON_IMAGE_PATH))));
|
||||||
|
btn.setOnAction(
|
||||||
|
e -> {
|
||||||
Integer lobbyId = translationManager.getLobbyIdForButton(buttonId);
|
Integer lobbyId = translationManager.getLobbyIdForButton(buttonId);
|
||||||
if (lobbyId != null)
|
if (lobbyId != null) {
|
||||||
joinLobby(lobbyId);
|
joinLobby(lobbyId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
int row = index / cols;
|
int row = index / COLS;
|
||||||
int col = index % cols;
|
int col = index % COLS;
|
||||||
gridPane.add(btn, col, row);
|
gridPane.add(btn, col, row);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@@ -75,8 +88,8 @@ public class LobbyButtonGridManager {
|
|||||||
*/
|
*/
|
||||||
public int createLobby() {
|
public int createLobby() {
|
||||||
// TODO: Replace with actual lobby creation logic
|
// TODO: Replace with actual lobby creation logic
|
||||||
int lobbyId = (int) (Math.random() * 10000 + 1);
|
int lobbyId = (int) (Math.random() * MAX_RANDOM_LOBBY_ID + 1);
|
||||||
System.out.println("Lobby created: " + lobbyId);
|
LOGGER.info("Lobby created: {}", lobbyId);
|
||||||
return lobbyId;
|
return lobbyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +100,7 @@ public class LobbyButtonGridManager {
|
|||||||
*/
|
*/
|
||||||
public void joinLobby(int lobbyId) {
|
public void joinLobby(int lobbyId) {
|
||||||
// TODO: Replace with actual join logic
|
// TODO: Replace with actual join logic
|
||||||
System.out.println("Joining lobby: " + lobbyId);
|
LOGGER.info("Joining lobby: {}", lobbyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+12
-6
@@ -4,24 +4,24 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verwaltet das Mapping zwischen Button-IDs und Lobby-IDs rein im Speicher.
|
* Verwaltet das Mapping zwischen Button-IDs und Lobby-IDs rein im Speicher. Keine Dateioperationen,
|
||||||
* Keine Dateioperationen, nur Laufzeitdatenstruktur.
|
* nur Laufzeitdatenstruktur.
|
||||||
*/
|
*/
|
||||||
public class LobbyButtonTranslationManager {
|
public class LobbyButtonTranslationManager {
|
||||||
/** Maximale Anzahl an Buttons/Lobbys */
|
/** Maximale Anzahl an Buttons/Lobbys */
|
||||||
private static final int MAX_BUTTONS = 8;
|
private static final int MAX_BUTTONS = 8;
|
||||||
|
|
||||||
/** Zuordnung ButtonID → LobbyID */
|
/** Zuordnung ButtonID → LobbyID */
|
||||||
private final Map<Integer, Integer> buttonIdToLobbyId = new HashMap<>();
|
private final Map<Integer, Integer> buttonIdToLobbyId = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/** Konstruktor: initialisiert die Zuordnung leer. */
|
||||||
* Konstruktor: initialisiert die Zuordnung leer.
|
|
||||||
*/
|
|
||||||
public LobbyButtonTranslationManager() {
|
public LobbyButtonTranslationManager() {
|
||||||
// Zuordnung bleibt leer beim Start
|
// Zuordnung bleibt leer beim Start
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prüft, ob das Grid voll ist (MAX_BUTTONS erreicht).
|
* Prüft, ob das Grid voll ist (MAX_BUTTONS erreicht).
|
||||||
|
*
|
||||||
* @return true, wenn Grid voll; sonst false
|
* @return true, wenn Grid voll; sonst false
|
||||||
*/
|
*/
|
||||||
public boolean isFull() {
|
public boolean isFull() {
|
||||||
@@ -30,17 +30,21 @@ public class LobbyButtonTranslationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fügt eine Zuordnung ButtonID → LobbyID hinzu.
|
* Fügt eine Zuordnung ButtonID → LobbyID hinzu.
|
||||||
|
*
|
||||||
* @param buttonId Die ID des Buttons
|
* @param buttonId Die ID des Buttons
|
||||||
* @param lobbyId Die ID der Lobby
|
* @param lobbyId Die ID der Lobby
|
||||||
* @throws Exception wenn das Grid voll ist
|
* @throws Exception wenn das Grid voll ist
|
||||||
*/
|
*/
|
||||||
public void addLobbyButton(int buttonId, int lobbyId) throws Exception {
|
public void addLobbyButton(int buttonId, int lobbyId) throws Exception {
|
||||||
if (isFull()) throw new Exception("Grid is full!");
|
if (isFull()) {
|
||||||
|
throw new Exception("Grid is full!");
|
||||||
|
}
|
||||||
buttonIdToLobbyId.put(buttonId, lobbyId);
|
buttonIdToLobbyId.put(buttonId, lobbyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entfernt eine Zuordnung für die gegebene ButtonID.
|
* Entfernt eine Zuordnung für die gegebene ButtonID.
|
||||||
|
*
|
||||||
* @param buttonId Die ID des zu entfernenden Buttons
|
* @param buttonId Die ID des zu entfernenden Buttons
|
||||||
*/
|
*/
|
||||||
public void removeLobbyButton(int buttonId) {
|
public void removeLobbyButton(int buttonId) {
|
||||||
@@ -49,6 +53,7 @@ public class LobbyButtonTranslationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt die LobbyID für eine gegebene ButtonID zurück.
|
* Gibt die LobbyID für eine gegebene ButtonID zurück.
|
||||||
|
*
|
||||||
* @param buttonId Die ButtonID
|
* @param buttonId Die ButtonID
|
||||||
* @return Die zugehoerige LobbyID oder null, falls nicht vorhanden
|
* @return Die zugehoerige LobbyID oder null, falls nicht vorhanden
|
||||||
*/
|
*/
|
||||||
@@ -58,6 +63,7 @@ public class LobbyButtonTranslationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt die gesamte Zuordnung ButtonID → LobbyID zurück.
|
* Gibt die gesamte Zuordnung ButtonID → LobbyID zurück.
|
||||||
|
*
|
||||||
* @return Map aller Zuordnungen
|
* @return Map aller Zuordnungen
|
||||||
*/
|
*/
|
||||||
public Map<Integer, Integer> getButtonIdToLobbyId() {
|
public Map<Integer, Integer> getButtonIdToLobbyId() {
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class LobbyButtonGridManagerTest {
|
class LobbyButtonGridManagerTest {
|
||||||
LobbyButtonGridManager gridManager;
|
LobbyButtonGridManager gridManager;
|
||||||
LobbyButtonTranslationManager translationManager;
|
LobbyButtonTranslationManager translationManager;
|
||||||
|
|||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
class LobbyButtonTranslationManagerTest {
|
class LobbyButtonTranslationManagerTest {
|
||||||
LobbyButtonTranslationManager manager;
|
LobbyButtonTranslationManager manager;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user