Skip to content

Commit

Permalink
Edited Pkayer class for status
Browse files Browse the repository at this point in the history
  • Loading branch information
elisab3 committed May 24, 2026
1 parent 4a0c756 commit 445dd5b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/Model/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

0 comments on commit 445dd5b

Please sign in to comment.