From a5f5c819128fe6c573a4a1c29f4d9dac5552076f Mon Sep 17 00:00:00 2001 From: LJ <23249107+LJNeon@users.noreply.github.com> Date: Mon, 4 Mar 2024 07:35:54 -0700 Subject: [PATCH] API: Add karma to ns.getPlayer() & document ns.heart.break() (#1131) --- src/NetscriptFunctions.ts | 1 + src/NetscriptFunctions/Formulas.ts | 1 + src/ScriptEditor/NetscriptDefinitions.d.ts | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 8e740affa..c6c5bf6e2 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1683,6 +1683,7 @@ export const ns: InternalAPI = { jobs: structuredClone(Player.jobs), factions: Player.factions.slice(), entropy: Player.entropy, + karma: Player.karma, }; setDeprecatedProperties(data, { playtimeSinceLastAug: { diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts index 0d0402980..98f9d2cad 100644 --- a/src/NetscriptFunctions/Formulas.ts +++ b/src/NetscriptFunctions/Formulas.ts @@ -108,6 +108,7 @@ export function NetscriptFormulas(): InternalAPI { jobs: {}, factions: [], entropy: 0, + karma: 0, }), mockPerson: () => (): IPerson => ({ hp: { current: 0, max: 0 }, diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 8beb590da..3ebca2a3d 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -48,6 +48,7 @@ interface Player extends Person { factions: string[]; totalPlaytime: number; location: string; + karma: number; } /** @public */ @@ -5513,6 +5514,15 @@ export interface NS { */ growthAnalyzeSecurity(threads: number, hostname?: string, cores?: number): number; + readonly heart: { + /** + * Get your current karma. + * @remarks + * RAM cost: 0 GB + */ + break(): number; + }; + /** * Suspends the script for n milliseconds. * @remarks