mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-28 08:57:32 +01:00
Change corporation.dividendPercentage to corporation.dividendRate
This commit is contained in:
parent
6f017bf4f6
commit
8d474a7610
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -19,7 +19,7 @@ export interface ICorporation {
|
||||
shareSalesUntilPriceUpdate: number;
|
||||
shareSaleCooldown: number;
|
||||
issueNewSharesCooldown: number;
|
||||
dividendPercentage: number;
|
||||
dividendRate: number;
|
||||
dividendTaxPercentage: number;
|
||||
issuedShares: number;
|
||||
sharePrice: number;
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
<StatsTable
|
||||
rows={[
|
||||
["Retained Profits (after dividends):", <MoneyRate money={retainedEarnings} />],
|
||||
["Dividend Percentage:", numeralWrapper.format(corp.dividendPercentage / 100, "0%")],
|
||||
["Dividend Percentage:", numeralWrapper.format(corp.dividendRate, "0%")],
|
||||
["Dividends per share:", <MoneyRate money={dividendsPerShare} />],
|
||||
["Your earnings as a shareholder:", <MoneyRate money={corp.getDividends()} />],
|
||||
]}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user