MISC: Add formulas API for calculating share power and move UI of sharing RAM (#2126)

This commit is contained in:
catloversg
2025-05-11 09:14:15 +07:00
committed by GitHub
parent 22ee7fca2c
commit 849bcb2601
12 changed files with 77 additions and 23 deletions
+9
View File
@@ -53,6 +53,7 @@ import { CompanyPositions } from "../Company/CompanyPositions";
import { findCrime } from "../Crime/CrimeHelpers";
import { Skills } from "../Bladeburner/data/Skills";
import type { PositiveNumber } from "../types";
import { calculateEffectiveSharedThreads, calculateShareBonus } from "../NetworkShare/Share";
export function NetscriptFormulas(): InternalAPI<IFormulas> {
const checkFormulasAccess = function (ctx: NetscriptContext): void {
@@ -134,6 +135,14 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
checkFormulasAccess(ctx);
return donationForRep(reputation, person);
},
sharePower:
(ctx) =>
(_threads, _cpuCores = 1) => {
const threads = helpers.positiveInteger(ctx, "threads", _threads);
const cpuCores = helpers.positiveInteger(ctx, "cpuCores", _cpuCores);
checkFormulasAccess(ctx);
return calculateShareBonus(calculateEffectiveSharedThreads(threads, cpuCores));
},
},
skills: {
calculateSkill: