mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
API: Add donationForRep() to Formulas (#1141)
This commit is contained in:
@@ -9,6 +9,10 @@ export function repFromDonation(amt: number, person: IPerson): number {
|
||||
return (amt / CONSTANTS.DonateMoneyToRepDivisor) * person.mults.faction_rep * currentNodeMults.FactionWorkRepGain;
|
||||
}
|
||||
|
||||
export function donationForRep(rep: number, person: IPerson): number {
|
||||
return (rep * CONSTANTS.DonateMoneyToRepDivisor) / person.mults.faction_rep / currentNodeMults.FactionWorkRepGain;
|
||||
}
|
||||
|
||||
export function repNeededToDonate(): number {
|
||||
return Math.floor(CONSTANTS.BaseFavorToDonate * currentNodeMults.RepToDonateToFaction);
|
||||
}
|
||||
|
||||
@@ -632,6 +632,7 @@ export const RamCosts: RamCostTree<NSFull> = {
|
||||
calculateFavorToRep: 0,
|
||||
calculateRepToFavor: 0,
|
||||
repFromDonation: 0,
|
||||
donationForRep: 0,
|
||||
},
|
||||
skills: {
|
||||
calculateSkill: 0,
|
||||
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
calculateAscensionPointsGain,
|
||||
} from "../Gang/formulas/formulas";
|
||||
import { favorToRep as calculateFavorToRep, repToFavor as calculateRepToFavor } from "../Faction/formulas/favor";
|
||||
import { repFromDonation } from "../Faction/formulas/donation";
|
||||
import { repFromDonation, donationForRep } from "../Faction/formulas/donation";
|
||||
import { InternalAPI, NetscriptContext, setRemovedFunctions } from "../Netscript/APIWrapper";
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { calculateCrimeWorkStats } from "../Work/Formulas";
|
||||
@@ -128,6 +128,12 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
|
||||
checkFormulasAccess(ctx);
|
||||
return repFromDonation(amount, person);
|
||||
},
|
||||
donationForRep: (ctx) => (_reputation, _player) => {
|
||||
const reputation = helpers.number(ctx, "reputation", _reputation);
|
||||
const person = helpers.person(ctx, _player);
|
||||
checkFormulasAccess(ctx);
|
||||
return donationForRep(reputation, person);
|
||||
},
|
||||
},
|
||||
skills: {
|
||||
calculateSkill:
|
||||
|
||||
7
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
7
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@@ -5209,6 +5209,13 @@ interface ReputationFormulas {
|
||||
* @param player - Player info, typically from {@link NS.getPlayer | getPlayer}
|
||||
*/
|
||||
repFromDonation(amount: number, player: Person): number;
|
||||
|
||||
/**
|
||||
* Calculate the donation needed to gain an amount of reputation.
|
||||
* @param reputation - Amount of reputation
|
||||
* @param player - Player info, typically from {@link NS.getPlayer | getPlayer}
|
||||
*/
|
||||
donationForRep(reputation: number, player: Person): number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user