mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-02 12:33:56 +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 {
|
export function IssueDividends(corporation: ICorporation, rate: number): void {
|
||||||
if (isNaN(percent) || percent < 0 || percent > CorporationConstants.DividendMaxPercentage) {
|
if (isNaN(rate) || rate < 0 || rate > CorporationConstants.DividendMaxRate) {
|
||||||
throw new Error(`Invalid value. Must be an integer between 0 and ${CorporationConstants.DividendMaxPercentage}`);
|
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 {
|
export function SellMaterial(mat: Material, amt: string, price: string): void {
|
||||||
|
@ -35,8 +35,8 @@ export class Corporation {
|
|||||||
shareSalesUntilPriceUpdate = CorporationConstants.SHARESPERPRICEUPDATE;
|
shareSalesUntilPriceUpdate = CorporationConstants.SHARESPERPRICEUPDATE;
|
||||||
shareSaleCooldown = 0; // Game cycles until player can sell shares again
|
shareSaleCooldown = 0; // Game cycles until player can sell shares again
|
||||||
issueNewSharesCooldown = 0; // Game cycles until player can issue shares again
|
issueNewSharesCooldown = 0; // Game cycles until player can issue shares again
|
||||||
dividendPercentage = 0;
|
dividendRate = 0;
|
||||||
dividendTaxPercentage = 50;
|
dividendTaxPercentage = 100 - 100 * BitNodeMultipliers.CorporationSoftcap;
|
||||||
issuedShares = 0;
|
issuedShares = 0;
|
||||||
sharePrice = 0;
|
sharePrice = 0;
|
||||||
storedCycles = 0;
|
storedCycles = 0;
|
||||||
@ -121,16 +121,16 @@ export class Corporation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process dividends
|
// Process dividends
|
||||||
if (this.dividendPercentage > 0 && cycleProfit > 0) {
|
if (this.dividendRate > 0 && cycleProfit > 0) {
|
||||||
// Validate input again, just to be safe
|
// Validate input again, just to be safe
|
||||||
if (
|
if (
|
||||||
isNaN(this.dividendPercentage) ||
|
isNaN(this.dividendRate) ||
|
||||||
this.dividendPercentage < 0 ||
|
this.dividendRate < 0 ||
|
||||||
this.dividendPercentage > CorporationConstants.DividendMaxPercentage * 100
|
this.dividendRate > CorporationConstants.DividendMaxRate
|
||||||
) {
|
) {
|
||||||
console.error(`Invalid Corporation dividend percentage: ${this.dividendPercentage}`);
|
console.error(`Invalid Corporation dividend rate: ${this.dividendRate}`);
|
||||||
} else {
|
} else {
|
||||||
const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
|
const totalDividends = this.dividendRate * cycleProfit;
|
||||||
const retainedEarnings = cycleProfit - totalDividends;
|
const retainedEarnings = cycleProfit - totalDividends;
|
||||||
player.gainMoney(this.getDividends(), "corporation");
|
player.gainMoney(this.getDividends(), "corporation");
|
||||||
this.addFunds(retainedEarnings);
|
this.addFunds(retainedEarnings);
|
||||||
@ -149,7 +149,7 @@ export class Corporation {
|
|||||||
getDividends(): number {
|
getDividends(): number {
|
||||||
const profit = this.revenue - this.expenses;
|
const profit = this.revenue - this.expenses;
|
||||||
const cycleProfit = profit * CorporationConstants.SecsPerMarketCycle;
|
const cycleProfit = profit * CorporationConstants.SecsPerMarketCycle;
|
||||||
const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
|
const totalDividends = this.dividendRate * cycleProfit;
|
||||||
const dividendsPerShare = totalDividends / this.totalShares;
|
const dividendsPerShare = totalDividends / this.totalShares;
|
||||||
const dividends = this.numShares * dividendsPerShare;
|
const dividends = this.numShares * dividendsPerShare;
|
||||||
let upgrades = -0.15;
|
let upgrades = -0.15;
|
||||||
@ -167,8 +167,8 @@ export class Corporation {
|
|||||||
profit = this.avgProfit;
|
profit = this.avgProfit;
|
||||||
if (this.public) {
|
if (this.public) {
|
||||||
// Account for dividends
|
// Account for dividends
|
||||||
if (this.dividendPercentage > 0) {
|
if (this.dividendRate > 0) {
|
||||||
profit *= (100 - this.dividendPercentage) / 100;
|
profit *= 1 - this.dividendRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = this.funds + profit * 85e3;
|
val = this.funds + profit * 85e3;
|
||||||
|
@ -19,7 +19,7 @@ export interface ICorporation {
|
|||||||
shareSalesUntilPriceUpdate: number;
|
shareSalesUntilPriceUpdate: number;
|
||||||
shareSaleCooldown: number;
|
shareSaleCooldown: number;
|
||||||
issueNewSharesCooldown: number;
|
issueNewSharesCooldown: number;
|
||||||
dividendPercentage: number;
|
dividendRate: number;
|
||||||
dividendTaxPercentage: number;
|
dividendTaxPercentage: number;
|
||||||
issuedShares: number;
|
issuedShares: number;
|
||||||
sharePrice: number;
|
sharePrice: number;
|
||||||
|
@ -19,7 +19,7 @@ export const CorporationConstants: {
|
|||||||
BribeThreshold: number;
|
BribeThreshold: number;
|
||||||
BribeToRepRatio: number;
|
BribeToRepRatio: number;
|
||||||
ProductProductionCostRatio: number;
|
ProductProductionCostRatio: number;
|
||||||
DividendMaxPercentage: number;
|
DividendMaxRate: number;
|
||||||
EmployeeSalaryMultiplier: number;
|
EmployeeSalaryMultiplier: number;
|
||||||
CyclesPerEmployeeRaise: number;
|
CyclesPerEmployeeRaise: number;
|
||||||
EmployeeRaiseAmount: number;
|
EmployeeRaiseAmount: number;
|
||||||
@ -61,7 +61,7 @@ export const CorporationConstants: {
|
|||||||
|
|
||||||
ProductProductionCostRatio: 5, //Ratio of material cost of a product to its production cost
|
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
|
EmployeeSalaryMultiplier: 3, // Employee stats multiplied by this to determine initial salary
|
||||||
CyclesPerEmployeeRaise: 400, // All employees get a raise every X market cycles
|
CyclesPerEmployeeRaise: 400, // All employees get a raise every X market cycles
|
||||||
|
@ -275,15 +275,15 @@ interface IDividendsStatsProps {
|
|||||||
}
|
}
|
||||||
function DividendsStats({ profit }: IDividendsStatsProps): React.ReactElement {
|
function DividendsStats({ profit }: IDividendsStatsProps): React.ReactElement {
|
||||||
const corp = useCorporation();
|
const corp = useCorporation();
|
||||||
if (corp.dividendPercentage <= 0 || profit <= 0) return <></>;
|
if (corp.dividendRate <= 0 || profit <= 0) return <></>;
|
||||||
const totalDividends = (corp.dividendPercentage / 100) * profit;
|
const totalDividends = corp.dividendRate * profit;
|
||||||
const retainedEarnings = profit - totalDividends;
|
const retainedEarnings = profit - totalDividends;
|
||||||
const dividendsPerShare = totalDividends / corp.totalShares;
|
const dividendsPerShare = totalDividends / corp.totalShares;
|
||||||
return (
|
return (
|
||||||
<StatsTable
|
<StatsTable
|
||||||
rows={[
|
rows={[
|
||||||
["Retained Profits (after dividends):", <MoneyRate money={retainedEarnings} />],
|
["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} />],
|
["Dividends per share:", <MoneyRate money={dividendsPerShare} />],
|
||||||
["Your earnings as a shareholder:", <MoneyRate money={corp.getDividends()} />],
|
["Your earnings as a shareholder:", <MoneyRate money={corp.getDividends()} />],
|
||||||
]}
|
]}
|
||||||
|
@ -19,7 +19,7 @@ export function IssueDividendsModal(props: IProps): React.ReactElement {
|
|||||||
const corp = useCorporation();
|
const corp = useCorporation();
|
||||||
const [percent, setPercent] = useState(0);
|
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 {
|
function issueDividends(): void {
|
||||||
if (!canIssue) return;
|
if (!canIssue) return;
|
||||||
if (percent === null) return;
|
if (percent === null) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user