API: Programming-friendly interface to getFactionInviteRequirements (#953)

This commit is contained in:
Jesse Clark
2023-12-16 01:27:22 -08:00
committed by GitHub
parent e957864c4b
commit 473217ef31
79 changed files with 1626 additions and 140 deletions
+1 -3
View File
@@ -816,14 +816,12 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
const companyName = getEnumHelper("CompanyName").nsGetMember(ctx, _companyName);
return Companies[companyName].getFavorGain();
},
/* Function temporarily removed, likely to change in next version to be more programming-friendly instead of providing human-readable string outputs for each requirement
getFactionInviteRequirements: (ctx) => (_facName) => {
helpers.checkSingularityAccess(ctx);
const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName);
const fac = Factions[facName];
return fac.getInfo().inviteReqs.map((condition) => condition.toString());
return [...fac.getInfo().inviteReqs].map((condition) => condition.toJSON());
},
*/
checkFactionInvitations: (ctx) => () => {
helpers.checkSingularityAccess(ctx);
// Manually trigger a check for faction invites
+9 -18
View File
@@ -108,19 +108,13 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
return staneksGift.delete(rootX, rootY);
},
acceptGift: (ctx) => () => {
//Check if the player is eligible to join the church
if (
Player.canAccessCotMG() &&
Player.augmentations.filter((a) => a.name !== AugmentationName.NeuroFluxGovernor).length == 0 &&
Player.queuedAugmentations.filter((a) => a.name !== AugmentationName.NeuroFluxGovernor).length == 0
) {
//Attempt to join CotMG
joinFaction(Factions[FactionName.ChurchOfTheMachineGod]);
//Attempt to install the first Stanek aug
if (
!Player.hasAugmentation(AugmentationName.StaneksGift1) &&
!Player.queuedAugmentations.some((a) => a.name === AugmentationName.StaneksGift1)
) {
const cotmgFaction = Factions[FactionName.ChurchOfTheMachineGod];
// Check if the player is eligible to join the church
if (cotmgFaction.getInfo().inviteReqs.isSatisfied(Player)) {
// Attempt to join CotMG
joinFaction(cotmgFaction);
// Attempt to install the first Stanek aug (unless it is already queued)
if (!Player.hasAugmentation(AugmentationName.StaneksGift1, false)) {
applyAugmentation({ name: AugmentationName.StaneksGift1, level: 1 });
helpers.log(
ctx,
@@ -128,11 +122,8 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
);
}
}
//Return true iff the player is in CotMG and has the first Stanek aug installed
return (
Factions[FactionName.ChurchOfTheMachineGod].isMember &&
Player.hasAugmentation(AugmentationName.StaneksGift1, true)
);
// Return true iff the player is in CotMG and has the first Stanek aug installed
return cotmgFaction.isMember && Player.hasAugmentation(AugmentationName.StaneksGift1, true);
},
};
}