speed up ns1

This commit is contained in:
Olivier Gagnon 2021-11-05 14:32:21 -04:00
parent 362d2eb51d
commit d83650c3bc
12 changed files with 79 additions and 71 deletions

34
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -567,6 +567,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.FactionWorkRepGain = 0.5; BitNodeMultipliers.FactionWorkRepGain = 0.5;
BitNodeMultipliers.FactionPassiveRepGain = 0; BitNodeMultipliers.FactionPassiveRepGain = 0;
BitNodeMultipliers.PurchasedServerSoftcap = 1.3; BitNodeMultipliers.PurchasedServerSoftcap = 1.3;
BitNodeMultipliers.CorporationSoftCap = 0.9;
break; break;
case 3: // Corporatocracy case 3: // Corporatocracy
BitNodeMultipliers.HackingLevelMultiplier = 0.8; BitNodeMultipliers.HackingLevelMultiplier = 0.8;
@ -630,6 +631,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.DaedalusAugsRequirement = 1.166; // Results in 35 Augs needed BitNodeMultipliers.DaedalusAugsRequirement = 1.166; // Results in 35 Augs needed
BitNodeMultipliers.PurchasedServerSoftcap = 2; BitNodeMultipliers.PurchasedServerSoftcap = 2;
BitNodeMultipliers.GangSoftcap = 0.7; BitNodeMultipliers.GangSoftcap = 0.7;
BitNodeMultipliers.CorporationSoftCap = 0.9;
break; break;
case 7: // Bladeburner 2079 case 7: // Bladeburner 2079
BitNodeMultipliers.BladeburnerRank = 0.6; BitNodeMultipliers.BladeburnerRank = 0.6;
@ -652,6 +654,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.DaedalusAugsRequirement = 1.166; // Results in 35 Augs needed BitNodeMultipliers.DaedalusAugsRequirement = 1.166; // Results in 35 Augs needed
BitNodeMultipliers.PurchasedServerSoftcap = 2; BitNodeMultipliers.PurchasedServerSoftcap = 2;
BitNodeMultipliers.GangSoftcap = 0.7; BitNodeMultipliers.GangSoftcap = 0.7;
BitNodeMultipliers.CorporationSoftCap = 0.9;
break; break;
case 8: // Ghost of Wall Street case 8: // Ghost of Wall Street
BitNodeMultipliers.ScriptHackMoney = 0.3; BitNodeMultipliers.ScriptHackMoney = 0.3;
@ -666,6 +669,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.CodingContractMoney = 0; BitNodeMultipliers.CodingContractMoney = 0;
BitNodeMultipliers.PurchasedServerSoftcap = 4; BitNodeMultipliers.PurchasedServerSoftcap = 4;
BitNodeMultipliers.GangSoftcap = 0; BitNodeMultipliers.GangSoftcap = 0;
BitNodeMultipliers.CorporationSoftCap = 0;
break; break;
case 9: // Hacktocracy case 9: // Hacktocracy
BitNodeMultipliers.HackingLevelMultiplier = 0.4; BitNodeMultipliers.HackingLevelMultiplier = 0.4;
@ -688,6 +692,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.BladeburnerRank = 0.9; BitNodeMultipliers.BladeburnerRank = 0.9;
BitNodeMultipliers.BladeburnerSkillCost = 1.2; BitNodeMultipliers.BladeburnerSkillCost = 1.2;
BitNodeMultipliers.GangSoftcap = 0.8; BitNodeMultipliers.GangSoftcap = 0.8;
BitNodeMultipliers.CorporationSoftCap = 0.9;
break; break;
case 10: // Digital Carbon case 10: // Digital Carbon
BitNodeMultipliers.HackingLevelMultiplier = 0.2; BitNodeMultipliers.HackingLevelMultiplier = 0.2;
@ -713,6 +718,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.BladeburnerRank = 0.8; BitNodeMultipliers.BladeburnerRank = 0.8;
BitNodeMultipliers.PurchasedServerSoftcap = 1.1; BitNodeMultipliers.PurchasedServerSoftcap = 1.1;
BitNodeMultipliers.GangSoftcap = 0.9; BitNodeMultipliers.GangSoftcap = 0.9;
BitNodeMultipliers.CorporationSoftCap = 0.9;
break; break;
case 11: //The Big Crash case 11: //The Big Crash
BitNodeMultipliers.HackingLevelMultiplier = 0.5; BitNodeMultipliers.HackingLevelMultiplier = 0.5;
@ -732,6 +738,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.FourSigmaMarketDataCost = 4; BitNodeMultipliers.FourSigmaMarketDataCost = 4;
BitNodeMultipliers.FourSigmaMarketDataApiCost = 4; BitNodeMultipliers.FourSigmaMarketDataApiCost = 4;
BitNodeMultipliers.PurchasedServerSoftcap = 2; BitNodeMultipliers.PurchasedServerSoftcap = 2;
BitNodeMultipliers.CorporationSoftCap = 0.9;
break; break;
case 12: { case 12: {
//The Recursion //The Recursion
@ -800,7 +807,8 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.BladeburnerRank = dec; BitNodeMultipliers.BladeburnerRank = dec;
BitNodeMultipliers.BladeburnerSkillCost = inc; BitNodeMultipliers.BladeburnerSkillCost = inc;
BitNodeMultipliers.GangSoftcap = dec; BitNodeMultipliers.GangSoftcap = 0.8;
BitNodeMultipliers.CorporationSoftCap = 0.8;
break; break;
} }
default: default:

