API: Return active SF levels in getOwnedSourceFiles and ResetInfo.ownedSF (#1761)

* DOCUMENTATION: Clarify getOwnedSourceFiles when player overrides active levels of SFs
* Return Player.activeSourceFiles instead of Player.sourceFiles
* Get rid of zeroes in the map
This commit is contained in:
catloversg 2024-11-11 13:56:57 +07:00 committed by GitHub
parent cb9e281c45
commit 72a63b15cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 38 additions and 7 deletions

@ -21,5 +21,5 @@ interface ResetInfo
| [lastAugReset](./bitburner.resetinfo.lastaugreset.md) | | number | Numeric timestamp (from Date.now()) of last augmentation reset | | [lastAugReset](./bitburner.resetinfo.lastaugreset.md) | | number | Numeric timestamp (from Date.now()) of last augmentation reset |
| [lastNodeReset](./bitburner.resetinfo.lastnodereset.md) | | number | Numeric timestamp (from Date.now()) of last BitNode reset | | [lastNodeReset](./bitburner.resetinfo.lastnodereset.md) | | number | Numeric timestamp (from Date.now()) of last BitNode reset |
| [ownedAugs](./bitburner.resetinfo.ownedaugs.md) | | Map<string, number> | A map of owned augmentations to their levels. Keyed by the augmentation name. Map values are the augmentation level (e.g. for NeuroFlux governor). | | [ownedAugs](./bitburner.resetinfo.ownedaugs.md) | | Map<string, number> | A map of owned augmentations to their levels. Keyed by the augmentation name. Map values are the augmentation level (e.g. for NeuroFlux governor). |
| [ownedSF](./bitburner.resetinfo.ownedsf.md) | | Map&lt;number, number&gt; | A map of owned SF to their levels. Keyed by the SF number. Map values are the SF level. | | [ownedSF](./bitburner.resetinfo.ownedsf.md) | | Map&lt;number, number&gt; | <p>A map of owned source files. Its keys are the SF numbers. Its values are the active SF levels. This map takes BitNode options into account.</p><p>For example, let's say you have SF 1.3, but you overrode the active level of SF1 and set it to level 1. In this case, this map contains this entry: Key: 1 =<!-- -->&gt; Value: 1.</p><p>If the active level of a source file is 0, that source file won't be included in the result.</p> |

@ -4,7 +4,11 @@
## ResetInfo.ownedSF property ## ResetInfo.ownedSF property
A map of owned SF to their levels. Keyed by the SF number. Map values are the SF level. A map of owned source files. Its keys are the SF numbers. Its values are the active SF levels. This map takes BitNode options into account.
For example, let's say you have SF 1.3, but you overrode the active level of SF1 and set it to level 1. In this case, this map contains this entry: Key: 1 =<!-- -->&gt; Value: 1.
If the active level of a source file is 0, that source file won't be included in the result.
**Signature:** **Signature:**

@ -21,5 +21,9 @@ Array containing an object with number and level of the source file.
RAM cost: 5 GB RAM cost: 5 GB
Returns an array of source files Returns an array of source files. This function takes BitNode options into account.
For example, let's say you have SF 1.3, but you overrode the active level of SF1 and set it to level 1. In this case, this function returns {<!-- -->"n":1,"lvl":1<!-- -->}<!-- -->.
If the active level of a source file is 0, that source file won't be included in the result.

@ -1825,7 +1825,11 @@ export const ns: InternalAPI<NSFull> = {
lastNodeReset: Player.lastNodeReset, lastNodeReset: Player.lastNodeReset,
currentNode: Player.bitNodeN, currentNode: Player.bitNodeN,
ownedAugs: new Map(Player.augmentations.map((aug) => [aug.name, aug.level])), ownedAugs: new Map(Player.augmentations.map((aug) => [aug.name, aug.level])),
ownedSF: new Map(Player.sourceFiles), ownedSF: new Map(
[...Player.activeSourceFiles].filter(([__, activeLevel]) => {
return activeLevel > 0;
}),
),
bitNodeOptions: { bitNodeOptions: {
...Player.bitNodeOptions, ...Player.bitNodeOptions,
sourceFileOverrides: new Map(Player.bitNodeOptions.sourceFileOverrides), sourceFileOverrides: new Map(Player.bitNodeOptions.sourceFileOverrides),

@ -88,7 +88,13 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
return res; return res;
}, },
getOwnedSourceFiles: () => () => [...Player.sourceFiles].map(([n, lvl]) => ({ n, lvl })), getOwnedSourceFiles: () => () => {
return [...Player.activeSourceFiles]
.filter(([__, activeLevel]) => {
return activeLevel > 0;
})
.map(([n, lvl]) => ({ n, lvl }));
},
getAugmentationFactions: (ctx) => (_augName) => { getAugmentationFactions: (ctx) => (_augName) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = getEnumHelper("AugmentationName").nsGetMember(ctx, _augName); const augName = getEnumHelper("AugmentationName").nsGetMember(ctx, _augName);

@ -74,7 +74,15 @@ interface ResetInfo {
currentNode: number; currentNode: number;
/** A map of owned augmentations to their levels. Keyed by the augmentation name. Map values are the augmentation level (e.g. for NeuroFlux governor). */ /** A map of owned augmentations to their levels. Keyed by the augmentation name. Map values are the augmentation level (e.g. for NeuroFlux governor). */
ownedAugs: Map<string, number>; ownedAugs: Map<string, number>;
/** A map of owned SF to their levels. Keyed by the SF number. Map values are the SF level. */ /**
* A map of owned source files. Its keys are the SF numbers. Its values are the active SF levels. This map takes
* BitNode options into account.
*
* For example, let's say you have SF 1.3, but you overrode the active level of SF1 and set it to level 1. In this
* case, this map contains this entry: Key: 1 => Value: 1.
*
* If the active level of a source file is 0, that source file won't be included in the result.
*/
ownedSF: Map<number, number>; ownedSF: Map<number, number>;
/** Current BitNode options */ /** Current BitNode options */
bitNodeOptions: BitNodeOptions; bitNodeOptions: BitNodeOptions;
@ -2435,7 +2443,12 @@ export interface Singularity {
* RAM cost: 5 GB * RAM cost: 5 GB
* *
* *
* Returns an array of source files * Returns an array of source files. This function takes BitNode options into account.
*
* For example, let's say you have SF 1.3, but you overrode the active level of SF1 and set it to level 1. In this
* case, this function returns {"n":1,"lvl":1}.
*
* If the active level of a source file is 0, that source file won't be included in the result.
* *
* @returns Array containing an object with number and level of the source file. * @returns Array containing an object with number and level of the source file.
*/ */