From e28fe3e31d07d7a4b410c30760a4d40fb017c20c Mon Sep 17 00:00:00 2001 From: Staszek Welsh Date: Mon, 30 May 2022 22:05:05 +0100 Subject: [PATCH] Use stored corporation.dividendTax in the dividend tax calculation --- src/Corporation/Corporation.tsx | 28 +++++++++++++++------------- src/Corporation/ICorporation.ts | 5 +++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Corporation/Corporation.tsx b/src/Corporation/Corporation.tsx index 787e22569..a41185372 100644 --- a/src/Corporation/Corporation.tsx +++ b/src/Corporation/Corporation.tsx @@ -36,7 +36,7 @@ export class Corporation { shareSaleCooldown = 0; // Game cycles until player can sell shares again issueNewSharesCooldown = 0; // Game cycles until player can issue shares again dividendRate = 0; - dividendTaxPercentage = 100 - 100 * BitNodeMultipliers.CorporationSoftcap; + dividendTax = 1 - BitNodeMultipliers.CorporationSoftcap + 0.15; issuedShares = 0; sharePrice = 0; storedCycles = 0; @@ -121,6 +121,7 @@ export class Corporation { } // Process dividends + this.updateDividendTax(); if (this.dividendRate > 0 && cycleProfit > 0) { // Validate input again, just to be safe if ( @@ -146,20 +147,23 @@ export class Corporation { } } + updateDividendTax(): void { + this.dividendTax = 1 - BitNodeMultipliers.CorporationSoftcap + 0.15; + if (this.unlockUpgrades[5] === 1) { + this.dividendTax -= 0.05; + } + if (this.unlockUpgrades[6] === 1) { + this.dividendTax -= 0.1; + } + } + getDividends(): number { const profit = this.revenue - this.expenses; const cycleProfit = profit * CorporationConstants.SecsPerMarketCycle; const totalDividends = this.dividendRate * cycleProfit; const dividendsPerShare = totalDividends / this.totalShares; const dividends = this.numShares * dividendsPerShare; - let upgrades = -0.15; - if (this.unlockUpgrades[5] === 1) { - upgrades += 0.05; - } - if (this.unlockUpgrades[6] === 1) { - upgrades += 0.1; - } - return Math.pow(dividends, BitNodeMultipliers.CorporationSoftcap + upgrades); + return Math.pow(dividends, 1 - this.dividendTax); } determineValuation(): number { @@ -277,10 +281,8 @@ export class Corporation { this.funds = this.funds - price; // Apply effects for one-time upgrades - if (upgN === 5) { - this.dividendTaxPercentage -= 5; - } else if (upgN === 6) { - this.dividendTaxPercentage -= 10; + if (upgN === 5 || upgN === 6) { + this.updateDividendTax(); } } diff --git a/src/Corporation/ICorporation.ts b/src/Corporation/ICorporation.ts index ebb51cad6..457f09061 100644 --- a/src/Corporation/ICorporation.ts +++ b/src/Corporation/ICorporation.ts @@ -20,7 +20,7 @@ export interface ICorporation { shareSaleCooldown: number; issueNewSharesCooldown: number; dividendRate: number; - dividendTaxPercentage: number; + dividendTax: number; issuedShares: number; sharePrice: number; storedCycles: number; @@ -54,6 +54,7 @@ export interface ICorporation { getSalesMultiplier(): number; getScientificResearchMultiplier(): number; getStarterGuide(player: IPlayer): void; - toJSON(): any; + updateDividendTax(): void; getDividends(): number; + toJSON(): any; }