@ -274,6 +274,7 @@ export const BitNodeMultipliers: IBitNodeMultipliers = {
FourSigmaMarketDataApiCost: 1, FourSigmaMarketDataApiCost: 1,
CorporationValuation: 1, CorporationValuation: 1,
CorporationSoftCap: 1,
BladeburnerRank: 1, BladeburnerRank: 1,
BladeburnerSkillCost: 1, BladeburnerSkillCost: 1,

@ -132,9 +132,7 @@ export class Corporation {
} else { } else {
const totalDividends = (this.dividendPercentage / 100) * cycleProfit; const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
const retainedEarnings = cycleProfit - totalDividends; const retainedEarnings = cycleProfit - totalDividends;
const dividendsPerShare = totalDividends / this.totalShares; player.gainMoney(this.getDividends(), "corporation");
const profit = this.numShares * dividendsPerShare * (1 - this.dividendTaxPercentage / 100);
player.gainMoney(profit, "corporation");
this.addFunds(retainedEarnings); this.addFunds(retainedEarnings);
} }
} else { } else {
@ -148,6 +146,15 @@ export class Corporation {
} }
} }
getDividends(): number {
const profit = this.revenue.minus(this.expenses);
const cycleProfit = profit.times(CorporationConstants.SecsPerMarketCycle);
const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
const dividendsPerShare = totalDividends / this.totalShares;
const dividends = this.numShares * dividendsPerShare * (1 - this.dividendTaxPercentage / 100);
return Math.pow(dividends, BitNodeMultipliers.CorporationSoftcap);
}
determineValuation(): number { determineValuation(): number {
let val, let val,
profit = this.revenue.minus(this.expenses).toNumber(); profit = this.revenue.minus(this.expenses).toNumber();

@ -55,4 +55,5 @@ export interface ICorporation {
getScientificResearchMultiplier(): number; getScientificResearchMultiplier(): number;
getStarterGuide(player: IPlayer): void; getStarterGuide(player: IPlayer): void;
toJSON(): any; toJSON(): any;
getDividends(): number;
} }

@ -221,7 +221,7 @@ function PublicButtons({ rerender }: IPublicButtonsProps): React.ReactElement {
<SellSharesModal open={sellSharesOpen} onClose={() => setSellSharesOpen(false)} rerender={rerender} /> <SellSharesModal open={sellSharesOpen} onClose={() => setSellSharesOpen(false)} rerender={rerender} />
<Tooltip title={<Typography>Buy back shares you that previously issued or sold at market price.</Typography>}> <Tooltip title={<Typography>Buy back shares you that previously issued or sold at market price.</Typography>}>
<span> <span>
<Button disabled={corp.issuedShares <1} onClick={() => setBuybackSharesOpen(true)}> <Button disabled={corp.issuedShares < 1} onClick={() => setBuybackSharesOpen(true)}>
Buyback shares Buyback shares
</Button> </Button>
</span> </span>
@ -289,18 +289,17 @@ function DividendsStats({ profit }: IDividendsStatsProps): React.ReactElement {
const totalDividends = (corp.dividendPercentage / 100) * profit; const totalDividends = (corp.dividendPercentage / 100) * profit;
const retainedEarnings = profit - totalDividends; const retainedEarnings = profit - totalDividends;
const dividendsPerShare = totalDividends / corp.totalShares; const dividendsPerShare = totalDividends / corp.totalShares;
const playerEarnings = corp.numShares * dividendsPerShare;
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.dividendPercentage / 100, "0%")],
["Dividends per share:", <MoneyRate money={dividendsPerShare} />], ["Dividends per share:", <MoneyRate money={dividendsPerShare} />],
["Your earnings as a shareholder (Pre-Tax):", <MoneyRate money={playerEarnings} />], ["Your earnings as a shareholder (Pre-Tax):", <MoneyRate money={corp.getDividends()} />],
["Dividend Tax Rate:", <>{corp.dividendTaxPercentage}%</>], ["Dividend Tax Rate:", <>{corp.dividendTaxPercentage}%</>],
[ [
"Your earnings as a shareholder (Post-Tax):", "Your earnings as a shareholder (Post-Tax):",
<MoneyRate money={playerEarnings * (1 - corp.dividendTaxPercentage / 100)} />, <MoneyRate money={corp.getDividends() * (1 - corp.dividendTaxPercentage / 100)} />,
], ],
]} ]}
/> />

