mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 05:29:44 +01:00
show all playe stats in toolbar
This commit is contained in:
parent
0e405d2f90
commit
3956d8efa7
@ -493,4 +493,9 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
serverConnection.disconnect();
|
serverConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
if (serverConnection != null && serverConnection instanceof NetworkSupport) return ((NetworkSupport) serverConnection).getId();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.notification.Sound;
|
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
|
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0)); // Volle Breite
|
||||||
|
|
||||||
|
PlayerHandler playerHandler = app.getGameLogic().getPlayerHandler();
|
||||||
// Füge Buttons zur Toolbar hinzu
|
|
||||||
//initializeButtons();
|
|
||||||
|
|
||||||
|
|
||||||
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
|
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
|
||||||
Container accountContainer = toolbarContainer.addChild(new Container());
|
Container accountContainer = toolbarContainer.addChild(new Container());
|
||||||
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
|
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("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)));
|
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
// Add a spacer between accountContainer and overviewContainer
|
// // Add a spacer between accountContainer and overviewContainer
|
||||||
Panel spacer = new Panel(); // Create an empty panel as a spacer
|
// Panel spacer = new Panel(); // Create an empty panel as a spacer
|
||||||
spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
|
// spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
|
||||||
spacer.setBackground(null);
|
// spacer.setBackground(null);
|
||||||
toolbarContainer.addChild(spacer);
|
// toolbarContainer.addChild(spacer);
|
||||||
|
|
||||||
// Menü-Container: Ein Container für Übersicht
|
// Menü-Container: Ein Container für Übersicht
|
||||||
Container overviewContainer = toolbarContainer.addChild(new Container());
|
Container overviewContainer = toolbarContainer.addChild(new Container());
|
||||||
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
|
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
|
for (Player player : playerHandler.getPlayers()) {
|
||||||
overviewContainer.addChild(new Label("„Spieler 3“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
if (player.getId() != app.getId()) { // Skip the current player (host)
|
||||||
overviewContainer.addChild(new Label("„Spieler 4“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
overviewContainer.addChild(new Label(
|
||||||
overviewContainer.addChild(new Label("„Spieler 5“: 1244€", new ElementId("label-Text")));//TODO Variable hier einsetzen
|
player.getName() + ": " + player.getAccountBalance() + " EUR",
|
||||||
|
new ElementId("label-Text")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
|
|
||||||
// Menü-Container: Ein Container für Würfel
|
// Menü-Container: Ein Container für Würfel
|
||||||
|
@ -3,6 +3,7 @@ package pp.monopoly.game.server;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -15,7 +16,7 @@ import pp.monopoly.model.LimitedLinkedList;
|
|||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class PlayerHandler {
|
public class PlayerHandler {
|
||||||
private List<Player> players = new LimitedLinkedList<>(6);
|
private List<Player> players = new LinkedList<>();
|
||||||
private Set<Player> readyPlayers = new HashSet<>();
|
private Set<Player> readyPlayers = new HashSet<>();
|
||||||
private transient ServerGameLogic logic;
|
private transient ServerGameLogic logic;
|
||||||
private Player hostPlayer;
|
private Player hostPlayer;
|
||||||
@ -165,8 +166,10 @@ public class PlayerHandler {
|
|||||||
* @return the player with the required id
|
* @return the player with the required id
|
||||||
*/
|
*/
|
||||||
public Player getPlayerById(int id) {
|
public Player getPlayerById(int id) {
|
||||||
|
System.out.println("TEST");
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
if (player.getId() == id) return player;
|
if (player.getId() == id) return player;
|
||||||
|
System.out.println(player.getId());
|
||||||
}
|
}
|
||||||
throw new NoSuchElementException("Player mit id "+id+" existiert nicht");
|
throw new NoSuchElementException("Player mit id "+id+" existiert nicht");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user