From 445dd5b49df125b480ea2b79a68eca3d1a058c24 Mon Sep 17 00:00:00 2001 From: Elisabeth Berg Date: Sun, 24 May 2026 22:19:28 +0200 Subject: [PATCH] Edited Pkayer class for status --- src/main/java/Model/Player.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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; + } }