diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java index ad65643e..83515559 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSyncronizer.java @@ -76,6 +76,12 @@ public void enter(MdgaState state) { ceremonyView.addCeremonyParticipant(Color.ARMY, 2, "ugidffdg"); ceremonyView.addCeremonyParticipant(Color.NAVY, 3, "ugidffdg"); ceremonyView.addCeremonyParticipant(Color.CYBER, 4, "ugidffdg"); + + ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6); + ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6); + ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6); + ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6); + ceremonyView.addStatisticsRow("Gesamt", 1, 2, 3, 4, 5, 6); } } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java index f9cddb7b..c97cd682 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java @@ -75,13 +75,33 @@ private void handleGame(Notification notification) { // Handle AcquireCardNotification } else if (notification instanceof ActivePlayerNotification n) { gameView.getGuiHandler().setActivePlayer(n.getColor()); - } else if (notification instanceof CeremonyNotification) { + } else if (notification instanceof CeremonyNotification ceremonyNotification) { app.enter(MdgaState.CEREMONY); CeremonyView ceremonyView = (CeremonyView) app.getView(); - ceremonyView.addCeremonyParticipant(Color.AIRFORCE, 1, "ugidffdg"); - ceremonyView.addCeremonyParticipant(Color.ARMY, 2, "ugidffdg"); - ceremonyView.addCeremonyParticipant(Color.NAVY, 3, "ugidffdg"); - ceremonyView.addCeremonyParticipant(Color.CYBER, 4, "ugidffdg"); + int size = ceremonyNotification.getNames().size(); + + if (ceremonyNotification.getPiecesThrown().size() != size || + ceremonyNotification.getPiecesLost().size() != size || + ceremonyNotification.getBonusCardsPlayed().size() != size || + ceremonyNotification.getSixes().size() != size || + ceremonyNotification.getNodesMoved().size() != size || + ceremonyNotification.getBonusNodes().size() != size) { + throw new IllegalArgumentException("All data lists in CeremonyNotification must have the same size."); + } + + for (int i = 0; i < size; i++) { + Color color = ceremonyNotification.getColors().get(i); + String name = ceremonyNotification.getNames().get(i); + int v1 = ceremonyNotification.getPiecesThrown().get(i); + int v2 = ceremonyNotification.getPiecesLost().get(i); + int v3 = ceremonyNotification.getBonusCardsPlayed().get(i); + int v4 = ceremonyNotification.getSixes().get(i); + int v5 = ceremonyNotification.getNodesMoved().get(i); + int v6 = ceremonyNotification.getBonusNodes().get(i); + + ceremonyView.addCeremonyParticipant(color, i, name); + ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6); + } } else if (notification instanceof DiceNowNotification) { // Handle DiceNowNotification } else if (notification instanceof DicingNotification) { diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java index c2715695..de37adc1 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java @@ -7,10 +7,10 @@ import pp.mdga.client.MdgaApp; public abstract class AbstractButton { - protected static final ColorRGBA BUTTON_NORMAL = ColorRGBA.fromRGBA255(169, 165, 104, 255); - protected static final ColorRGBA BUTTON_PRESSED = ColorRGBA.fromRGBA255(105, 117, 89, 255); - protected static final ColorRGBA TEXT_NORMAL = ColorRGBA.Black; - protected static final ColorRGBA TEXT_PRESSED = ColorRGBA.fromRGBA255( 180, 195, 191, 255); + public static final ColorRGBA BUTTON_NORMAL = ColorRGBA.fromRGBA255(169, 165, 104, 255); + public static final ColorRGBA BUTTON_PRESSED = ColorRGBA.fromRGBA255(105, 117, 89, 255); + public static final ColorRGBA TEXT_NORMAL = ColorRGBA.Black; + public static final ColorRGBA TEXT_PRESSED = ColorRGBA.fromRGBA255( 180, 195, 191, 255); public static final float HORIZONTAL = 16; public static final float VERTICAL = 9; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java index d7648db3..4b207f0b 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java @@ -130,6 +130,8 @@ public void onUnHover() { @Override public void show() { + release(); + calculateRelative(); setRelative(); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java index 3330f564..0b1fe1e6 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java @@ -39,12 +39,12 @@ public abstract class ClickButton extends AbstractButton { calculateRelative(); setRelative(); - - release(); } @Override public void show() { + release(); + calculateRelative(); setRelative(); @@ -59,7 +59,7 @@ public void hide() { protected abstract void onHover(); protected abstract void onUnHover(); - private void click() { + protected void click() { instance.setColor(TEXT_PRESSED); instance.setHighlightColor(TEXT_PRESSED); @@ -69,7 +69,7 @@ private void click() { onHover(); }; - private void release() { + protected void release() { instance.setColor(TEXT_NORMAL); instance.setHighlightColor(TEXT_NORMAL); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java index 2257d21a..1740a954 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java @@ -7,12 +7,17 @@ import pp.mdga.client.MdgaApp; public class LabelButton extends ClickButton{ + private ColorRGBA text = TEXT_NORMAL; + private ColorRGBA button = BUTTON_NORMAL; + public LabelButton(MdgaApp app, Node node, String label, Vector2f size, Vector2f pos) { super(app, node, () -> {}, label, size, pos); } @Override public void show() { + release(); + calculateRelative(); setRelative(); @@ -28,23 +33,31 @@ public void hide() { @Override public void onHover() { - instance.setColor(TEXT_NORMAL); - instance.setHighlightColor(TEXT_NORMAL); + instance.setColor(text); + instance.setHighlightColor(text); - QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL); + QuadBackgroundComponent background = new QuadBackgroundComponent(button); instance.setBackground(background); } @Override public void onUnHover() { - instance.setColor(TEXT_NORMAL); - instance.setHighlightColor(TEXT_NORMAL); + instance.setColor(text); + instance.setHighlightColor(text); - QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL); + QuadBackgroundComponent background = new QuadBackgroundComponent(button); instance.setBackground(background); } public void setText(String text) { instance.setText(text); } + + public void setColor(ColorRGBA text, ColorRGBA button) { + this.text = text; + this.button = button; + + hide(); + show(); + } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java index e852d6c5..1ee3b882 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java @@ -129,6 +129,8 @@ public void onUnHover() { @Override public void show() { + release(); + calculateRelative(); setRelative(); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java index c902de0a..261ce033 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java @@ -1,8 +1,10 @@ package pp.mdga.client.dialog; +import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; import com.jme3.scene.Node; import pp.mdga.client.MdgaApp; +import pp.mdga.client.button.AbstractButton; import pp.mdga.client.button.InputButton; import pp.mdga.client.button.LabelButton; import pp.mdga.client.button.MenuButton; @@ -13,39 +15,33 @@ public class CeremonyDialog extends Dialog { private ArrayList> labels; + float offsetX = 0.5f; + public CeremonyDialog(MdgaApp app, Node node) { super(app, node); labels = new ArrayList<>(); - labels.add(new ArrayList<>()); - labels.add(new ArrayList<>()); - labels.add(new ArrayList<>()); - labels.add(new ArrayList<>()); - labels.add(new ArrayList<>()); - labels.add(new ArrayList<>()); - float offsetX = 0.5f; + ArrayList first = new ArrayList<>(); + Vector2f size = new Vector2f(4, 1.2f); + first.add(new LabelButton(app, node, "", size, new Vector2f())); + first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f())); + first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f())); + first.add(new LabelButton(app, node, "Verwendete Bonuskarten", size, new Vector2f())); + first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f())); + first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f())); + first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f())); - for (ArrayList row : labels) { + float offsetY = 0.5f; - float offsetY = 0.5f; - - Vector2f size = new Vector2f(5, 1.2f); - row.add(new LabelButton(app, node, "", size, new Vector2f())); - row.add(new LabelButton(app, node, "Würfe", size, new Vector2f())); - row.add(new LabelButton(app, node, "Figuren rausgeworfen", size, new Vector2f())); - row.add(new LabelButton(app, node, "verwendete Bonuskarten", size, new Vector2f())); - row.add(new LabelButton(app, node, "gewürfelte 6en", size, new Vector2f())); - row.add(new LabelButton(app, node, "gelaufene Felder", size, new Vector2f())); - row.add(new LabelButton(app, node, "auf Bonusfeldern gelandet", size, new Vector2f())); - - for (LabelButton b : row) { - b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY)); - offsetY += 0.8f; - } - - offsetX += 3; + for (LabelButton b : first) { + b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY)); + offsetY += 0.8f; } + + offsetX += 2.3f; + + labels.add(first); } @Override @@ -65,4 +61,41 @@ protected void onHide() { } } } + + public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) { + float offsetYSmall = 0.5f; + + ArrayList row = new ArrayList<>(); + + Vector2f sizeSmall = new Vector2f(4, 1.2f); + row.add(new LabelButton(app, node, name, sizeSmall, new Vector2f())); + row.add(new LabelButton(app, node, "" + v1, sizeSmall, new Vector2f())); + row.add(new LabelButton(app, node, "" + v2, sizeSmall, new Vector2f())); + row.add(new LabelButton(app, node, "" + v3, sizeSmall, new Vector2f())); + row.add(new LabelButton(app, node, "" + v4, sizeSmall, new Vector2f())); + row.add(new LabelButton(app, node, "" + v5, sizeSmall, new Vector2f())); + row.add(new LabelButton(app, node, "" + v6, sizeSmall, new Vector2f())); + + ColorRGBA colorText = AbstractButton.TEXT_NORMAL.clone(); + colorText.a = 0.1f; + + ColorRGBA colorButton = AbstractButton.BUTTON_NORMAL.clone(); + colorButton.a = 0.1f; + + int j = 0; + for (LabelButton b : row) { + if(j > 0) { + b.setColor(colorText, colorButton); + } + + b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetYSmall)); + offsetYSmall += 0.8f; + + j++; + } + + offsetX += 2.3f; + + labels.add(row); + } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java index 103614d9..d6fd6941 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java @@ -58,7 +58,9 @@ public void onLeave() { backButton.hide(); continueButton.hide(); - guiNode.detachChild(background); + if(null != background) { + guiNode.detachChild(background); + } ceremonyButtons.clear(); @@ -89,8 +91,8 @@ private void awardCeremony() { } private void statistics() { - background = createBackground("Images/b2.png"); - guiNode.attachChild(background); + //background = createBackground("Images/b2.png"); + //guiNode.attachChild(background); backButton.show(); continueButton.show(); @@ -152,4 +154,8 @@ public void addCeremonyParticipant(Color color, int pos, String name) { button.show(); } } + + public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) { + ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6); + } } diff --git a/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java b/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java index 3f88eb8a..f7210f69 100644 --- a/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java +++ b/Projekte/mdga/model/src/main/java/pp.mdga/notification/CeremonyNotification.java @@ -1,12 +1,156 @@ package pp.mdga.notification; +import pp.mdga.game.Color; + +import java.util.ArrayList; + /** * Class CeremonyNotification + * Represents a notification for a ceremony in the game. + * + * Index mapping: + * index = 0 ==> winner + * index = 1 ==> 2nd + * index = 2 ==> third place + * index = 3 ==> loser + * index = 4 ==> total */ -public class CeremonyNotification extends Notification{ +public class CeremonyNotification extends Notification { + private ArrayList colors; + private ArrayList names; + private ArrayList piecesThrown; + private ArrayList piecesLost; + private ArrayList bonusCardsPlayed; + private ArrayList sixes; + private ArrayList nodesMoved; + private ArrayList bonusNodes; + /** * Constructor + * Initializes all lists. */ - CeremonyNotification() { + public CeremonyNotification() { + this.colors = new ArrayList<>(); + this.names = new ArrayList<>(); + this.piecesThrown = new ArrayList<>(); + this.piecesLost = new ArrayList<>(); + this.bonusCardsPlayed = new ArrayList<>(); + this.sixes = new ArrayList<>(); + this.nodesMoved = new ArrayList<>(); + this.bonusNodes = new ArrayList<>(); + } + + // Getters and Setters + + /** + * @return the list of colors + */ + public ArrayList getColors() { + return colors; + } + + /** + * @param colors the list of colors to set + */ + public void setColors(ArrayList colors) { + this.colors = colors; + } + + /** + * @return the list of player names + */ + public ArrayList getNames() { + return names; + } + + /** + * @param names the list of player names to set + */ + public void setNames(ArrayList names) { + this.names = names; + } + + /** + * @return the list of pieces thrown + */ + public ArrayList getPiecesThrown() { + return piecesThrown; + } + + /** + * @param piecesThrown the list of pieces thrown to set + */ + public void setPiecesThrown(ArrayList piecesThrown) { + this.piecesThrown = piecesThrown; + } + + /** + * @return the list of pieces lost + */ + public ArrayList getPiecesLost() { + return piecesLost; + } + + /** + * @param piecesLost the list of pieces lost to set + */ + public void setPiecesLost(ArrayList piecesLost) { + this.piecesLost = piecesLost; + } + + /** + * @return the list of bonus cards played + */ + public ArrayList getBonusCardsPlayed() { + return bonusCardsPlayed; + } + + /** + * @param bonusCardsPlayed the list of bonus cards played to set + */ + public void setBonusCardsPlayed(ArrayList bonusCardsPlayed) { + this.bonusCardsPlayed = bonusCardsPlayed; + } + + /** + * @return the list of sixes rolled + */ + public ArrayList getSixes() { + return sixes; + } + + /** + * @param sixes the list of sixes rolled to set + */ + public void setSixes(ArrayList sixes) { + this.sixes = sixes; + } + + /** + * @return the list of nodes moved + */ + public ArrayList getNodesMoved() { + return nodesMoved; + } + + /** + * @param nodesMoved the list of nodes moved to set + */ + public void setNodesMoved(ArrayList nodesMoved) { + this.nodesMoved = nodesMoved; + } + + /** + * @return the list of bonus nodes + */ + public ArrayList getBonusNodes() { + return bonusNodes; + } + + /** + * @param bonusNodes the list of bonus nodes to set + */ + public void setBonusNodes(ArrayList bonusNodes) { + this.bonusNodes = bonusNodes; } }