From 548849e6f274f7ebec164b5d695115021cc202cf Mon Sep 17 00:00:00 2001 From: horrible little slime <69secret69email69@gmail.com> Date: Sun, 13 Oct 2024 14:54:52 -0400 Subject: [PATCH] initialize defaults of certain functions in a different way --- packages/garbo-lib/src/wanderer/index.ts | 10 +----- packages/garbo/src/combat.ts | 31 +++++++--------- .../garbo/src/familiar/freeFightFamiliar.ts | 36 +++++++------------ packages/garbo/src/lib.ts | 23 +++++------- 4 files changed, 35 insertions(+), 65 deletions(-) diff --git a/packages/garbo-lib/src/wanderer/index.ts b/packages/garbo-lib/src/wanderer/index.ts index aa3c8ab1b..f3159353c 100644 --- a/packages/garbo-lib/src/wanderer/index.ts +++ b/packages/garbo-lib/src/wanderer/index.ts @@ -142,11 +142,6 @@ export type WanderOptions = { export type WanderDetails = DraggableFight | WanderOptions; -const defaultWanderOptions = { - drunkSafe: true, - allowEquipment: true, -}; - export class WandererManager { private unsupportedChoices = new Map< Location, @@ -254,10 +249,7 @@ export class WandererManager { const { draggableFight, options } = isDraggableFight(wanderer) ? { draggableFight: wanderer, options: {} } : { draggableFight: wanderer.wanderer, options: wanderer }; - const { drunkSafe, allowEquipment } = { - ...defaultWanderOptions, - ...options, - }; + const { drunkSafe = true, allowEquipment = false } = options; const newKey = `${myTotalTurnsSpent()};${totalTurnsPlayed()};${get( "familiarSweat", )}`; diff --git a/packages/garbo/src/combat.ts b/packages/garbo/src/combat.ts index 462e64e98..86aa89528 100644 --- a/packages/garbo/src/combat.ts +++ b/packages/garbo/src/combat.ts @@ -868,28 +868,23 @@ type CustomizeMacroOptions = { tentacle: (macro: StrictMacro) => Macro; innateWanderer: (macro: StrictMacro) => Macro; }; -const DEFAULT_MACRO_OPTIONS = { - freeWanderer: () => Macro.basicCombat(), - tentacle: () => Macro.basicCombat(), - innateWanderer: (macro: StrictMacro) => - Macro.externalIf( - haveEquipped($item`backup camera`) && - get("_backUpUses") < 11 && - get("lastCopyableMonster") === globalOptions.target && - (!targettingMeat() || myFamiliar() === meatFamiliar()), - Macro.skill($skill`Back-Up to your Last Enemy`).step(macro), - Macro.basicCombat(), - ), -} as const satisfies CustomizeMacroOptions; function customizeMacro( macro: M, - options: Partial = {}, + { + freeWanderer = () => Macro.basicCombat(), + tentacle = () => Macro.basicCombat(), + innateWanderer = (macro: StrictMacro) => + Macro.externalIf( + haveEquipped($item`backup camera`) && + get("_backUpUses") < 11 && + get("lastCopyableMonster") === globalOptions.target && + (!targettingMeat() || myFamiliar() === meatFamiliar()), + Macro.skill($skill`Back-Up to your Last Enemy`).step(macro), + Macro.basicCombat(), + ), + } = {} as Partial, ) { - const { freeWanderer, tentacle, innateWanderer } = { - ...DEFAULT_MACRO_OPTIONS, - ...options, - }; return Macro.if_( $monsters`giant rubber spider, time-spinner prank`, freeWanderer(macro), diff --git a/packages/garbo/src/familiar/freeFightFamiliar.ts b/packages/garbo/src/familiar/freeFightFamiliar.ts index 6e99f86b5..7a2d9a815 100644 --- a/packages/garbo/src/familiar/freeFightFamiliar.ts +++ b/packages/garbo/src/familiar/freeFightFamiliar.ts @@ -36,28 +36,18 @@ type MenuOptions = Partial<{ allowAttackFamiliars: boolean; mode: "barf" | "free" | "target"; }>; -const DEFAULT_MENU_OPTIONS = { - canChooseMacro: true, - location: $location`none`, - extraFamiliars: [], - excludeFamiliar: [], - includeExperienceFamiliars: true, - allowAttackFamiliars: true, - mode: "free", -} as const; -export function menu(options: MenuOptions = {}): GeneralFamiliar[] { - const { - includeExperienceFamiliars, - canChooseMacro, - location, - extraFamiliars, - excludeFamiliar, - allowAttackFamiliars, - mode, - } = { - ...DEFAULT_MENU_OPTIONS, - ...options, - }; + +export function menu( + { + canChooseMacro = true, + location = $location`none`, + extraFamiliars = [], + excludeFamiliar = [], + includeExperienceFamiliars = true, + allowAttackFamiliars = true, + mode = "free", + } = {} as MenuOptions, +): GeneralFamiliar[] { const familiarMenu = [ ...getConstantValueFamiliars(mode), ...getDropFamiliars(), @@ -179,7 +169,7 @@ export function getAllJellyfishDrops(): { } export function freeFightFamiliarData( - options: MenuOptions = {}, + options: Partial = {}, ): GeneralFamiliar { const compareFamiliars = (a: GeneralFamiliar, b: GeneralFamiliar) => { if (a === null) return b; diff --git a/packages/garbo/src/lib.ts b/packages/garbo/src/lib.ts index 235aedfed..f857cecfa 100644 --- a/packages/garbo/src/lib.ts +++ b/packages/garbo/src/lib.ts @@ -715,23 +715,16 @@ type LastAdventureOptions = { includeJuneCleaver: boolean; includeVioletFog: boolean; }; -const DEFAULT_LAST_ADVENTURE_OPTIONS = { - extraEncounters: [], - includeGhostDog: true, - includeHolidayWanderers: true, - includeJuneCleaver: true, - includeVioletFog: true, -} as const; + export function lastAdventureWasWeird( - options: Partial = {}, + { + extraEncounters = [], + includeGhostDog = true, + includeHolidayWanderers = true, + includeJuneCleaver = true, + includeVioletFog = true, + } = {} as Partial, ): boolean { - const { - extraEncounters, - includeGhostDog, - includeHolidayWanderers, - includeJuneCleaver, - includeVioletFog, - } = { ...DEFAULT_LAST_ADVENTURE_OPTIONS, ...options }; return [ ...extraEncounters, ...(includeGhostDog ? GHOST_DOG_ADVENTURES : []),