fix corp softcap

This commit is contained in:
Olivier Gagnon 2021-11-05 21:01:23 -04:00
parent 88b4a7d862
commit eb6f016ac1
12 changed files with 76 additions and 66 deletions

32
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

@ -32,6 +32,7 @@ export function StartButton(props: IProps): React.ReactElement {
if (disabled) return; if (disabled) return;
props.bladeburner.action.type = props.type; props.bladeburner.action.type = props.type;
props.bladeburner.action.name = props.name; props.bladeburner.action.name = props.name;
player.singularityStopWork();
props.bladeburner.startAction(player, props.bladeburner.action); props.bladeburner.startAction(player, props.bladeburner.action);
props.rerender(); props.rerender();
} }

@ -127,14 +127,7 @@ function getRandomReward(): ICodingContractReward {
reward.type = sanitizeRewardType(reward.type); reward.type = sanitizeRewardType(reward.type);
// Add additional information based on the reward type // Add additional information based on the reward type
const factionsThatAllowHacking = Player.factions.filter((fac) => { const factionsThatAllowHacking = Player.factions.filter((fac) => Factions[fac].getInfo().offerHackingWork);
try {
return Factions[fac].getInfo().offerHackingWork;
} catch (e) {
console.error(`Error when trying to filter Hacking Factions for Coding Contract Generation: ${e}`);
return false;
}
});
switch (reward.type) { switch (reward.type) {
case CodingContractRewardType.FactionReputation: { case CodingContractRewardType.FactionReputation: {

@ -152,7 +152,7 @@ export class Corporation {
const totalDividends = (this.dividendPercentage / 100) * cycleProfit; const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
const dividendsPerShare = totalDividends / this.totalShares; const dividendsPerShare = totalDividends / this.totalShares;
const dividends = this.numShares * dividendsPerShare * (1 - this.dividendTaxPercentage / 100); const dividends = this.numShares * dividendsPerShare * (1 - this.dividendTaxPercentage / 100);
return Math.pow(dividends, BitNodeMultipliers.CorporationSoftcap); return Math.pow(dividends, BitNodeMultipliers.CorporationSoftCap);
} }
determineValuation(): number { determineValuation(): number {

@ -47,6 +47,11 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement {
); );
} }
let color: "primary" | "info" = "primary";
if (n.researched) {
color = "info";
}
const but = ( const but = (
<Box> <Box>
<Tooltip <Tooltip
@ -59,7 +64,7 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement {
} }
> >
<span> <span>
<Button disabled={disabled} onClick={research}> <Button color={color} disabled={disabled && !n.researched} onClick={research}>
{n.text} {n.text}
</Button> </Button>
</span> </span>

@ -50,7 +50,7 @@ export function purchaseHacknet(player: IPlayer): number {
if (!player.canAfford(cost)) { if (!player.canAfford(cost)) {
return -1; return -1;
} }
player.loseMoney(cost, "hacknet"); player.loseMoney(cost, "hacknet_expenses");
player.createHacknetServer(); player.createHacknetServer();
updateHashManagerCapacity(player); updateHashManagerCapacity(player);
@ -69,7 +69,7 @@ export function purchaseHacknet(player: IPlayer): number {
const name = "hacknet-node-" + numOwned; const name = "hacknet-node-" + numOwned;
const node = new HacknetNode(name, player.hacknet_node_money_mult); const node = new HacknetNode(name, player.hacknet_node_money_mult);
player.loseMoney(cost, "hacknet"); player.loseMoney(cost, "hacknet_expenses");
player.hacknetNodes.push(node); player.hacknetNodes.push(node);
return numOwned; return numOwned;
@ -266,7 +266,7 @@ export function purchaseLevelUpgrade(player: IPlayer, node: HacknetNode | Hackne
return false; return false;
} }
player.loseMoney(cost, "hacknet"); player.loseMoney(cost, "hacknet_expenses");
node.upgradeLevel(sanitizedLevels, player.hacknet_node_money_mult); node.upgradeLevel(sanitizedLevels, player.hacknet_node_money_mult);
return true; return true;
@ -305,7 +305,7 @@ export function purchaseRamUpgrade(player: IPlayer, node: HacknetNode | HacknetS
return false; return false;
} }
player.loseMoney(cost, "hacknet"); player.loseMoney(cost, "hacknet_expenses");
node.upgradeRam(sanitizedLevels, player.hacknet_node_money_mult); node.upgradeRam(sanitizedLevels, player.hacknet_node_money_mult);
return true; return true;
@ -336,7 +336,7 @@ export function purchaseCoreUpgrade(player: IPlayer, node: HacknetNode | Hacknet
return false; return false;
} }
player.loseMoney(cost, "hacknet"); player.loseMoney(cost, "hacknet_expenses");
node.upgradeCore(sanitizedLevels, player.hacknet_node_money_mult); node.upgradeCore(sanitizedLevels, player.hacknet_node_money_mult);
return true; return true;
@ -364,7 +364,7 @@ export function purchaseCacheUpgrade(player: IPlayer, node: HacknetServer, level
return false; return false;
} }
player.loseMoney(cost, "hacknet"); player.loseMoney(cost, "hacknet_expenses");
node.upgradeCache(sanitizedLevels); node.upgradeCache(sanitizedLevels);
return true; return true;

@ -32,6 +32,7 @@ import { sprintf } from "sprintf-js";
import { parse } from "acorn"; import { parse } from "acorn";
import { simple as walksimple } from "acorn-walk"; import { simple as walksimple } from "acorn-walk";
import { areFilesEqual } from "./Terminal/DirectoryHelpers";
// Netscript Ports are instantiated here // Netscript Ports are instantiated here
export const NetscriptPorts: IPort[] = []; export const NetscriptPorts: IPort[] = [];
@ -676,38 +677,38 @@ export function runScriptFromScript(
// Check if the script exists and if it does run it // Check if the script exists and if it does run it
for (let i = 0; i < server.scripts.length; ++i) { for (let i = 0; i < server.scripts.length; ++i) {
if (server.scripts[i].filename === scriptname) { if (!areFilesEqual(server.scripts[i].filename, scriptname)) continue;
// Check for admin rights and that there is enough RAM availble to run // Check for admin rights and that there is enough RAM availble to run
const script = server.scripts[i]; const script = server.scripts[i];
let ramUsage = script.ramUsage; let ramUsage = script.ramUsage;
threads = Math.round(Number(threads)); threads = Math.round(Number(threads));
if (threads === 0) { if (threads === 0) {
return 0; return 0;
}
ramUsage = ramUsage * threads;
const ramAvailable = server.maxRam - server.ramUsed;
if (server.hasAdminRights == false) {
workerScript.log(caller, `You do not have root access on '${server.hostname}'`);
return 0;
} else if (ramUsage > ramAvailable) {
workerScript.log(
caller,
`Cannot run script '${scriptname}' (t=${threads}) on '${server.hostname}' because there is not enough available RAM!`,
);
return 0;
} else {
// Able to run script
workerScript.log(
caller,
`'${scriptname}' on '${server.hostname}' with ${threads} threads and args: ${arrayToString(args)}.`,
);
const runningScriptObj = new RunningScript(script, args);
runningScriptObj.threads = threads;
return startWorkerScript(runningScriptObj, server, workerScript);
}
} }
ramUsage = ramUsage * threads;
const ramAvailable = server.maxRam - server.ramUsed;
if (server.hasAdminRights == false) {
workerScript.log(caller, `You do not have root access on '${server.hostname}'`);
return 0;
} else if (ramUsage > ramAvailable) {
workerScript.log(
caller,
`Cannot run script '${scriptname}' (t=${threads}) on '${server.hostname}' because there is not enough available RAM!`,
);
return 0;
} else {
// Able to run script
workerScript.log(
caller,
`'${scriptname}' on '${server.hostname}' with ${threads} threads and args: ${arrayToString(args)}.`,
);
const runningScriptObj = new RunningScript(script, args);
runningScriptObj.threads = threads;
return startWorkerScript(runningScriptObj, server, workerScript);
}
break;
} }
workerScript.log(caller, `Could not find script '${scriptname}' on '${server.hostname}'`); workerScript.log(caller, `Could not find script '${scriptname}' on '${server.hostname}'`);

@ -265,3 +265,9 @@ export function evaluateFilePath(path: string, currPath?: string): string | null
return "/" + reconstructedPath.join("/"); return "/" + reconstructedPath.join("/");
} }
export function areFilesEqual(f0: string, f1: string): boolean {
if (!f0.startsWith("/")) f0 = "/" + f0;
if (!f1.startsWith("/")) f1 = "/" + f1;
return f0 === f1;
}

@ -200,6 +200,9 @@ function MoneyModal({ open, onClose }: IMoneyModalProps): React.ReactElement {
if (src.hacknet) { if (src.hacknet) {
parts.push([`Hacknet Nodes:`, <Money money={src.hacknet} />]); parts.push([`Hacknet Nodes:`, <Money money={src.hacknet} />]);
} }
if (src.hacknet_expenses) {
parts.push([`Hacknet Nodes Expenses:`, <Money money={src.hacknet_expenses} />]);
}
if (src.hospitalization) { if (src.hospitalization) {
parts.push([`Hospitalization:`, <Money money={src.hospitalization} />]); parts.push([`Hospitalization:`, <Money money={src.hospitalization} />]);
} }

@ -17,6 +17,7 @@ export class MoneySourceTracker {
gang = 0; gang = 0;
hacking = 0; hacking = 0;
hacknet = 0; hacknet = 0;
hacknet_expenses = 0;
hospitalization = 0; hospitalization = 0;
infiltration = 0; infiltration = 0;
sleeves = 0; sleeves = 0;