mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
Merge pull request #3314 from PSEUDOSTAGE/patch-1
Add calculateFavorToRep and calculateRepToFavor to Formulas.exe
This commit is contained in:
commit
f55197eabd
@ -37,6 +37,10 @@ import {
|
||||
calculateAscensionMult,
|
||||
calculateAscensionPointsGain,
|
||||
} from "../Gang/formulas/formulas";
|
||||
import {
|
||||
favorToRep as calculateFavorToRep,
|
||||
repToFavor as calculateRepToFavor,
|
||||
} from "../Faction/formulas/favor";
|
||||
|
||||
export function NetscriptFormulas(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): IFormulas {
|
||||
const checkFormulasAccess = function (func: string): void {
|
||||
@ -45,6 +49,18 @@ export function NetscriptFormulas(player: IPlayer, workerScript: WorkerScript, h
|
||||
}
|
||||
};
|
||||
return {
|
||||
factions: {
|
||||
calculateFavorToRep: function (_favor: unknown): number {
|
||||
const favor = helper.number("calculateFavorToRep", "favor", _favor);
|
||||
checkFormulasAccess("factions.calculateFavorToRep");
|
||||
return calculateFavorToRep(favor);
|
||||
},
|
||||
calculateRepToFavor: function (_rep: unknown): number {
|
||||
const rep = helper.number("calculateRepToFavor", "rep", _rep);
|
||||
checkFormulasAccess("factions.calculateRepToFavor");
|
||||
return calculateRepToFavor(rep);
|
||||
},
|
||||
},
|
||||
skills: {
|
||||
calculateSkill: function (_exp: unknown, _mult: unknown = 1): number {
|
||||
const exp = helper.number("calculateSkill", "exp", _exp);
|
||||
|
22
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
22
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -3797,6 +3797,26 @@ interface SkillsFormulas {
|
||||
calculateExp(skill: number, skillMult?: number): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factions formulas
|
||||
* @public
|
||||
*/
|
||||
interface FactionsFormulas {
|
||||
/**
|
||||
* Calculate the total required amount of faction reputation to reach a target favor.
|
||||
* @param favor - target faction favor.
|
||||
* @returns The calculated faction reputation required.
|
||||
*/
|
||||
calculateFavorToRep(favor: number): number;
|
||||
/**
|
||||
* Calculate the resulting faction favor of a total amount of reputation.
|
||||
* (Faction favor is gained whenever you install an Augmentation.)
|
||||
* @param rep - amount of reputation.
|
||||
* @returns The calculated faction favor.
|
||||
*/
|
||||
calculateRepToFavor(rep: number): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hacking formulas
|
||||
* @public
|
||||
@ -4039,6 +4059,8 @@ interface GangFormulas {
|
||||
* @public
|
||||
*/
|
||||
export interface Formulas {
|
||||
/** Factions formulas */
|
||||
factions: FactionsFormulas;
|
||||
/** Skills formulas */
|
||||
skills: SkillsFormulas;
|
||||
/** Hacking formulas */
|
||||
|
Loading…
Reference in New Issue
Block a user