diff --git a/src/Corporation/Corporation.tsx b/src/Corporation/Corporation.tsx index 85b196a74..d4a434d20 100644 --- a/src/Corporation/Corporation.tsx +++ b/src/Corporation/Corporation.tsx @@ -45,6 +45,8 @@ export class Corporation { upgrades: number[]; upgradeMultipliers: number[]; + avgProfit = 0; + state = new CorporationState(); constructor(params: IParams = {}) { @@ -106,6 +108,8 @@ export class Corporation { this.expenses = this.expenses + ind.lastCycleExpenses; }); const profit = this.revenue - this.expenses; + this.avgProfit = + (this.avgProfit * (CorporationConstants.AvgProfitLength - 1) + profit) / CorporationConstants.AvgProfitLength; const cycleProfit = profit * (marketCycles * CorporationConstants.SecsPerMarketCycle); if (isNaN(this.funds) || this.funds === Infinity || this.funds === -Infinity) { dialogBoxCreate( @@ -160,7 +164,7 @@ export class Corporation { determineValuation(): number { let val, - profit = this.revenue - this.expenses; + profit = this.avgProfit; if (this.public) { // Account for dividends if (this.dividendPercentage > 0) { diff --git a/src/Corporation/data/Constants.ts b/src/Corporation/data/Constants.ts index e6b5a749a..f2578454a 100644 --- a/src/Corporation/data/Constants.ts +++ b/src/Corporation/data/Constants.ts @@ -28,6 +28,7 @@ export const CorporationConstants: { AllMaterials: string[]; FundingRoundShares: number[]; FundingRoundMultiplier: number[]; + AvgProfitLength: number; } = { INITIALSHARES: 1e9, //Total number of shares you have at your company SHARESPERPRICEUPDATE: 1e6, //When selling large number of shares, price is dynamically updated for every batch of this amount @@ -83,4 +84,6 @@ export const CorporationConstants: { ], FundingRoundShares: [0.1, 0.35, 0.25, 0.2], FundingRoundMultiplier: [4, 3, 3, 2.5], + + AvgProfitLength: 20, }; diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index acd94e78d..8b86c8b8d 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -1342,6 +1342,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript (_nextBN: unknown, _callbackScript: unknown = ""): void => { const nextBN = _ctx.helper.number("nextBN", _nextBN); const callbackScript = _ctx.helper.string("callbackScript", _callbackScript); + _ctx.helper.checkSingularityAccess(); enterBitNode(Router, true, player.bitNodeN, nextBN); if (callbackScript) setTimeout(() => { @@ -1353,6 +1354,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript (_nextBN: unknown, _callbackScript: unknown = ""): void => { const nextBN = _ctx.helper.number("nextBN", _nextBN); const callbackScript = _ctx.helper.string("callbackScript", _callbackScript); + _ctx.helper.checkSingularityAccess(); const hackingRequirements = (): boolean => { const wd = GetServer(SpecialServers.WorldDaemon);