From f6871f0911bd1f1701389f453d224ce6e0d60d33 Mon Sep 17 00:00:00 2001
From: LJ <23249107+LJNeon@users.noreply.github.com>
Date: Fri, 23 Feb 2024 13:58:22 -0700
Subject: [PATCH] GANG: Clarify install behavior & add getInstallResult()
(#1119)
New function returns post-install ascension ratios.
* Add ascension penalty to Gang constants
* Improve wording of Gang install message
* Add GangMember#getInstallResults()
* Update prestiging to use getInstallResults()
* Add ns.gang.getInstallResults(memberName)
* Update definitions
* Add ram cost for ns.gang.getInstallResult()
* Fix typo
* More specific wording in documentation
* Fix another typo
* Run prettier
* Rename getInstallResults to getPostInstallPoints
* Update Prestige.ts
* Update Gang.ts
---
src/Gang/GangMember.ts | 12 ++++++++++
src/Gang/data/Constants.ts | 2 ++
src/Gang/ui/ManagementSubpage.tsx | 5 ++--
src/Netscript/RamCostGenerator.ts | 1 +
src/NetscriptFunctions/Gang.ts | 16 +++++++++++++
src/Prestige.ts | 14 +++++------
src/ScriptEditor/NetscriptDefinitions.d.ts | 28 ++++++++++++++++++++++
7 files changed, 69 insertions(+), 9 deletions(-)
diff --git a/src/Gang/GangMember.ts b/src/Gang/GangMember.ts
index f0a780f23..80b655346 100644
--- a/src/Gang/GangMember.ts
+++ b/src/Gang/GangMember.ts
@@ -5,6 +5,7 @@ import { GangMemberUpgrades } from "./GangMemberUpgrades";
import { IAscensionResult } from "./IAscensionResult";
import { Player } from "@player";
import { Gang } from "./Gang";
+import { GangConstants } from "./data/Constants";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
import {
calculateRespectGain,
@@ -250,6 +251,17 @@ export class GangMember {
};
}
+ getPostInstallPoints(): IMults {
+ return {
+ hack: this.hack_asc_points * GangConstants.InstallAscensionPenalty,
+ str: this.str_asc_points * GangConstants.InstallAscensionPenalty,
+ def: this.def_asc_points * GangConstants.InstallAscensionPenalty,
+ dex: this.dex_asc_points * GangConstants.InstallAscensionPenalty,
+ agi: this.agi_asc_points * GangConstants.InstallAscensionPenalty,
+ cha: this.cha_asc_points * GangConstants.InstallAscensionPenalty,
+ };
+ }
+
ascend(): IAscensionResult {
const res = this.getAscensionResults();
const points = this.getGainedAscensionPoints();
diff --git a/src/Gang/data/Constants.ts b/src/Gang/data/Constants.ts
index 95a557bbd..365ba3b06 100644
--- a/src/Gang/data/Constants.ts
+++ b/src/Gang/data/Constants.ts
@@ -12,6 +12,8 @@ export const GangConstants = {
CyclesPerTerritoryAndPowerUpdate: 100,
// Portion of upgrade multiplier that is kept after ascending
AscensionMultiplierRatio: 0.15,
+ // Penalty to ascension points on install
+ InstallAscensionPenalty: 0.95,
// Names of possible Gangs
Names: [
FactionName.SlumSnakes,
diff --git a/src/Gang/ui/ManagementSubpage.tsx b/src/Gang/ui/ManagementSubpage.tsx
index 057cd13c2..6f58e3122 100644
--- a/src/Gang/ui/ManagementSubpage.tsx
+++ b/src/Gang/ui/ManagementSubpage.tsx
@@ -21,8 +21,9 @@ export function ManagementSubpage(): React.ReactElement {
Vigilante Justice to lower your wanted level.
- Installing Augmentations does NOT reset progress with your Gang. Furthermore, after installing Augmentations,
- you will automatically join whatever Faction you created your gang with.
+ Installing Augmentations does NOT reset progress with your Gang, however ascension multipliers will decrease
+ slightly. Furthermore, after installing Augmentations, you will automatically join whatever Faction you created
+ your gang with.
You can also manage your gang programmatically through Netscript using the Gang API.
diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts
index fdbb9a198..7e115cc89 100644
--- a/src/Netscript/RamCostGenerator.ts
+++ b/src/Netscript/RamCostGenerator.ts
@@ -237,6 +237,7 @@ const gang = {
purchaseEquipment: RamCostConstants.GangApiBase,
ascendMember: RamCostConstants.GangApiBase,
getAscensionResult: RamCostConstants.GangApiBase / 2,
+ getInstallResult: RamCostConstants.GangApiBase / 2,
setTerritoryWarfare: RamCostConstants.GangApiBase / 2,
getChanceToWinClash: RamCostConstants.GangApiBase,
getBonusTime: 0,
diff --git a/src/NetscriptFunctions/Gang.ts b/src/NetscriptFunctions/Gang.ts
index 899be4c9e..9e4ec7e60 100644
--- a/src/NetscriptFunctions/Gang.ts
+++ b/src/NetscriptFunctions/Gang.ts
@@ -297,6 +297,22 @@ export function NetscriptGang(): InternalAPI {
...member.getAscensionResults(),
};
},
+ getInstallResult: (ctx) => (_memberName) => {
+ const memberName = helpers.string(ctx, "memberName", _memberName);
+ getGang(ctx);
+ const member = getGangMember(ctx, memberName);
+ if (!member.canAscend()) return;
+ const preInstall = member.getCurrentAscensionMults();
+ const postInstall = member.getPostInstallPoints();
+ return {
+ hack: member.calculateAscensionMult(postInstall.hack) / preInstall.hack,
+ str: member.calculateAscensionMult(postInstall.str) / preInstall.str,
+ def: member.calculateAscensionMult(postInstall.def) / preInstall.def,
+ dex: member.calculateAscensionMult(postInstall.dex) / preInstall.dex,
+ agi: member.calculateAscensionMult(postInstall.agi) / preInstall.agi,
+ cha: member.calculateAscensionMult(postInstall.cha) / preInstall.cha,
+ };
+ },
setTerritoryWarfare: (ctx) => (_engage) => {
const engage = !!_engage;
const gang = getGang(ctx);
diff --git a/src/Prestige.ts b/src/Prestige.ts
index 954945036..684f5a26a 100755
--- a/src/Prestige.ts
+++ b/src/Prestige.ts
@@ -110,14 +110,14 @@ export function prestigeAugmentation(): void {
if (gang) {
const faction = Factions[gang.facName];
if (faction) joinFaction(faction);
- const penalty = 0.95;
for (const m of gang.members) {
- m.hack_asc_points *= penalty;
- m.str_asc_points *= penalty;
- m.def_asc_points *= penalty;
- m.dex_asc_points *= penalty;
- m.agi_asc_points *= penalty;
- m.cha_asc_points *= penalty;
+ const results = m.getPostInstallPoints();
+ m.hack_asc_points = results.hack;
+ m.str_asc_points = results.str;
+ m.def_asc_points = results.def;
+ m.dex_asc_points = results.dex;
+ m.agi_asc_points = results.agi;
+ m.cha_asc_points = results.cha;
}
}
diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts
index 44be5d702..0243ebe5a 100644
--- a/src/ScriptEditor/NetscriptDefinitions.d.ts
+++ b/src/ScriptEditor/NetscriptDefinitions.d.ts
@@ -961,6 +961,22 @@ interface GangMemberInfo {
moneyGain: number;
}
+/** @public */
+interface GangMemberInstall {
+ /** Factor by which the hacking ascension multiplier was decreased (newMult / oldMult) */
+ hack: number;
+ /** Factor by which the strength ascension multiplier was decreased (newMult / oldMult) */
+ str: number;
+ /** Factor by which the defense ascension multiplier was decreased (newMult / oldMult) */
+ def: number;
+ /** Factor by which the dexterity ascension multiplier was decreased (newMult / oldMult) */
+ dex: number;
+ /** Factor by which the agility ascension multiplier was decreased (newMult / oldMult) */
+ agi: number;
+ /** Factor by which the charisma ascension multiplier was decreased (newMult / oldMult) */
+ cha: number;
+}
+
/** @public */
interface GangMemberAscension {
/** Amount of respect lost from ascending */
@@ -3832,6 +3848,18 @@ export interface Gang {
*/
getAscensionResult(memberName: string): GangMemberAscension | undefined;
+ /**
+ * Get the effect of an install on ascension multipliers without installing.
+ * @remarks
+ * RAM cost: 2 GB
+ *
+ * Get {@link GangMemberInstall} effects on ascension multipliers for a gang member after installing without performing the install.
+ *
+ * @param memberName - Name of member.
+ * @returns Object with info about the install results on ascension multipliers, or undefined if ascension is not possible.
+ */
+ getInstallResult(memberName: string): GangMemberInstall | undefined;
+
/**
* Enable/Disable territory clashes.
* @remarks