Fix sleeves unable to commit crime

This commit is contained in:
omuretsu 2022-11-03 08:39:34 -04:00
parent 442a4f0198
commit b057e2e5f2
3 changed files with 6 additions and 4 deletions

@ -71,7 +71,7 @@ export function NetscriptSleeve(): InternalAPI<ISleeve> {
checkSleeveNumber(ctx, sleeveNumber); checkSleeveNumber(ctx, sleeveNumber);
const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType); const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType);
if (crime == null) return false; if (crime == null) return false;
return Player.sleeves[sleeveNumber].commitCrime(crime.name); return Player.sleeves[sleeveNumber].commitCrime(crime.type);
}, },
setToUniversityCourse: (ctx) => (_sleeveNumber, _universityName, _className) => { setToUniversityCourse: (ctx) => (_sleeveNumber, _universityName, _className) => {
const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber); const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber);

@ -94,8 +94,7 @@ export class Sleeve extends Person {
} }
/** Commit crimes */ /** Commit crimes */
commitCrime(type: string): boolean { commitCrime(type: CrimeType): boolean {
if (!checkEnum(CrimeType, type)) return false;
this.startWork(new SleeveCrimeWork(type)); this.startWork(new SleeveCrimeWork(type));
return true; return true;
} }

@ -20,6 +20,8 @@ import { isSleeveInfiltrateWork } from "../Work/SleeveInfiltrateWork";
import { isSleeveSupportWork } from "../Work/SleeveSupportWork"; import { isSleeveSupportWork } from "../Work/SleeveSupportWork";
import { isSleeveBladeburnerWork } from "../Work/SleeveBladeburnerWork"; import { isSleeveBladeburnerWork } from "../Work/SleeveBladeburnerWork";
import { isSleeveCrimeWork } from "../Work/SleeveCrimeWork"; import { isSleeveCrimeWork } from "../Work/SleeveCrimeWork";
import { findCrime } from "../../../Crime/CrimeHelpers";
import { CrimeType } from "../../../utils/WorkType";
interface IProps { interface IProps {
sleeve: Sleeve; sleeve: Sleeve;
@ -44,7 +46,8 @@ export function SleeveElem(props: IProps): React.ReactElement {
props.sleeve.workForFaction(abc[1], abc[2]); props.sleeve.workForFaction(abc[1], abc[2]);
break; break;
case "Commit Crime": case "Commit Crime":
props.sleeve.commitCrime(abc[1]); const crimeType = findCrime(abc[1])?.type ?? CrimeType.SHOPLIFT;
props.sleeve.commitCrime(crimeType);
break; break;
case "Take University Course": case "Take University Course":
props.sleeve.takeUniversityCourse(abc[2], abc[1]); props.sleeve.takeUniversityCourse(abc[2], abc[1]);