diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/PlayerStatus.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/PlayerStatus.java index d34c54e..7e4aeb1 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/PlayerStatus.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/PlayerStatus.java @@ -4,38 +4,41 @@ * Enum representing a players' current status. * *
The player has the responsibility for getting - * a status.
+ * a status. Each status has a percent-increase threshold + * (measured against the players' starting capital) and a + * human-readable, socio-economic display name used by + * the UI. * */ public enum PlayerStatus { - /** Status representing a beginner. */ - NOOB(0), + /** Status representing a beginner / lowest tier. */ + NOOB(0, "Really Poor"), /** * Status representing a player who has increased * their net worth by at least 20 percent. */ - NOVICE(20), + NOVICE(20, "Poor"), /** * Status representing a player who has increased * their net worth by at least 50 percent. */ - GOOD(50), + GOOD(50, "Middle Class"), /** Status representing a player who has at least doubled their net worth. */ - TRYHARD(100), + TRYHARD(100, "Wealthy"), /** Status representing a player who has at least tripled their net worth. */ - PRO(200), + PRO(200, "Rich"), /** * Status representing a player who has at least quintupled their * net worth. */ - SEER(400), + SEER(400, "Elite"), /** * Status representing a player who has at least dectupled their * net worth. */ - OMNIPOTENT(900); + OMNIPOTENT(900, "Tycoon"); /** * Value representing percent increase @@ -43,13 +46,21 @@ public enum PlayerStatus { * */ private final int percentIncreaseNeeded; + /** + * Human-readable, socio-economic label shown in the UI + * (e.g. "Really Poor", "Middle Class", "Tycoon"). + * */ + private final String displayName; + /** * Constructor. * * @param percentIncreaseNeeded the increase needed to get the status. + * @param displayName the socio-economic label shown in the UI. * */ - PlayerStatus(final int percentIncreaseNeeded) { + PlayerStatus(final int percentIncreaseNeeded, final String displayName) { this.percentIncreaseNeeded = percentIncreaseNeeded; + this.displayName = displayName; } /** @@ -60,5 +71,16 @@ public enum PlayerStatus { public int getPercentIncreaseNeeded() { return percentIncreaseNeeded; } -} + /** + * Returns the human-readable, socio-economic label + * for this status (e.g. "Really Poor", "Middle Class", + * "Tycoon"). Used by the UI to label the players' + * current income/investment tier. + * + * @return the display name. + * */ + public String getDisplayName() { + return displayName; + } +} diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java index d4234e5..6c9940e 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java @@ -32,6 +32,7 @@ public SummaryController(final SummaryView viewElement, eventManager.addSubscriber(this, EventType.STATE_RESET); eventManager.addSubscriber(this, EventType.PRE_LOAD_SAVE); getViewElement().setBalance(player.getStartingMoney().floatValue(), player.getStartingMoney().floatValue()); + getViewElement().setStatus(player.getStatus()); } @Override @@ -46,14 +47,17 @@ protected void initInteractions() { playerNetWorthHistory.add(player.getNetWorth().floatValue()); getViewElement().updateChart(playerNetWorthHistory); getViewElement().setBalance(player.getMoney().floatValue(), player.getNetWorth().floatValue()); + getViewElement().setStatus(player.getStatus()); }); player.getNetWorthAsFloatProperty().addListener((observable, o, n) -> { getViewElement().setBalance(player.getMoney().floatValue(), player.getNetWorth().floatValue()); + getViewElement().setStatus(player.getStatus()); }); player.getMoneyAsFloatProperty().addListener((observable, o, n) -> { getViewElement().setBalance(player.getMoney().floatValue(), player.getNetWorth().floatValue()); + getViewElement().setStatus(player.getStatus()); }); } @@ -99,5 +103,6 @@ publicShows the players' current income/investment tier + * (e.g. "Really Poor", "Middle Class", "Tycoon") as + * computed by {@link edu.ntnu.idi.idatt2003.g40.mappe.controller.PlayerStatusController}.
+ * + * @param status the players' current status. Null is ignored. + * */ + public void setStatus(final PlayerStatus status) { + if (status == null) { + return; + } + statusLabel.setText(status.getDisplayName()); + // Swap CSS pseudo/style class so each tier can be themed + // independently (e.g. red for "Really Poor", gold for "Tycoon"). + statusLabel.getStyleClass().removeIf(c -> c.startsWith("status-tier-")); + statusLabel.getStyleClass().add("status-tier-" + status.name().toLowerCase()); + } + public void setWeek(int week) { weekLabel.setText("week: " + week); }