API: Make ActiveFragment extend Fragment (#2373)

* DOCUMENTATION: Fix wrong return type of ns.stanek.activeFragments

* Make ActiveFragment extend Fragment
This commit is contained in:
catloversg
2025-10-31 00:27:58 +07:00
committed by GitHub
parent a69ee132f9
commit 174e160348
5 changed files with 14 additions and 40 deletions
+11 -7
View File
@@ -5,8 +5,8 @@ import { canAcceptStaneksGift, staneksGift } from "../CotMG/Helper";
import { Fragments, FragmentById } from "../CotMG/Fragment";
import { FragmentTypeEnum } from "../CotMG/FragmentType";
import { Stanek as IStanek } from "@nsdefs";
import { NetscriptContext, InternalAPI } from "../Netscript/APIWrapper";
import type { Stanek as IStanek } from "@nsdefs";
import type { NetscriptContext, InternalAPI } from "../Netscript/APIWrapper";
import { applyAugmentation } from "../Augmentation/AugmentationHelpers";
import { joinFaction } from "../Faction/FactionHelpers";
import { Factions } from "../Faction/Factions";
@@ -63,9 +63,9 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
activeFragments: (ctx) => () => {
checkStanekAPIAccess(ctx);
helpers.log(ctx, () => `Returned ${staneksGift.fragments.length} fragments`);
return staneksGift.fragments.map((af) => {
return { ...af.copy(), ...af.fragment().copy() };
});
return staneksGift.fragments.map((activeFragment) => {
return { ...activeFragment.copy(), ...activeFragment.fragment().copy() };
}) satisfies ReturnType<IStanek["activeFragments"]>;
},
clearGift: (ctx) => () => {
checkStanekAPIAccess(ctx);
@@ -97,8 +97,12 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
const rootX = helpers.number(ctx, "rootX", _rootX);
const rootY = helpers.number(ctx, "rootY", _rootY);
checkStanekAPIAccess(ctx);
const fragment = staneksGift.findFragment(rootX, rootY);
if (fragment !== undefined) return fragment.copy();
const activeFragment = staneksGift.findFragment(rootX, rootY);
if (activeFragment !== undefined) {
return { ...activeFragment.copy(), ...activeFragment.fragment().copy() } satisfies ReturnType<
IStanek["getFragment"]
>;
}
return undefined;
},
removeFragment: (ctx) => (_rootX, _rootY) => {