Merge pull request #1729 from danielyxie/dev

plenty of bf
This commit is contained in:
hydroflame 2021-11-15 23:49:47 -05:00 committed by GitHub
commit b222b1ecbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 213 additions and 115 deletions

26
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

@ -86,7 +86,7 @@ export function SellMaterial(mat: Material, amt: string, price: string): void {
if (price === "") price = "0"; if (price === "") price = "0";
if (amt === "") amt = "0"; if (amt === "") amt = "0";
let cost = price.replace(/\s+/g, ""); let cost = price.replace(/\s+/g, "");
cost = cost.replace(/[^-()\d/*+.MP]/g, ""); //Sanitize cost cost = cost.replace(/[^-()\d/*+.MPe]/g, ""); //Sanitize cost
let temp = cost.replace(/MP/g, mat.bCost + ""); let temp = cost.replace(/MP/g, mat.bCost + "");
try { try {
temp = eval(temp); temp = eval(temp);

@ -19,6 +19,7 @@ import {
import { createRandomIp } from "../utils/IPAddress"; import { createRandomIp } from "../utils/IPAddress";
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
import { IPlayer } from "../PersonObjects/IPlayer";
interface IConstructorParams { interface IConstructorParams {
adminRights?: boolean; adminRights?: boolean;
@ -122,6 +123,11 @@ export class HacknetServer extends BaseServer implements IHacknetNode {
} }
} }
updateRamUsed(ram: number, player: IPlayer): void {
super.updateRamUsed(ram, player);
this.updateHashRate(player.hacknet_node_money_mult);
}
updateHashCapacity(): void { updateHashCapacity(): void {
this.hashCapacity = 32 * Math.pow(2, this.cache); this.hashCapacity = 32 * Math.pow(2, this.cache);
} }

@ -28,7 +28,9 @@ import { TableCell } from "../../ui/React/Table";
import TableBody from "@mui/material/TableBody"; import TableBody from "@mui/material/TableBody";
import Table from "@mui/material/Table"; import Table from "@mui/material/Table";
import TableRow from "@mui/material/TableRow"; import TableRow from "@mui/material/TableRow";
import Tooltip from "@mui/material/Tooltip";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { calculateMoneyGainRate } from "../formulas/HacknetNodes";
interface IProps { interface IProps {
node: HacknetNode; node: HacknetNode;
@ -43,9 +45,9 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
const rerender = props.rerender; const rerender = props.rerender;
// Upgrade Level Button // Upgrade Level Button
let upgradeLevelContent; let upgradeLevelButton;
if (node.level >= HacknetNodeConstants.MaxLevel) { if (node.level >= HacknetNodeConstants.MaxLevel) {
upgradeLevelContent = <>MAX LEVEL</>; upgradeLevelButton = <Button disabled>MAX LEVEL</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -55,12 +57,23 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
multiplier = Math.min(levelsToMax, purchaseMult as number); multiplier = Math.min(levelsToMax, purchaseMult as number);
} }
const increase =
calculateMoneyGainRate(node.level + multiplier, node.ram, node.cores, props.player.hacknet_node_money_mult) -
node.moneyGainRatePerSecond;
const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, props.player.hacknet_node_level_cost_mult); const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, props.player.hacknet_node_level_cost_mult);
upgradeLevelContent = ( upgradeLevelButton = (
<> <Tooltip
+{multiplier} -&nbsp; title={
<Money money={upgradeLevelCost} player={props.player} /> <Typography>
</> +<MoneyRate money={increase} />
</Typography>
}
>
<Button onClick={upgradeLevelOnClick}>
+{multiplier} -&nbsp;
<Money money={upgradeLevelCost} player={props.player} />
</Button>
</Tooltip>
); );
} }
function upgradeLevelOnClick(): void { function upgradeLevelOnClick(): void {
@ -72,9 +85,9 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
rerender(); rerender();
} }
let upgradeRamContent; let upgradeRAMButton;
if (node.ram >= HacknetNodeConstants.MaxRam) { if (node.ram >= HacknetNodeConstants.MaxRam) {
upgradeRamContent = <>MAX RAM</>; upgradeRAMButton = <Button disabled>MAX RAM</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -84,12 +97,27 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
multiplier = Math.min(levelsToMax, purchaseMult as number); multiplier = Math.min(levelsToMax, purchaseMult as number);
} }
const increase =
calculateMoneyGainRate(
node.level,
node.ram * Math.pow(2, multiplier),
node.cores,
props.player.hacknet_node_money_mult,
) - node.moneyGainRatePerSecond;
const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, props.player.hacknet_node_ram_cost_mult); const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, props.player.hacknet_node_ram_cost_mult);
upgradeRamContent = ( upgradeRAMButton = (
<> <Tooltip
+{multiplier} -&nbsp; title={
<Money money={upgradeRamCost} player={props.player} /> <Typography>
</> +<MoneyRate money={increase} />
</Typography>
}
>
<Button onClick={upgradeRamOnClick}>
+{multiplier} -&nbsp;
<Money money={upgradeRamCost} player={props.player} />
</Button>
</Tooltip>
); );
} }
function upgradeRamOnClick(): void { function upgradeRamOnClick(): void {
@ -99,9 +127,17 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
rerender(); rerender();
} }
let upgradeCoresContent; function upgradeCoresOnClick(): void {
const numUpgrades =
purchaseMult === "MAX"
? getMaxNumberCoreUpgrades(props.player, node, HacknetNodeConstants.MaxCores)
: purchaseMult;
purchaseCoreUpgrade(props.player, node, numUpgrades);
rerender();
}
let upgradeCoresButton;
if (node.cores >= HacknetNodeConstants.MaxCores) { if (node.cores >= HacknetNodeConstants.MaxCores) {
upgradeCoresContent = <>MAX CORES</>; upgradeCoresButton = <Button disabled>MAX CORES</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -111,22 +147,25 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
multiplier = Math.min(levelsToMax, purchaseMult as number); multiplier = Math.min(levelsToMax, purchaseMult as number);
} }
const increase =
calculateMoneyGainRate(node.level, node.ram, node.cores + multiplier, props.player.hacknet_node_money_mult) -
node.moneyGainRatePerSecond;
const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult); const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult);
upgradeCoresContent = ( upgradeCoresButton = (
<> <Tooltip
+{multiplier} -&nbsp; title={
<Money money={upgradeCoreCost} player={props.player} /> <Typography>
</> +<MoneyRate money={increase} />
</Typography>
}
>
<Button onClick={upgradeCoresOnClick}>
+{multiplier} -&nbsp;
<Money money={upgradeCoreCost} player={props.player} />
</Button>
</Tooltip>
); );
} }
function upgradeCoresOnClick(): void {
const numUpgrades =
purchaseMult === "MAX"
? getMaxNumberCoreUpgrades(props.player, node, HacknetNodeConstants.MaxCores)
: purchaseMult;
purchaseCoreUpgrade(props.player, node, numUpgrades);
rerender();
}
return ( return (
<Grid item component={Paper} p={1}> <Grid item component={Paper} p={1}>
@ -155,9 +194,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{node.level}</Typography> <Typography>{node.level}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeLevelButton}</TableCell>
<Button onClick={upgradeLevelOnClick}>{upgradeLevelContent}</Button>
</TableCell>
</TableRow> </TableRow>
<TableRow> <TableRow>
<TableCell> <TableCell>
@ -166,9 +203,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{numeralWrapper.formatRAM(node.ram)}</Typography> <Typography>{numeralWrapper.formatRAM(node.ram)}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeRAMButton}</TableCell>
<Button onClick={upgradeRamOnClick}>{upgradeRamContent}</Button>
</TableCell>
</TableRow> </TableRow>
<TableRow> <TableRow>
<TableCell> <TableCell>
@ -177,9 +212,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{node.cores}</Typography> <Typography>{node.cores}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeCoresButton}</TableCell>
<Button onClick={upgradeCoresOnClick}>{upgradeCoresContent}</Button>
</TableCell>
</TableRow> </TableRow>
</TableBody> </TableBody>
</Table> </Table>

@ -32,6 +32,8 @@ import TableBody from "@mui/material/TableBody";
import Table from "@mui/material/Table"; import Table from "@mui/material/Table";
import TableRow from "@mui/material/TableRow"; import TableRow from "@mui/material/TableRow";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { calculateHashGainRate } from "../formulas/HacknetServers";
import Tooltip from "@mui/material/Tooltip";
interface IProps { interface IProps {
node: HacknetServer; node: HacknetServer;
@ -46,9 +48,9 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
const rerender = props.rerender; const rerender = props.rerender;
// Upgrade Level Button // Upgrade Level Button
let upgradeLevelContent; let upgradeLevelButton;
if (node.level >= HacknetServerConstants.MaxLevel) { if (node.level >= HacknetServerConstants.MaxLevel) {
upgradeLevelContent = <>MAX LEVEL</>; upgradeLevelButton = <Button disabled>MAX LEVEL</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -58,12 +60,23 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
multiplier = Math.min(levelsToMax, purchaseMult as number); multiplier = Math.min(levelsToMax, purchaseMult as number);
} }
const increase =
calculateHashGainRate(node.level + multiplier, 0, node.maxRam, node.cores, props.player.hacknet_node_money_mult) -
node.hashRate;
const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, props.player.hacknet_node_level_cost_mult); const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, props.player.hacknet_node_level_cost_mult);
upgradeLevelContent = ( upgradeLevelButton = (
<> <Tooltip
+{multiplier}&nbsp;-&nbsp; title={
<Money money={upgradeLevelCost} player={props.player} /> <Typography>
</> +<HashRate hashes={increase} />
</Typography>
}
>
<Button onClick={upgradeLevelOnClick}>
+{multiplier}&nbsp;-&nbsp;
<Money money={upgradeLevelCost} player={props.player} />
</Button>
</Tooltip>
); );
} }
function upgradeLevelOnClick(): void { function upgradeLevelOnClick(): void {
@ -75,10 +88,18 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
rerender(); rerender();
} }
function upgradeRamOnClick(): void {
let numUpgrades = purchaseMult;
if (purchaseMult === "MAX") {
numUpgrades = getMaxNumberRamUpgrades(props.player, node, HacknetServerConstants.MaxRam);
}
purchaseRamUpgrade(props.player, node, numUpgrades as number);
rerender();
}
// Upgrade RAM Button // Upgrade RAM Button
let upgradeRamContent; let upgradeRamButton;
if (node.maxRam >= HacknetServerConstants.MaxRam) { if (node.maxRam >= HacknetServerConstants.MaxRam) {
upgradeRamContent = <>MAX RAM</>; upgradeRamButton = <Button disabled>MAX RAM</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -88,27 +109,43 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
multiplier = Math.min(levelsToMax, purchaseMult as number); multiplier = Math.min(levelsToMax, purchaseMult as number);
} }
const increase =
calculateHashGainRate(
node.level,
0,
node.maxRam * Math.pow(2, multiplier),
node.cores,
props.player.hacknet_node_money_mult,
) - node.hashRate;
const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, props.player.hacknet_node_ram_cost_mult); const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, props.player.hacknet_node_ram_cost_mult);
upgradeRamContent = ( upgradeRamButton = (
<> <Tooltip
+{multiplier}&nbsp;-&nbsp; title={
<Money money={upgradeRamCost} player={props.player} /> <Typography>
</> +<HashRate hashes={increase} />
</Typography>
}
>
<Button onClick={upgradeRamOnClick}>
+{multiplier}&nbsp;-&nbsp;
<Money money={upgradeRamCost} player={props.player} />
</Button>
</Tooltip>
); );
} }
function upgradeRamOnClick(): void {
function upgradeCoresOnClick(): void {
let numUpgrades = purchaseMult; let numUpgrades = purchaseMult;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
numUpgrades = getMaxNumberRamUpgrades(props.player, node, HacknetServerConstants.MaxRam); numUpgrades = getMaxNumberCoreUpgrades(props.player, node, HacknetServerConstants.MaxCores);
} }
purchaseRamUpgrade(props.player, node, numUpgrades as number); purchaseCoreUpgrade(props.player, node, numUpgrades as number);
rerender(); rerender();
} }
// Upgrade Cores Button // Upgrade Cores Button
let upgradeCoresContent; let upgradeCoresButton;
if (node.cores >= HacknetServerConstants.MaxCores) { if (node.cores >= HacknetServerConstants.MaxCores) {
upgradeCoresContent = <>MAX CORES</>; upgradeCoresButton = <Button disabled>MAX CORES</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -118,27 +155,30 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
multiplier = Math.min(levelsToMax, purchaseMult as number); multiplier = Math.min(levelsToMax, purchaseMult as number);
} }
const increase =
calculateHashGainRate(node.level, 0, node.maxRam, node.cores + multiplier, props.player.hacknet_node_money_mult) -
node.hashRate;
const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult); const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult);
upgradeCoresContent = ( upgradeCoresButton = (
<> <Tooltip
+{multiplier}&nbsp;-&nbsp; title={
<Money money={upgradeCoreCost} player={props.player} /> <Typography>
</> +<HashRate hashes={increase} />
</Typography>
}
>
<Button onClick={upgradeCoresOnClick}>
+{multiplier}&nbsp;-&nbsp;
<Money money={upgradeCoreCost} player={props.player} />
</Button>
</Tooltip>
); );
} }
function upgradeCoresOnClick(): void {
let numUpgrades = purchaseMult;
if (purchaseMult === "MAX") {
numUpgrades = getMaxNumberCoreUpgrades(props.player, node, HacknetServerConstants.MaxCores);
}
purchaseCoreUpgrade(props.player, node, numUpgrades as number);
rerender();
}
// Upgrade Cache button // Upgrade Cache button
let upgradeCacheContent; let upgradeCacheButton;
if (node.cache >= HacknetServerConstants.MaxCache) { if (node.cache >= HacknetServerConstants.MaxCache) {
upgradeCacheContent = <>MAX CACHE</>; upgradeCacheButton = <Button disabled>MAX CACHE</Button>;
} else { } else {
let multiplier = 0; let multiplier = 0;
if (purchaseMult === "MAX") { if (purchaseMult === "MAX") {
@ -149,11 +189,19 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
} }
const upgradeCacheCost = node.calculateCacheUpgradeCost(multiplier); const upgradeCacheCost = node.calculateCacheUpgradeCost(multiplier);
upgradeCacheContent = ( upgradeCacheButton = (
<> <Tooltip
+{multiplier}&nbsp;-&nbsp; title={
<Money money={upgradeCacheCost} player={props.player} /> <Typography>
</> +<Hashes hashes={32 * Math.pow(2, node.cache)} /> hashes
</Typography>
}
>
<Button onClick={upgradeCacheOnClick}>
+{multiplier}&nbsp;-&nbsp;
<Money money={upgradeCacheCost} player={props.player} />
</Button>
</Tooltip>
); );
if (props.player.money < upgradeCacheCost) { if (props.player.money < upgradeCacheCost) {
} else { } else {
@ -205,9 +253,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{node.level}</Typography> <Typography>{node.level}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeLevelButton}</TableCell>
<Button onClick={upgradeLevelOnClick}>{upgradeLevelContent}</Button>
</TableCell>
</TableRow> </TableRow>
<TableRow> <TableRow>
<TableCell> <TableCell>
@ -216,9 +262,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{numeralWrapper.formatRAM(node.maxRam)}</Typography> <Typography>{numeralWrapper.formatRAM(node.maxRam)}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeRamButton}</TableCell>
<Button onClick={upgradeRamOnClick}>{upgradeRamContent}</Button>
</TableCell>
</TableRow> </TableRow>
<TableRow> <TableRow>
<TableCell> <TableCell>
@ -227,9 +271,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{node.cores}</Typography> <Typography>{node.cores}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeCoresButton}</TableCell>
<Button onClick={upgradeCoresOnClick}>{upgradeCoresContent}</Button>
</TableCell>
</TableRow> </TableRow>
<TableRow> <TableRow>
<TableCell> <TableCell>
@ -238,9 +280,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
<TableCell> <TableCell>
<Typography>{node.cache}</Typography> <Typography>{node.cache}</Typography>
</TableCell> </TableCell>
<TableCell> <TableCell>{upgradeCacheButton}</TableCell>
<Button onClick={upgradeCacheOnClick}>{upgradeCacheContent}</Button>
</TableCell>
</TableRow> </TableRow>
</TableBody> </TableBody>
</Table> </Table>

@ -12,6 +12,7 @@ import { GetServer } from "../Server/AllServers";
import { compareArrays } from "../utils/helpers/compareArrays"; import { compareArrays } from "../utils/helpers/compareArrays";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
import { AddRecentScript } from "./RecentScripts"; import { AddRecentScript } from "./RecentScripts";
import { Player } from "../Player";
export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean; export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean;
export function killWorkerScript(workerScript: WorkerScript): boolean; export function killWorkerScript(workerScript: WorkerScript): boolean;
@ -110,8 +111,9 @@ function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void
} }
// Recalculate ram used on that server // Recalculate ram used on that server
server.ramUsed = 0;
for (const rs of server.runningScripts) server.ramUsed += rs.ramUsage * rs.threads; server.updateRamUsed(0, Player);
for (const rs of server.runningScripts) server.updateRamUsed(server.ramUsed + rs.ramUsage * rs.threads, Player);
// Delete script from global pool (workerScripts) // Delete script from global pool (workerScripts)
const res = workerScripts.delete(workerScript.pid); const res = workerScripts.delete(workerScript.pid);

@ -33,6 +33,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"; import { areFilesEqual } from "./Terminal/DirectoryHelpers";
import { Player } from "./Player";
// Netscript Ports are instantiated here // Netscript Ports are instantiated here
export const NetscriptPorts: IPort[] = []; export const NetscriptPorts: IPort[] = [];
@ -490,7 +491,8 @@ function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseS
); );
return false; return false;
} }
server.ramUsed = roundToTwo(server.ramUsed + ramUsage);
server.updateRamUsed(roundToTwo(server.ramUsed + ramUsage), Player);
// Get the pid // Get the pid
const pid = generateNextPid(); const pid = generateNextPid();

@ -854,7 +854,7 @@ export function startFactionHackWork(this: IPlayer, router: IRouter, faction: Fa
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkHacking); this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkHacking);
this.workHackExpGainRate = 0.15 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workHackExpGainRate = 0.15 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction); this.workRepGainRate = getHackingWorkRepGain(this, faction);
this.factionWorkType = CONSTANTS.FactionWorkHacking; this.factionWorkType = CONSTANTS.FactionWorkHacking;
this.currentWorkFactionDescription = "carrying out hacking contracts"; this.currentWorkFactionDescription = "carrying out hacking contracts";
@ -872,6 +872,7 @@ export function startFactionFieldWork(this: IPlayer, router: IRouter, faction: F
this.workAgiExpGainRate = 0.1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workAgiExpGainRate = 0.1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
this.workChaExpGainRate = 0.1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain; this.workChaExpGainRate = 0.1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction); this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
console.log(this.workRepGainRate);
this.factionWorkType = CONSTANTS.FactionWorkField; this.factionWorkType = CONSTANTS.FactionWorkField;
this.currentWorkFactionDescription = "carrying out field missions"; this.currentWorkFactionDescription = "carrying out field missions";
@ -906,6 +907,7 @@ export function workForFaction(this: IPlayer, numCycles: number): boolean {
break; break;
case CONSTANTS.FactionWorkField: case CONSTANTS.FactionWorkField:
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction); this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
console.log(this.workRepGainRate);
break; break;
case CONSTANTS.FactionWorkSecurity: case CONSTANTS.FactionWorkSecurity:
this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction); this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction);
@ -913,6 +915,12 @@ export function workForFaction(this: IPlayer, numCycles: number): boolean {
default: default:
break; break;
} }
let favorMult = 1 + faction.favor / 100;
if (isNaN(favorMult)) {
favorMult = 1;
}
this.workRepGainRate *= favorMult;
this.workRepGainRate *= BitNodeMultipliers.FactionWorkRepGain;
//Cap the number of cycles being processed to whatever would put you at limit (20 hours) //Cap the number of cycles being processed to whatever would put you at limit (20 hours)
let overMax = false; let overMax = false;

@ -1992,7 +1992,7 @@ export interface Singularity {
* *
* @returns True if the installation was successful. * @returns True if the installation was successful.
*/ */
installBackdoor(): Promise<boolean>; installBackdoor(): Promise<void>;
} }
/** /**
@ -3607,7 +3607,7 @@ export interface NS extends Singularity {
* @param growthAmount - Multiplicative factor by which the server is grown. Decimal form.. * @param growthAmount - Multiplicative factor by which the server is grown. Decimal form..
* @returns The amount of grow calls needed to grow the specified server by the specified amount * @returns The amount of grow calls needed to grow the specified server by the specified amount
*/ */
growthAnalyze(host: string, growthAmount: number): number; growthAnalyze(host: string, growthAmount: number, cores?: number): number;
/** /**
* Calculate the security increase for a number of thread. * Calculate the security increase for a number of thread.

@ -12,6 +12,7 @@ import { isScriptFilename } from "../Script/isScriptFilename";
import { createRandomIp } from "../utils/IPAddress"; import { createRandomIp } from "../utils/IPAddress";
import { compareArrays } from "../utils/helpers/compareArrays"; import { compareArrays } from "../utils/helpers/compareArrays";
import { IPlayer } from "../PersonObjects/IPlayer";
interface IConstructorParams { interface IConstructorParams {
adminRights?: boolean; adminRights?: boolean;
@ -245,6 +246,10 @@ export class BaseServer {
this.maxRam = ram; this.maxRam = ram;
} }
updateRamUsed(ram: number, player: IPlayer): void {
this.ramUsed = ram;
}
/** /**
* Write to a script file * Write to a script file
* Overwrites existing files. Creates new files if the script does not eixst * Overwrites existing files. Creates new files if the script does not eixst

@ -1,7 +1,7 @@
import { evaluateDirectoryPath, getAllParentDirectories } from "./DirectoryHelpers"; import { evaluateDirectoryPath, getAllParentDirectories } from "./DirectoryHelpers";
import { getSubdirectories } from "./DirectoryServerHelpers"; import { getSubdirectories } from "./DirectoryServerHelpers";
import { Aliases, GlobalAliases } from "../Alias"; import { Aliases, GlobalAliases, substituteAliases } from "../Alias";
import { DarkWebItems } from "../DarkWeb/DarkWebItems"; import { DarkWebItems } from "../DarkWeb/DarkWebItems";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { GetServer, GetAllServers } from "../Server/AllServers"; import { GetServer, GetAllServers } from "../Server/AllServers";
@ -58,6 +58,7 @@ export async function determineAllPossibilitiesForTabCompletion(
index: number, index: number,
currPath = "", currPath = "",
): Promise<string[]> { ): Promise<string[]> {
input = substituteAliases(input);
let allPos: string[] = []; let allPos: string[] = [];
allPos = allPos.concat(Object.keys(GlobalAliases)); allPos = allPos.concat(Object.keys(GlobalAliases));
const currServ = p.getCurrentServer(); const currServ = p.getCurrentServer();

@ -3,5 +3,5 @@ import { numeralWrapper } from "../../ui/numeralFormat";
import { Hashes } from "../../ui/React/Hashes"; import { Hashes } from "../../ui/React/Hashes";
export function HashRate({ hashes }: { hashes: number }): React.ReactElement { export function HashRate({ hashes }: { hashes: number }): React.ReactElement {
return <Hashes hashes={`${numeralWrapper.formatHashes(hashes)} / sec`} />; return <Hashes hashes={`${numeralWrapper.formatHashes(hashes)} h / s`} />;
} }

@ -43,6 +43,7 @@ export function WorkInProgressRoot(): React.ReactElement {
router.toFaction(faction); router.toFaction(faction);
player.stopFocusing(); player.stopFocusing();
} }
console.log(`${player.currentWorkFactionName} ${player.workRepGainRate}`);
return ( return (
<Grid container direction="column" justifyContent="center" alignItems="center" style={{ minHeight: "100vh" }}> <Grid container direction="column" justifyContent="center" alignItems="center" style={{ minHeight: "100vh" }}>
<Grid item> <Grid item>