From 849bcb2601e082bd36ee12ecd40fc5a2dcdd6d85 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Sun, 11 May 2025 09:14:15 +0700 Subject: [PATCH] MISC: Add formulas API for calculating share power and move UI of sharing RAM (#2126) --- markdown/bitburner.ns.getsharepower.md | 2 +- markdown/bitburner.ns.md | 4 +-- markdown/bitburner.ns.share.md | 2 +- markdown/bitburner.reputationformulas.md | 1 + ...bitburner.reputationformulas.sharepower.md | 27 +++++++++++++++++++ src/Faction/ui/FactionRoot.tsx | 2 -- src/Faction/ui/FactionsRoot.tsx | 7 +++++ src/Faction/ui/ShareOption.tsx | 7 ++--- src/Netscript/RamCostGenerator.ts | 1 + src/NetscriptFunctions/Formulas.ts | 9 +++++++ src/NetworkShare/Share.ts | 22 +++++++-------- src/ScriptEditor/NetscriptDefinitions.d.ts | 16 ++++++++--- 12 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 markdown/bitburner.reputationformulas.sharepower.md diff --git a/markdown/bitburner.ns.getsharepower.md b/markdown/bitburner.ns.getsharepower.md index 6be43f8bd..375505574 100644 --- a/markdown/bitburner.ns.getsharepower.md +++ b/markdown/bitburner.ns.getsharepower.md @@ -4,7 +4,7 @@ ## NS.getSharePower() method -Share Power has a multiplicative effect on rep/second while doing work for a faction. Share Power increases incrementally for every thread of share running on your server network, but at a sharply decreasing rate. +Share power has a multiplicative effect on rep/second while doing work for a faction. Share power increases incrementally for every thread of share running on your server network, but at a sharply decreasing rate. **Signature:** diff --git a/markdown/bitburner.ns.md b/markdown/bitburner.ns.md index 5dbb2a900..314d621bd 100644 --- a/markdown/bitburner.ns.md +++ b/markdown/bitburner.ns.md @@ -112,7 +112,7 @@ export async function main(ns) { | [getServerRequiredHackingLevel(host)](./bitburner.ns.getserverrequiredhackinglevel.md) | Returns the required hacking level of the target server. | | [getServerSecurityLevel(host)](./bitburner.ns.getserversecuritylevel.md) | Get server security level. | | [getServerUsedRam(host)](./bitburner.ns.getserverusedram.md) | Get the used RAM on a server. | -| [getSharePower()](./bitburner.ns.getsharepower.md) | Share Power has a multiplicative effect on rep/second while doing work for a faction. Share Power increases incrementally for every thread of share running on your server network, but at a sharply decreasing rate. | +| [getSharePower()](./bitburner.ns.getsharepower.md) | Share power has a multiplicative effect on rep/second while doing work for a faction. Share power increases incrementally for every thread of share running on your server network, but at a sharply decreasing rate. | | [getTimeSinceLastAug()](./bitburner.ns.gettimesincelastaug.md) | Returns the amount of time in milliseconds that have passed since you last installed Augmentations. | | [getTotalScriptExpGain()](./bitburner.ns.gettotalscriptexpgain.md) | Get the exp gain of all scripts. | | [getTotalScriptIncome()](./bitburner.ns.gettotalscriptincome.md) | Get the income of all scripts. | @@ -161,7 +161,7 @@ export async function main(ns) { | [self()](./bitburner.ns.self.md) | Returns the currently running script. | | [serverExists(host)](./bitburner.ns.serverexists.md) | Returns a boolean denoting whether or not the specified server exists. | | [setTitle(title, pid)](./bitburner.ns.settitle.md) | Set the title of the tail window of a script. This function is deprecated and will be removed in a later version. | -| [share()](./bitburner.ns.share.md) | Share the server's ram with your factions. | +| [share()](./bitburner.ns.share.md) | Share the server's ram with your factions to increase the reputation gain rate of faction work. This boost is applied to all faction work of all factions. | | [sleep(millis)](./bitburner.ns.sleep.md) | Suspends the script for n milliseconds. | | [spawn(script, threadOrOptions, args)](./bitburner.ns.spawn.md) | Terminate current script and start another in a defined number of milliseconds. | | [sprintf(format, args)](./bitburner.ns.sprintf.md) | Format a string. | diff --git a/markdown/bitburner.ns.share.md b/markdown/bitburner.ns.share.md index 6e0b7e20f..e2fa4fb48 100644 --- a/markdown/bitburner.ns.share.md +++ b/markdown/bitburner.ns.share.md @@ -4,7 +4,7 @@ ## NS.share() method -Share the server's ram with your factions. +Share the server's ram with your factions to increase the reputation gain rate of faction work. This boost is applied to all faction work of all factions. **Signature:** diff --git a/markdown/bitburner.reputationformulas.md b/markdown/bitburner.reputationformulas.md index c147e27c2..c4bfc5253 100644 --- a/markdown/bitburner.reputationformulas.md +++ b/markdown/bitburner.reputationformulas.md @@ -20,4 +20,5 @@ interface ReputationFormulas | [calculateRepToFavor(rep)](./bitburner.reputationformulas.calculatereptofavor.md) | Calculate the resulting faction favor of a total amount of reputation. (Faction favor is gained whenever you install an Augmentation.) | | [donationForRep(reputation, player)](./bitburner.reputationformulas.donationforrep.md) | Calculate the donation needed to gain an amount of reputation. | | [repFromDonation(amount, player)](./bitburner.reputationformulas.repfromdonation.md) | Calculate how much rep would be gained. | +| [sharePower(threads, cpuCores)](./bitburner.reputationformulas.sharepower.md) | Calculate the share power if you call [ns.share](./bitburner.ns.share.md) with the specified number of threads on a server having the specified number of CPU cores. | diff --git a/markdown/bitburner.reputationformulas.sharepower.md b/markdown/bitburner.reputationformulas.sharepower.md new file mode 100644 index 000000000..708e1f576 --- /dev/null +++ b/markdown/bitburner.reputationformulas.sharepower.md @@ -0,0 +1,27 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [ReputationFormulas](./bitburner.reputationformulas.md) > [sharePower](./bitburner.reputationformulas.sharepower.md) + +## ReputationFormulas.sharePower() method + +Calculate the share power if you call [ns.share](./bitburner.ns.share.md) with the specified number of threads on a server having the specified number of CPU cores. + +**Signature:** + +```typescript +sharePower(threads: number, cpuCores?: number): number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| threads | number | Number of threads. Must be a positive integer. | +| cpuCores | number | _(Optional)_ Number of CPU cores. Must be a positive integer. The default value is 1. | + +**Returns:** + +number + +The calculated share power. + diff --git a/src/Faction/ui/FactionRoot.tsx b/src/Faction/ui/FactionRoot.tsx index 643224cb1..63b671fb9 100644 --- a/src/Faction/ui/FactionRoot.tsx +++ b/src/Faction/ui/FactionRoot.tsx @@ -22,7 +22,6 @@ import { GangButton } from "./GangButton"; import { FactionWork } from "../../Work/FactionWork"; import { useCycleRerender } from "../../ui/React/hooks"; import { repNeededToDonate } from "../formulas/donation"; -import { ShareOption } from "./ShareOption"; type FactionRootProps = { faction: Faction; @@ -132,7 +131,6 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea {!isPlayersGang && factionInfo.offersWork() && ( )} - {!isPlayersGang && factionInfo.offersWork() && }