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

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

@ -132,9 +132,7 @@ export class Corporation {
} else {
const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
const retainedEarnings = cycleProfit - totalDividends;
const dividendsPerShare = totalDividends / this.totalShares;
const profit = this.numShares * dividendsPerShare * (1 - this.dividendTaxPercentage / 100);
player.gainMoney(profit, "corporation");
player.gainMoney(this.getDividends(), "corporation");
this.addFunds(retainedEarnings);
}
} 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 {
let val,
profit = this.revenue.minus(this.expenses).toNumber();

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

@ -221,7 +221,7 @@ function PublicButtons({ rerender }: IPublicButtonsProps): React.ReactElement {
<SellSharesModal open={sellSharesOpen} onClose={() => setSellSharesOpen(false)} rerender={rerender} />
<Tooltip title={<Typography>Buy back shares you that previously issued or sold at market price.</Typography>}>
<span>
<Button disabled={corp.issuedShares <1} onClick={() => setBuybackSharesOpen(true)}>
<Button disabled={corp.issuedShares < 1} onClick={() => setBuybackSharesOpen(true)}>
Buyback shares
</Button>
</span>
@ -289,18 +289,17 @@ function DividendsStats({ profit }: IDividendsStatsProps): React.ReactElement {
const totalDividends = (corp.dividendPercentage / 100) * profit;
const retainedEarnings = profit - totalDividends;
const dividendsPerShare = totalDividends / corp.totalShares;
const playerEarnings = corp.numShares * dividendsPerShare;
return (
<StatsTable
rows={[
["Retained Profits (after dividends):", <MoneyRate money={retainedEarnings} />],
["Dividend Percentage:", numeralWrapper.format(corp.dividendPercentage / 100, "0%")],
["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}%</>],
[
"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);
}
if (interpreter.step()) {
let more = true;
let i = 0;
while (i < 3 && more) {
more = more && interpreter.step();
i++;
}
if (more) {
setTimeout(runInterpreter, Settings.CodeInstructionRunTime);
} else {
resolve(workerScript);

@ -290,6 +290,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
return (
<Context.Player.Provider value={player}>
<Context.Router.Provider value={Router}>
<SnackbarProvider>
<Overview>
{!ITutorial.isRunning ? (
<CharacterOverview save={() => saveObject.saveGame()} killScripts={killAllScripts} />
@ -308,7 +309,6 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
) : page === Page.Work ? (
<WorkInProgressRoot />
) : (
<SnackbarProvider>
<Box display="flex" flexDirection="row" width="100%">
<SidebarRoot player={player} router={Router} page={page} />
<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>
<Snackbar />
</SnackbarProvider>
)}
<Unclickable />
<LogBoxManager />
<AlertManager />
<PromptManager />
<InvitationModal />
<Snackbar />
</SnackbarProvider>
</Context.Router.Provider>
</Context.Player.Provider>
);

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

@ -30,19 +30,4 @@ export function Snackbar(): React.ReactElement {
),
);
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>
// );
}