From e98e17f6d798171b78d3396d948e9df2b6aae8a9 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Mon, 9 Dec 2024 13:55:04 +0100 Subject: [PATCH] cleanup --- .../pp/monopoly/client/BoardAppState.java | 1 - .../pp/monopoly/client/gui/FigureControl.java | 34 +++++++++++-------- .../pp/monopoly/client/gui/LobbyMenu.java | 1 - .../java/pp/monopoly/client/gui/Toolbar.java | 3 +- .../monopoly/client/gui/hslider/ListBox.java | 2 -- .../gui/popups/BuildingPropertyCard.java | 1 - .../monopoly/client/gui/popups/SellHouse.java | 6 ---- .../monopoly/game/client/ClientGameLogic.java | 3 +- .../monopoly/game/server/ServerGameLogic.java | 1 - .../main/java/pp/monopoly/model/Figure.java | 3 +- .../game/server/ServerGameLogicTest.java | 2 -- 11 files changed, 23 insertions(+), 34 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java index f930b96..b300a63 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java @@ -99,7 +99,6 @@ public class BoardAppState extends MonopolyAppState { setupScene(); if (bobTheBuilder == null) { bobTheBuilder = new BobTheBuilder(getApp(), sceneNode); - System.out.println("LISTENER IS REGISTEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"); getGameLogic().addListener(bobTheBuilder); } getApp().getRootNode().attachChild(viewNode); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java index e1663f3..a09ce28 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java @@ -1,24 +1,27 @@ package pp.monopoly.client.gui; import com.jme3.math.FastMath; -import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.scene.Node; -import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.model.Figure; import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.UpdatePlayerView; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.LinkedList; import java.util.Queue; + public class FigureControl extends AbstractControl implements GameEventListener { + private static final Logger LOGGER = System.getLogger(FigureControl.class.getName()); private final Figure figure; private final Node spatial; private final MonopolyApp app; @@ -47,14 +50,14 @@ public class FigureControl extends AbstractControl implements GameEventListener return; // Warte, bis die Verzögerung abgeschlossen ist } delayTime = 0; // Verzögerung abgeschlossen - System.out.println("Delay completed. Starting animation..."); + LOGGER.log(Level.DEBUG, "Delay completed. Starting animation..."); } if (currentTarget == null && !path.isEmpty()) { // Hole das nächste Ziel aus dem Pfad currentTarget = path.poll(); animationTime = 0f; - System.out.println("Next target: " + currentTarget); + LOGGER.log(Level.DEBUG, "Next target: {0}", currentTarget); } if (currentTarget != null) { @@ -76,7 +79,8 @@ public class FigureControl extends AbstractControl implements GameEventListener spatial.setLocalTranslation(currentTarget); figure.moveTo(currentTarget); // Synchronisiere die interne Position currentTarget = null; // Setze Ziel zurück - System.out.println("Target reached."); + + LOGGER.log(Level.DEBUG, "Target reached. Remaining path: {0}", path.size()); } } } @@ -97,33 +101,35 @@ public class FigureControl extends AbstractControl implements GameEventListener } public void setPath(int startField, int endField) { - System.out.println("setPath called with startField: " + startField + ", endField: " + endField); + LOGGER.log(Level.TRACE, "setPath called with startField: {0} to endField {1}", startField, endField); path.clear(); for (int fieldId = startField; fieldId != endField; fieldId = (fieldId + 1) % 40) { Vector3f position = figure.calculateFieldPosition(fieldId); - System.out.println("Adding position to path: " + position); + LOGGER.log(Level.DEBUG, "Adding postition to path: {0}", position); path.add(position); } Vector3f finalPosition = figure.calculateFieldPosition(endField); path.add(finalPosition); - System.out.println("Final position added to path: " + finalPosition); - - System.out.println("Path size: " + path.size()); + LOGGER.log(Level.DEBUG, "Final position added to path: {0}", finalPosition); + + + LOGGER.log(Level.TRACE, "Path size: {0}", path.size()); } @Override public void receivedEvent(UpdatePlayerView event) { - System.out.println("Event received: " + event); - + LOGGER.log(Level.TRACE, "receivedEvent called with event: {0}", event); + int newPos = app.getGameLogic().getPlayerHandler().getPlayerById(figure.getId()).getFieldID(); int currentField = figure.getCurrentFieldID(); if (currentField == newPos) { - System.out.println("Figure is already at the correct position. No path set."); + LOGGER.log(Level.DEBUG, "No movement required. Current field: {0}, New field: {1}", currentField, newPos); return; } - System.out.println("Movement required. Current field: " + currentField + ", New field: " + newPos); + LOGGER.log(Level.DEBUG, "Movement required. Current field: {0}, New field: {1}", currentField, newPos); + setPath(currentField, newPos); delayTime = 3f; // Verzögerung zurücksetzen diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java index fa468f9..3c5768d 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java @@ -325,7 +325,6 @@ public class LobbyMenu extends Dialog { figure = selector.getSelectedItem(); break; } - System.out.println("FIGUR:::::"+figure); } /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index 51aec7d..740df8c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -381,7 +381,7 @@ public class Toolbar extends Dialog implements GameEventListener { showFinalDiceResult(latestDiceRollEvent); } } catch (InterruptedException e) { - System.err.println("Dice animation interrupted: " + e.getMessage()); + e.printStackTrace(); } }).start(); } @@ -527,7 +527,6 @@ public class Toolbar extends Dialog implements GameEventListener { */ @Override public void receivedEvent(ButtonStatusEvent event) { - System.out.println("Button status event received: " + event.buttonsEnabled()+ "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG"); boolean enabled = event.buttonsEnabled(); canRollDice = enabled; tradeButton.setEnabled(enabled); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/hslider/ListBox.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/hslider/ListBox.java index 1b0c0ed..433476c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/hslider/ListBox.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/hslider/ListBox.java @@ -910,7 +910,6 @@ } sliderhorsetup(); adjustothercolumnmodel(); - // System.out.println("Columns available: " +availableColumns); } @StyleAttribute(value="visibleColumns") @@ -923,7 +922,6 @@ sliderhorsetup(); grid.refreshGrid(); refreshSelector(); - // System.out.println("Columns visble: " +grid.getVisibleColumns()); } // Column Operations diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java index d320d80..fd17bc1 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java @@ -78,7 +78,6 @@ public class BuildingPropertyCard extends Dialog { Button quitButton = buildingPropertyContainer.addChild(new Button("Beenden", new ElementId("button"))); quitButton.setFontSize(32); quitButton.addClickCommands(s -> ifTopDialog( () -> { - System.err.println("Button does something?"); app.getGameLogic().playSound(Sound.BUTTON); close(); })); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java index 1509f9f..49501e7 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -119,13 +119,7 @@ public class SellHouse extends Dialog { confirmButton.addClickCommands(s -> ifTopDialog( () -> { app.getGameLogic().playSound(Sound.BUTTON); AlterProperty msg = new AlterProperty("SellHouse"); - for (String string : selectedProperties) { - System.out.println(string); - } msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet())); - for (Integer integer : msg.getProperties()) { - System.out.println("ID des verkaufs: "+integer); - } app.getGameLogic().send(msg); close(); })); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index 1d43175..e5f641a 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -253,7 +253,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { @Override public void received(PlayerStatusUpdate msg) { playerHandler = msg.getPlayerHandler(); - System.out.println("Update Player"); + LOGGER.log(Level.TRACE, "Update Player View triggerd with message: {0}", msg); notifyListeners(new UpdatePlayerView()); } @@ -317,7 +317,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { @Override public void received(BuildInfo msg) { - System.out.println("TRIGGER BUILD INFO"); if (msg.isAdded()) { BuildingProperty property = ((BuildingProperty)boardManager.getFieldAtIndex(msg.getId())); if (property.getHotel() == 1 ) { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java index ff055e5..ea33b69 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java @@ -168,7 +168,6 @@ public class ServerGameLogic implements ClientInterpreter { PropertyField property = (PropertyField) boardManager.getFieldAtIndex(player.getFieldID()); // Assuming player position for property player.buyProperty(property); - System.out.println("Properties:" +player.getProperties().toString()); LOGGER.log(Level.INFO, "Player {0} bought property {1}", player.getName(), property.getName()); } updateAllPlayers(); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java index 74e4dc4..6919997 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java @@ -150,7 +150,7 @@ public class Figure implements Item{ float zOffset = new Random().nextFloat(); //TODO adjust y pos - return new Vector3f(baseX , 1, baseZ ); + return new Vector3f(baseX , 0, baseZ ); } public int getCurrentFieldID() { @@ -158,7 +158,6 @@ public class Figure implements Item{ for (int fieldID = 0; fieldID < 40; fieldID++) { Vector3f fieldPosition = calculateFieldPosition(fieldID); if (pos.distance(fieldPosition) < 0.1f) { // Toleranz für Positionsvergleich - System.out.println("Current field ID: " + fieldID); return fieldID; } } diff --git a/Projekte/monopoly/model/src/test/java/pp/monopoly/game/server/ServerGameLogicTest.java b/Projekte/monopoly/model/src/test/java/pp/monopoly/game/server/ServerGameLogicTest.java index 8d6004b..4205ae7 100644 --- a/Projekte/monopoly/model/src/test/java/pp/monopoly/game/server/ServerGameLogicTest.java +++ b/Projekte/monopoly/model/src/test/java/pp/monopoly/game/server/ServerGameLogicTest.java @@ -801,8 +801,6 @@ public class ServerGameLogicTest { player.buyProperty(property); - System.out.println("Player Balance: " + player.getAccountBalance()); - System.out.println("Player Properties: " + player.getProperties()); assertEquals(14000, player.getAccountBalance()); assertTrue(player.getProperties().contains(property.getId())); }