API: Expose charged effects of active fragments (#2638)

This commit is contained in:
catloversg
2026-04-09 04:45:17 +07:00
committed by GitHub
parent fbd7930ab2
commit ee2949418f
5 changed files with 71 additions and 4 deletions
+10 -4
View File
@@ -64,7 +64,11 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
checkStanekAPIAccess(ctx);
helpers.log(ctx, () => `Returned ${staneksGift.fragments.length} fragments`);
return staneksGift.fragments.map((activeFragment) => {
return { ...activeFragment.copy(), ...activeFragment.fragment().copy() };
return {
...activeFragment.copy(),
...activeFragment.fragment().copy(),
chargedEffect: staneksGift.effect(activeFragment),
};
}) satisfies ReturnType<IStanek["activeFragments"]>;
},
clearGift: (ctx) => () => {
@@ -99,9 +103,11 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
checkStanekAPIAccess(ctx);
const activeFragment = staneksGift.findFragment(rootX, rootY);
if (activeFragment !== undefined) {
return { ...activeFragment.copy(), ...activeFragment.fragment().copy() } satisfies ReturnType<
IStanek["getFragment"]
>;
return {
...activeFragment.copy(),
...activeFragment.fragment().copy(),
chargedEffect: staneksGift.effect(activeFragment),
} satisfies ReturnType<IStanek["getFragment"]>;
}
return undefined;
},