show all playe stats in toolbar

This commit is contained in:
Johannes Schmelz 2024-11-26 00:11:37 +01:00
parent 0e405d2f90
commit 3956d8efa7
3 changed files with 31 additions and 16 deletions

View File

@ -493,4 +493,9 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
public void disconnect() {
serverConnection.disconnect();
}
public int getId() {
if (serverConnection != null && serverConnection instanceof NetworkSupport) return ((NetworkSupport) serverConnection).getId();
return 0;
}
}

View File

@ -16,6 +16,8 @@ import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.game.server.Player;
import pp.monopoly.game.server.PlayerHandler;
import pp.monopoly.notification.Sound;
/**
@ -52,32 +54,37 @@ public class Toolbar extends Dialog {
);
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0)); // Volle Breite
// Füge Buttons zur Toolbar hinzu
//initializeButtons();
PlayerHandler playerHandler = app.getGameLogic().getPlayerHandler();
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
Container accountContainer = toolbarContainer.addChild(new Container());
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
accountContainer.addChild(new Label("6666€", new ElementId("label-Text"))); //TODO Variable hier einsetzen
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR", new ElementId("label-Text"))); //TODO Variable hier einsetzen
accountContainer.addChild(new Label("Gulag Frei Karten", new ElementId("label-Bold")));
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getNumJailCard()+"", new ElementId("label-Text")));
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Add a spacer between accountContainer and overviewContainer
Panel spacer = new Panel(); // Create an empty panel as a spacer
spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
spacer.setBackground(null);
toolbarContainer.addChild(spacer);
// // Add a spacer between accountContainer and overviewContainer
// Panel spacer = new Panel(); // Create an empty panel as a spacer
// spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
// spacer.setBackground(null);
// toolbarContainer.addChild(spacer);
// Menü-Container: Ein Container für Übersicht
Container overviewContainer = toolbarContainer.addChild(new Container());
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
overviewContainer.addChild(new Label("„Spieler 1“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 2“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 3“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 4“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
overviewContainer.addChild(new Label("„Spieler 5“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
for (Player player : playerHandler.getPlayers()) {
if (player.getId() != app.getId()) { // Skip the current player (host)
overviewContainer.addChild(new Label(
player.getName() + ": " + player.getAccountBalance() + " EUR",
new ElementId("label-Text")
));
}
}
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Menü-Container: Ein Container für Würfel

View File

@ -3,6 +3,7 @@ package pp.monopoly.game.server;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@ -15,7 +16,7 @@ import pp.monopoly.model.LimitedLinkedList;
*/
@Serializable
public class PlayerHandler {
private List<Player> players = new LimitedLinkedList<>(6);
private List<Player> players = new LinkedList<>();
private Set<Player> readyPlayers = new HashSet<>();
private transient ServerGameLogic logic;
private Player hostPlayer;
@ -165,8 +166,10 @@ public class PlayerHandler {
* @return the player with the required id
*/
public Player getPlayerById(int id) {
System.out.println("TEST");
for (Player player : players) {
if (player.getId() == id) return player;
System.out.println(player.getId());
}
throw new NoSuchElementException("Player mit id "+id+" existiert nicht");
}