added logic to allow quitJob to be called from singularity

This commit is contained in:
phyzical 2022-04-28 19:05:56 +08:00
parent 9c805dabb8
commit 711955c112
6 changed files with 22 additions and 3 deletions

@ -156,6 +156,7 @@ const singularity: IMap<any> = {
getUpgradeHomeCoresCost: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 2), getUpgradeHomeCoresCost: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 2),
workForCompany: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost), workForCompany: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
applyToCompany: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost), applyToCompany: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
quitJob: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
getCompanyRep: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3), getCompanyRep: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3),
getCompanyFavor: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3), getCompanyFavor: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3),
getCompanyFavorGain: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 4), getCompanyFavorGain: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 4),

@ -947,6 +947,12 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
} }
return res; return res;
}, },
quitJob: (_ctx: NetscriptContext) =>
function (_companyName: unknown): void {
_ctx.helper.checkSingularityAccess();
const companyName = _ctx.helper.string("companyName", _companyName);
player.quitJob(companyName);
},
getCompanyRep: (_ctx: NetscriptContext) => getCompanyRep: (_ctx: NetscriptContext) =>
function (_companyName: unknown): number { function (_companyName: unknown): number {
_ctx.helper.checkSingularityAccess(); _ctx.helper.checkSingularityAccess();

@ -248,7 +248,7 @@ export interface IPlayer {
queryStatFromString(str: string): number; queryStatFromString(str: string): number;
getIntelligenceBonus(weight: number): number; getIntelligenceBonus(weight: number): number;
getCasinoWinnings(): number; getCasinoWinnings(): number;
quitJob(company: string): void; quitJob(company: string, sing?: boolean): void;
hasJob(): boolean; hasJob(): boolean;
createHacknetServer(): HacknetServer; createHacknetServer(): HacknetServer;
startCreateProgramWork(programName: string, time: number, reqLevel: number): void; startCreateProgramWork(programName: string, time: number, reqLevel: number): void;

@ -258,7 +258,7 @@ export class PlayerObject implements IPlayer {
queryStatFromString: (str: string) => number; queryStatFromString: (str: string) => number;
getIntelligenceBonus: (weight: number) => number; getIntelligenceBonus: (weight: number) => number;
getCasinoWinnings: () => number; getCasinoWinnings: () => number;
quitJob: (company: string) => void; quitJob: (company: string, sing?: boolean) => void;
hasJob: () => boolean; hasJob: () => boolean;
process: (router: IRouter, numCycles?: number) => void; process: (router: IRouter, numCycles?: number) => void;
createHacknetServer: () => HacknetServer; createHacknetServer: () => HacknetServer;

@ -1869,7 +1869,7 @@ export function getNextCompanyPosition(
return entryPosType; return entryPosType;
} }
export function quitJob(this: IPlayer, company: string): void { export function quitJob(this: IPlayer, company: string, _sing = false): void {
if (this.isWorking == true && this.workType.includes("Working for Company") && this.companyName == company) { if (this.isWorking == true && this.workType.includes("Working for Company") && this.companyName == company) {
this.finishWork(true); this.finishWork(true);
} }

@ -1800,6 +1800,18 @@ export interface Singularity {
*/ */
workForCompany(companyName?: string, focus?: boolean): boolean; workForCompany(companyName?: string, focus?: boolean): boolean;
/**
* Quit jobs by company.
* @remarks
* RAM cost: 3 GB * 16/4/1
*
*
* This function will finish work with the company provided and quit any jobs.
*
* @param companyName - Name of the company.
*/
quitJob(companyName?: string): void;
/** /**
* Apply for a job at a company. * Apply for a job at a company.
* @remarks * @remarks