From b057e2e5f249a49a780c6f059202e9df3d5900f6 Mon Sep 17 00:00:00 2001 From: omuretsu <84951833+Snarling@users.noreply.github.com> Date: Thu, 3 Nov 2022 08:39:34 -0400 Subject: [PATCH] Fix sleeves unable to commit crime --- src/NetscriptFunctions/Sleeve.ts | 2 +- src/PersonObjects/Sleeve/Sleeve.ts | 3 +-- src/PersonObjects/Sleeve/ui/SleeveElem.tsx | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index f0300183f..a22dd711c 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -71,7 +71,7 @@ export function NetscriptSleeve(): InternalAPI { checkSleeveNumber(ctx, sleeveNumber); const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType); if (crime == null) return false; - return Player.sleeves[sleeveNumber].commitCrime(crime.name); + return Player.sleeves[sleeveNumber].commitCrime(crime.type); }, setToUniversityCourse: (ctx) => (_sleeveNumber, _universityName, _className) => { const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber); diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 48fdc683c..480c165b0 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -94,8 +94,7 @@ export class Sleeve extends Person { } /** Commit crimes */ - commitCrime(type: string): boolean { - if (!checkEnum(CrimeType, type)) return false; + commitCrime(type: CrimeType): boolean { this.startWork(new SleeveCrimeWork(type)); return true; } diff --git a/src/PersonObjects/Sleeve/ui/SleeveElem.tsx b/src/PersonObjects/Sleeve/ui/SleeveElem.tsx index 68bb7d4fc..b1cb67cde 100644 --- a/src/PersonObjects/Sleeve/ui/SleeveElem.tsx +++ b/src/PersonObjects/Sleeve/ui/SleeveElem.tsx @@ -20,6 +20,8 @@ import { isSleeveInfiltrateWork } from "../Work/SleeveInfiltrateWork"; import { isSleeveSupportWork } from "../Work/SleeveSupportWork"; import { isSleeveBladeburnerWork } from "../Work/SleeveBladeburnerWork"; import { isSleeveCrimeWork } from "../Work/SleeveCrimeWork"; +import { findCrime } from "../../../Crime/CrimeHelpers"; +import { CrimeType } from "../../../utils/WorkType"; interface IProps { sleeve: Sleeve; @@ -44,7 +46,8 @@ export function SleeveElem(props: IProps): React.ReactElement { props.sleeve.workForFaction(abc[1], abc[2]); break; case "Commit Crime": - props.sleeve.commitCrime(abc[1]); + const crimeType = findCrime(abc[1])?.type ?? CrimeType.SHOPLIFT; + props.sleeve.commitCrime(crimeType); break; case "Take University Course": props.sleeve.takeUniversityCourse(abc[2], abc[1]);