From 8d474a7610febe574478a1739d68590b04f260d7 Mon Sep 17 00:00:00 2001 From: Staszek Welsh Date: Mon, 30 May 2022 21:45:36 +0100 Subject: [PATCH] Change corporation.dividendPercentage to corporation.dividendRate --- src/Corporation/Actions.ts | 8 +++---- src/Corporation/Corporation.tsx | 22 +++++++++---------- src/Corporation/ICorporation.ts | 2 +- src/Corporation/data/Constants.ts | 4 ++-- src/Corporation/ui/Overview.tsx | 6 ++--- .../ui/modals/IssueDividendsModal.tsx | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index 1ec820037..acd211467 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -84,12 +84,12 @@ export function LevelUpgrade(corporation: ICorporation, upgrade: CorporationUpgr } } -export function IssueDividends(corporation: ICorporation, percent: number): void { - if (isNaN(percent) || percent < 0 || percent > CorporationConstants.DividendMaxPercentage) { - throw new Error(`Invalid value. Must be an integer between 0 and ${CorporationConstants.DividendMaxPercentage}`); +export function IssueDividends(corporation: ICorporation, rate: number): void { + if (isNaN(rate) || rate < 0 || rate > CorporationConstants.DividendMaxRate) { + throw new Error(`Invalid value. Must be an number between 0 and ${CorporationConstants.DividendMaxRate}`); } - corporation.dividendPercentage = percent * 100; + corporation.dividendRate = rate; } export function SellMaterial(mat: Material, amt: string, price: string): void { diff --git a/src/Corporation/Corporation.tsx b/src/Corporation/Corporation.tsx index ace40ae72..787e22569 100644 --- a/src/Corporation/Corporation.tsx +++ b/src/Corporation/Corporation.tsx @@ -35,8 +35,8 @@ export class Corporation { shareSalesUntilPriceUpdate = CorporationConstants.SHARESPERPRICEUPDATE; shareSaleCooldown = 0; // Game cycles until player can sell shares again issueNewSharesCooldown = 0; // Game cycles until player can issue shares again - dividendPercentage = 0; - dividendTaxPercentage = 50; + dividendRate = 0; + dividendTaxPercentage = 100 - 100 * BitNodeMultipliers.CorporationSoftcap; issuedShares = 0; sharePrice = 0; storedCycles = 0; @@ -121,16 +121,16 @@ export class Corporation { } // Process dividends - if (this.dividendPercentage > 0 && cycleProfit > 0) { + if (this.dividendRate > 0 && cycleProfit > 0) { // Validate input again, just to be safe if ( - isNaN(this.dividendPercentage) || - this.dividendPercentage < 0 || - this.dividendPercentage > CorporationConstants.DividendMaxPercentage * 100 + isNaN(this.dividendRate) || + this.dividendRate < 0 || + this.dividendRate > CorporationConstants.DividendMaxRate ) { - console.error(`Invalid Corporation dividend percentage: ${this.dividendPercentage}`); + console.error(`Invalid Corporation dividend rate: ${this.dividendRate}`); } else { - const totalDividends = (this.dividendPercentage / 100) * cycleProfit; + const totalDividends = this.dividendRate * cycleProfit; const retainedEarnings = cycleProfit - totalDividends; player.gainMoney(this.getDividends(), "corporation"); this.addFunds(retainedEarnings); @@ -149,7 +149,7 @@ export class Corporation { getDividends(): number { const profit = this.revenue - this.expenses; const cycleProfit = profit * CorporationConstants.SecsPerMarketCycle; - const totalDividends = (this.dividendPercentage / 100) * cycleProfit; + const totalDividends = this.dividendRate * cycleProfit; const dividendsPerShare = totalDividends / this.totalShares; const dividends = this.numShares * dividendsPerShare; let upgrades = -0.15; @@ -167,8 +167,8 @@ export class Corporation { profit = this.avgProfit; if (this.public) { // Account for dividends - if (this.dividendPercentage > 0) { - profit *= (100 - this.dividendPercentage) / 100; + if (this.dividendRate > 0) { + profit *= 1 - this.dividendRate; } val = this.funds + profit * 85e3; diff --git a/src/Corporation/ICorporation.ts b/src/Corporation/ICorporation.ts index 609204fee..ebb51cad6 100644 --- a/src/Corporation/ICorporation.ts +++ b/src/Corporation/ICorporation.ts @@ -19,7 +19,7 @@ export interface ICorporation { shareSalesUntilPriceUpdate: number; shareSaleCooldown: number; issueNewSharesCooldown: number; - dividendPercentage: number; + dividendRate: number; dividendTaxPercentage: number; issuedShares: number; sharePrice: number; diff --git a/src/Corporation/data/Constants.ts b/src/Corporation/data/Constants.ts index d6b53f3d1..c83e3e0d7 100644 --- a/src/Corporation/data/Constants.ts +++ b/src/Corporation/data/Constants.ts @@ -19,7 +19,7 @@ export const CorporationConstants: { BribeThreshold: number; BribeToRepRatio: number; ProductProductionCostRatio: number; - DividendMaxPercentage: number; + DividendMaxRate: number; EmployeeSalaryMultiplier: number; CyclesPerEmployeeRaise: number; EmployeeRaiseAmount: number; @@ -61,7 +61,7 @@ export const CorporationConstants: { ProductProductionCostRatio: 5, //Ratio of material cost of a product to its production cost - DividendMaxPercentage: 1, + DividendMaxRate: 1, EmployeeSalaryMultiplier: 3, // Employee stats multiplied by this to determine initial salary CyclesPerEmployeeRaise: 400, // All employees get a raise every X market cycles diff --git a/src/Corporation/ui/Overview.tsx b/src/Corporation/ui/Overview.tsx index e2856867a..a873f9a92 100644 --- a/src/Corporation/ui/Overview.tsx +++ b/src/Corporation/ui/Overview.tsx @@ -275,15 +275,15 @@ interface IDividendsStatsProps { } function DividendsStats({ profit }: IDividendsStatsProps): React.ReactElement { const corp = useCorporation(); - if (corp.dividendPercentage <= 0 || profit <= 0) return <>; - const totalDividends = (corp.dividendPercentage / 100) * profit; + if (corp.dividendRate <= 0 || profit <= 0) return <>; + const totalDividends = corp.dividendRate * profit; const retainedEarnings = profit - totalDividends; const dividendsPerShare = totalDividends / corp.totalShares; return ( ], - ["Dividend Percentage:", numeralWrapper.format(corp.dividendPercentage / 100, "0%")], + ["Dividend Percentage:", numeralWrapper.format(corp.dividendRate, "0%")], ["Dividends per share:", ], ["Your earnings as a shareholder:", ], ]} diff --git a/src/Corporation/ui/modals/IssueDividendsModal.tsx b/src/Corporation/ui/modals/IssueDividendsModal.tsx index 4531faedf..110e21cc5 100644 --- a/src/Corporation/ui/modals/IssueDividendsModal.tsx +++ b/src/Corporation/ui/modals/IssueDividendsModal.tsx @@ -19,7 +19,7 @@ export function IssueDividendsModal(props: IProps): React.ReactElement { const corp = useCorporation(); const [percent, setPercent] = useState(0); - const canIssue = !isNaN(percent) && percent >= 0 && percent <= CorporationConstants.DividendMaxPercentage * 100; + const canIssue = !isNaN(percent) && percent >= 0 && percent <= CorporationConstants.DividendMaxRate * 100; function issueDividends(): void { if (!canIssue) return; if (percent === null) return;