@ -266,7 +266,14 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
return reject(workerScript); return reject(workerScript);
} }
if (interpreter.step()) { let more = true;
let i = 0;
while (i < 3 && more) {
more = more && interpreter.step();
i++;
}
if (more) {
setTimeout(runInterpreter, Settings.CodeInstructionRunTime); setTimeout(runInterpreter, Settings.CodeInstructionRunTime);
} else { } else {
resolve(workerScript); resolve(workerScript);

@ -290,25 +290,25 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
return ( return (
<Context.Player.Provider value={player}> <Context.Player.Provider value={player}>
<Context.Router.Provider value={Router}> <Context.Router.Provider value={Router}>
<Overview> <SnackbarProvider>
{!ITutorial.isRunning ? ( <Overview>
<CharacterOverview save={() => saveObject.saveGame()} killScripts={killAllScripts} /> {!ITutorial.isRunning ? (
<CharacterOverview save={() => saveObject.saveGame()} killScripts={killAllScripts} />
) : (
<InteractiveTutorialRoot />
)}
</Overview>
{page === Page.Recovery ? (
<RecoveryRoot router={Router} />
) : page === Page.BitVerse ? (
<BitverseRoot flume={flume} enter={enterBitNode} quick={quick} />
) : page === Page.Infiltration ? (
<InfiltrationRoot location={location} />
) : page === Page.BladeburnerCinematic ? (
<BladeburnerCinematic />
) : page === Page.Work ? (
<WorkInProgressRoot />
) : ( ) : (
<InteractiveTutorialRoot />
)}
</Overview>
{page === Page.Recovery ? (
<RecoveryRoot router={Router} />
) : page === Page.BitVerse ? (
<BitverseRoot flume={flume} enter={enterBitNode} quick={quick} />
) : page === Page.Infiltration ? (
<InfiltrationRoot location={location} />
) : page === Page.BladeburnerCinematic ? (
<BladeburnerCinematic />
) : page === Page.Work ? (
<WorkInProgressRoot />
) : (
<SnackbarProvider>
<Box display="flex" flexDirection="row" width="100%"> <Box display="flex" flexDirection="row" width="100%">
<SidebarRoot player={player} router={Router} page={page} /> <SidebarRoot player={player} router={Router} page={page} />
<Box className={classes.root} flexGrow={1} display="block" px={1} height="100vh"> <Box className={classes.root} flexGrow={1} display="block" px={1} height="100vh">
@ -401,14 +401,14 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
)} )}
</Box> </Box>
</Box> </Box>
<Snackbar /> )}
</SnackbarProvider> <Unclickable />
)} <LogBoxManager />
<Unclickable /> <AlertManager />
<LogBoxManager /> <PromptManager />
<AlertManager /> <InvitationModal />
<PromptManager /> <Snackbar />
<InvitationModal /> </SnackbarProvider>
</Context.Router.Provider> </Context.Router.Provider>
</Context.Player.Provider> </Context.Player.Provider>
); );

@ -229,7 +229,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
value={execTime} value={execTime}
onChange={handleExecTimeChange} onChange={handleExecTimeChange}
step={1} step={1}
min={10} min={5}
max={100} max={100}
valueLabelDisplay="auto" valueLabelDisplay="auto"
/> />

@ -30,19 +30,4 @@ export function Snackbar(): React.ReactElement {
), ),
); );
return <></>; return <></>;
// return (
// <S
// open={open}
// anchorOrigin={{
// vertical: "top",
// horizontal: "center",
// }}
// autoHideDuration={2000}
// onClose={() => setOpen(false)}
// >
// <Paper sx={{ p: 2 }}>
// <Typography>Game Saved!</Typography>
// </Paper>
// </S>
// );
} }