Fixes #1860 donate to gang faction possible via singularity

also fixes bug i found while testing this where its possible to donate
to a faction you arent a member of
This commit is contained in:
TheMas3212 2022-01-05 21:36:09 +11:00
parent fc888505ae
commit 538a440b7e
No known key found for this signature in database
GPG Key ID: 62A173A4FDA683CA

@ -1175,7 +1175,20 @@ export function NetscriptSingularity(
helper.updateDynamicRam("donateToFaction", getRamCost(player, "donateToFaction")); helper.updateDynamicRam("donateToFaction", getRamCost(player, "donateToFaction"));
helper.checkSingularityAccess("donateToFaction"); helper.checkSingularityAccess("donateToFaction");
const faction = getFaction("donateToFaction", name); const faction = getFaction("donateToFaction", name);
if (!player.factions.includes(faction.name)) {
workerScript.log(
"donateToFaction",
() => `You can't donate to '${name}' because you aren't a member`,
);
return false;
}
if (faction.name === player.getGangFaction().name) {
workerScript.log(
"donateToFaction",
() => `You can't donate to '${name}' because youre managing a gang for it`,
);
return false;
}
if (typeof amt !== "number" || amt <= 0) { if (typeof amt !== "number" || amt <= 0) {
workerScript.log("donateToFaction", () => `Invalid donation amount: '${amt}'.`); workerScript.log("donateToFaction", () => `Invalid donation amount: '${amt}'.`);
return false; return false;