Skip to content

Added more PlayerStatuses #42

Merged
merged 1 commit into from
May 26, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/Model/Player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ public TransactionArchive getTransactionArchive() {
/**
* Returns the player's current status based on trading activity and net worth performance.
* Status levels:
* - ROOKIE: Net worth is 1/4 or less of starting capital (significant losses)
* - 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
* - TYCOON: At least 50 weeks of trading AND net worth at least 5x
*
* @return the player's current PlayerStatus
*/
Expand All @@ -127,6 +129,18 @@ public PlayerStatus getStatus() {

// Get number of weeks with trading activity
int weeksActive = this.transactionArchive.countDistinctWeeks();

// Check for ROOKIE status: net worth is 1/4 or less of starting capital (significant losses)
if (totalNetWorth.compareTo(this
.startingMoney.multiply(new BigDecimal("0.25"))) <= 0) {
return PlayerStatus.ROOKIE;
}

// Check for TYCOON status: 50+ weeks AND net worth increased 5x
if (weeksActive >= 50 && totalNetWorth.compareTo(this
.startingMoney.multiply(new BigDecimal("5"))) >= 0) {
return PlayerStatus.TYCOON;
}

// Check for SPECULATOR status: 20+ weeks AND net worth doubled
if (weeksActive >= 20 && totalNetWorth.compareTo(this
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/Model/Player/PlayerStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
* Status levels are determined by trading activity (weeks with transactions)
* and net worth performance compared to starting capital.
* Levels:
* - ROOKIE: Net worth is 1/4 or less of starting capital (significant losses)
* - NOVICE: Initial status (default)
* - INVESTOR: 10+ weeks of trading AND net worth increased by 20%
* - SPECULATOR: 20+ weeks of trading AND net worth doubled
* - TYCOON: 50+ weeks of trading AND net worth increased 5x
*/
public enum PlayerStatus {
ROOKIE("Rookie"),
NOVICE("Novice"),
INVESTOR("Investor"),
SPECULATOR("Speculator");
SPECULATOR("Speculator"),
TYCOON("Tycoon");

private final String displayName;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/Model/Purchase/Purchase.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void commit(Player player) {

if (player.getMoney().compareTo(price) < 0) {
throw new IllegalStateException(
"Insufficient funds: required " + price + ", available " + player.getMoney()
"Insufficient funds: required " + price.toPlainString()
+ ", available " + player.getMoney().toPlainString()
);
}

Expand Down