Merge pull request #3349 from phyzical/bugfix/3347

add logic to block sleeve working for gang faction
This commit is contained in:
hydroflame 2022-04-05 20:01:02 -04:00 committed by GitHub
commit 4cdef2d898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

@ -122,7 +122,11 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
return player.sleeves[sleeveNumber].workForCompany(player, companyName);
},
setToFactionWork: function (_sleeveNumber: unknown, _factionName: unknown, _workType: unknown): boolean {
setToFactionWork: function (
_sleeveNumber: unknown,
_factionName: unknown,
_workType: unknown,
): boolean | undefined {
const sleeveNumber = helper.number("setToFactionWork", "sleeveNumber", _sleeveNumber);
const factionName = helper.string("setToUniversityCourse", "factionName", _factionName);
const workType = helper.string("setToUniversityCourse", "workType", _workType);
@ -144,6 +148,13 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
}
}
if (player.gang && player.gang.facName == factionName) {
throw helper.makeRuntimeErrorMsg(
"sleeve.setToFactionWork",
`Sleeve ${sleeveNumber} cannot work for faction ${factionName} because you have started a gang with them.`,
);
}
return player.sleeves[sleeveNumber].workForFaction(player, factionName, workType);
},
setToGymWorkout: function (_sleeveNumber: unknown, _gymName: unknown, _stat: unknown): boolean {

@ -3637,9 +3637,9 @@ export interface Sleeve {
* @param sleeveNumber - Index of the sleeve to work for the faction.
* @param factionName - Name of the faction to work for.
* @param factionWorkType - Name of the action to perform for this faction.
* @returns True if the sleeve started working on this faction, false otherwise.
* @returns True if the sleeve started working on this faction, false otherwise, can also throw on errors
*/
setToFactionWork(sleeveNumber: number, factionName: string, factionWorkType: string): boolean;
setToFactionWork(sleeveNumber: number, factionName: string, factionWorkType: string): boolean | undefined;
/**
* Set a sleeve to work for a company.