diff --git a/src/main/java/Model/Player.java b/src/main/java/Model/Player.java index cf3d8a3..ef078a5 100644 --- a/src/main/java/Model/Player.java +++ b/src/main/java/Model/Player.java @@ -62,5 +62,35 @@ public TransactionArchive getTransactionArchive() { return this.transactionArchive; } + /** + * Returns the player's current status based on trading activity and net worth performance. + * + * Status levels: + * - NOVICE: Starting level, no requirements + * - INVESTOR: At least 10 weeks of trading AND net worth increased by at least 20% + * - SPECULATOR: At least 20 weeks of trading AND net worth at least doubled + * + * @return the player's current PlayerStatus + */ + public PlayerStatus getStatus() { + // Calculate total net worth: current cash + portfolio value + BigDecimal totalNetWorth = this.money.add(this.portfolio.getNetWorth()); + + // Get number of weeks with trading activity + int weeksActive = this.transactionArchive.countDistinctWeeks(); + + // Check for SPECULATOR status: 20+ weeks AND net worth doubled + if (weeksActive >= 20 && totalNetWorth.compareTo(this.startingMoney.multiply(new BigDecimal("2"))) >= 0) { + return PlayerStatus.SPECULATOR; + } + + // Check for INVESTOR status: 10+ weeks AND net worth increased by 20% + if (weeksActive >= 10 && totalNetWorth.compareTo(this.startingMoney.multiply(new BigDecimal("1.2"))) >= 0) { + return PlayerStatus.INVESTOR; + } + + // Default: NOVICE + return PlayerStatus.NOVICE; + } } diff --git a/src/main/java/Model/PlayerStatus.java b/src/main/java/Model/PlayerStatus.java new file mode 100644 index 0000000..cf14ea8 --- /dev/null +++ b/src/main/java/Model/PlayerStatus.java @@ -0,0 +1,25 @@ +package Model; + +/** + * Enum representing the player's status level based on trading activity and performance. + * + * Status levels: + * - NOVICE: Starting level, no requirements + * - INVESTOR: Traded for at least 10 weeks AND increased net worth by at least 20% + * - SPECULATOR: Traded for at least 20 weeks AND doubled the net worth (100% increase) + */ +public enum PlayerStatus { + NOVICE("Novice"), + INVESTOR("Investor"), + SPECULATOR("Speculator"); + + private final String displayName; + + PlayerStatus(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } +} diff --git a/src/main/java/View/MainGameScene.java b/src/main/java/View/MainGameScene.java index a167eec..749d2da 100644 --- a/src/main/java/View/MainGameScene.java +++ b/src/main/java/View/MainGameScene.java @@ -488,8 +488,10 @@ private void updateBuyInfo(String symbol, TextField qtyField, Label label) { } private void updateStatus() { + PlayerStatus playerStatus = player.getStatus(); statusLabel.setText( "Player: " + player.getName() + + " | Status: " + playerStatus.getDisplayName() + " | Week: " + exchange.getWeek() + " | Cash: $" + formatMoney(player.getMoney()) + " | Net Worth: $" + formatMoney(getNetWorth())