From a0333d36a520f4107dec697c78c6cea63fc2234a Mon Sep 17 00:00:00 2001 From: PSEUDOSTAGE <61438810+PSEUDOSTAGE@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:27:02 -0400 Subject: [PATCH 1/3] Add calculateFavorToRep and calculateRepToFavor to Formulas.exe The favorToRep and repToFavor formulas are displayed to the player in the factions pages but were not available in Formulas.exe. This change adds a FactionsFormulas interface with the calculateFavorToRep and calculateRepToFavor as new functions. --- src/NetscriptFunctions/Formulas.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts index dbfdba566..080d5d59b 100644 --- a/src/NetscriptFunctions/Formulas.ts +++ b/src/NetscriptFunctions/Formulas.ts @@ -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); From ad9ff78533fc9a56c6eaed9f19bb3668373f514f Mon Sep 17 00:00:00 2001 From: PSEUDOSTAGE <61438810+PSEUDOSTAGE@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:28:25 -0400 Subject: [PATCH 2/3] Add calculateFavorToRep and calculateRepToFavor to Formulas.exe The favorToRep and repToFavor formulas are shown to the player in the factions pages but were not available in Formulas.exe. This change adds a FactionsFormulas interface with the calculateFavorToRep and calculateRepToFavor functions. --- src/ScriptEditor/NetscriptDefinitions.d.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 5e102ef1b..6cae8d001 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -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 */ From a5f63e593255c1d37f5054357257ccf57e4cf603 Mon Sep 17 00:00:00 2001 From: PSEUDOSTAGE <61438810+PSEUDOSTAGE@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:38:35 -0400 Subject: [PATCH 3/3] fixed trailing spaces --- src/NetscriptFunctions/Formulas.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts index 080d5d59b..c344aa0bb 100644 --- a/src/NetscriptFunctions/Formulas.ts +++ b/src/NetscriptFunctions/Formulas.ts @@ -37,8 +37,8 @@ import { calculateAscensionMult, calculateAscensionPointsGain, } from "../Gang/formulas/formulas"; -import { - favorToRep as calculateFavorToRep, +import { + favorToRep as calculateFavorToRep, repToFavor as calculateRepToFavor, } from "../Faction/formulas/favor";