From b6f6ba86317d24c63096177a1ec601f5b241e39b Mon Sep 17 00:00:00 2001 From: CatLover <152669316+catloversg@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:06:19 +0700 Subject: [PATCH] CODEBASE: Minor change in TaskSelector of Sleeve (follow-up of #1807) --- src/PersonObjects/Sleeve/ui/TaskSelector.tsx | 24 ++++---------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx index 6bd3fcb0bc..c0f5926bac 100644 --- a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx +++ b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx @@ -9,6 +9,7 @@ import { Crimes } from "../../../Crime/Crimes"; import { Factions } from "../../../Faction/Factions"; import { getEnumHelper } from "../../../utils/EnumHelper"; import { SleeveWorkType } from "../Work/Work"; +import { getRecordKeys } from "../../../Types/Record"; const universitySelectorOptions: string[] = [ "Computer Science", @@ -216,18 +217,7 @@ const tasks: { }, }; -const canDo: { - [key: string]: undefined | ((sleeve: Sleeve) => boolean); - ["Idle"]: (sleeve: Sleeve) => boolean; - ["Work for Company"]: (sleeve: Sleeve) => boolean; - ["Work for Faction"]: (sleeve: Sleeve) => boolean; - ["Commit Crime"]: (sleeve: Sleeve) => boolean; - ["Take University Course"]: (sleeve: Sleeve) => boolean; - ["Workout at Gym"]: (sleeve: Sleeve) => boolean; - ["Perform Bladeburner Actions"]: (sleeve: Sleeve) => boolean; - ["Shock Recovery"]: (sleeve: Sleeve) => boolean; - ["Synchronize"]: (sleeve: Sleeve) => boolean; -} = { +const canDo = { Idle: () => true, "Work for Company": (sleeve: Sleeve) => possibleJobs(sleeve).length > 0, "Work for Faction": (sleeve: Sleeve) => possibleFactions(sleeve).length > 0, @@ -238,20 +228,14 @@ const canDo: { "Perform Bladeburner Actions": () => !!Player.bladeburner, "Shock Recovery": (sleeve: Sleeve) => sleeve.shock > 0, Synchronize: (sleeve: Sleeve) => sleeve.sync < 100, -}; +} as const; export function TaskSelector(props: IProps): React.ReactElement { const s0 = props.abc[0]; const s1 = props.abc[1]; const s2 = props.abc[2]; - const validActions = Object.keys(canDo).filter((taskType) => { - const canDoTask = canDo[taskType]; - if (canDoTask === undefined) { - return false; - } - return canDoTask(props.sleeve); - }); + const validActions = getRecordKeys(canDo).filter((taskType) => canDo[taskType](props.sleeve)); const detailsF = tasks[s0]; if (detailsF === undefined) {