From e644c0e91eee9405ce6c8221663635c8d7370012 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:14:09 +0700 Subject: [PATCH] API: Make condition of donateToFaction consistent (#1686) --- .../bitburner.singularity.donatetofaction.md | 4 ++++ src/Faction/FactionInfo.tsx | 6 ++++++ src/NetscriptFunctions/Singularity.ts | 18 +++--------------- src/ScriptEditor/NetscriptDefinitions.d.ts | 4 ++++ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/markdown/bitburner.singularity.donatetofaction.md b/markdown/bitburner.singularity.donatetofaction.md index feae473d1..afcd570f2 100644 --- a/markdown/bitburner.singularity.donatetofaction.md +++ b/markdown/bitburner.singularity.donatetofaction.md @@ -31,3 +31,7 @@ RAM cost: 5 GB \* 16/4/1 Attempts to donate money to the specified faction in exchange for reputation. Returns true if you successfully donate the money, and false otherwise. +You cannot donate to your gang's faction. + +The specified faction must offer at least 1 type of work. You can use [getFactionWorkTypes](./bitburner.singularity.getfactionworktypes.md) to get the list of work types of a faction. + diff --git a/src/Faction/FactionInfo.tsx b/src/Faction/FactionInfo.tsx index eeb8f49b7..49c0800d3 100644 --- a/src/Faction/FactionInfo.tsx +++ b/src/Faction/FactionInfo.tsx @@ -697,6 +697,9 @@ export const FactionInfos: Record = { rumorText: <>The {CompanyName.NSA} would like to have a word with you once you're ready., inviteReqs: [haveSomeSourceFile(6, 7), haveBladeburnerRank(BladeburnerConstants.RankNeededForFaction)], rumorReqs: [haveSomeSourceFile(6, 7), notCondition(inBitNode(8))], + offerHackingWork: false, + offerFieldWork: false, + offerSecurityWork: false, special: true, assignment: (): React.ReactElement => { return ( @@ -790,6 +793,9 @@ export const FactionInfos: Record = { }, }, ], + offerHackingWork: false, + offerFieldWork: false, + offerSecurityWork: false, special: true, keepOnInstall: true, assignment: (): React.ReactElement => { diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 77db2199d..d3ef7480e 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -1,15 +1,7 @@ import type { Singularity as ISingularity, Task as ITask } from "@nsdefs"; import { Player } from "@player"; -import { - AugmentationName, - CityName, - FactionName, - FactionWorkType, - GymType, - LocationName, - UniversityClassType, -} from "@enums"; +import { AugmentationName, CityName, FactionWorkType, GymType, LocationName, UniversityClassType } from "@enums"; import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers"; import { startWorkerScript } from "../NetscriptWorker"; import { Augmentations } from "../Augmentation/Augmentations"; @@ -967,12 +959,8 @@ export function NetscriptSingularity(): InternalAPI { helpers.log(ctx, () => `You can't donate to '${facName}' because you are managing a gang for it`); return false; } - if ( - faction.name === FactionName.ChurchOfTheMachineGod || - faction.name === FactionName.Bladeburners || - faction.name === FactionName.ShadowsOfAnarchy - ) { - helpers.log(ctx, () => `You can't donate to '${facName}' because they do not accept donations`); + if (!faction.getInfo().offersWork()) { + helpers.log(ctx, () => `You can't donate to '${facName}' because this faction does not offer any type of work`); return false; } if (typeof amt !== "number" || amt <= 0 || isNaN(amt)) { diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index d8b834243..4b62ded4a 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2294,6 +2294,10 @@ export interface Singularity { * Attempts to donate money to the specified faction in exchange for reputation. * Returns true if you successfully donate the money, and false otherwise. * + * You cannot donate to your gang's faction. + * + * The specified faction must offer at least 1 type of work. You can use {@link Singularity.getFactionWorkTypes | getFactionWorkTypes} to get the list of work types of a faction. + * * @param faction - Name of faction to donate to. * @param amount - Amount of money to donate. * @returns True if the money was donated, and false otherwise.