Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize defaults of certain functions in a different way #2158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions packages/garbo-lib/src/wanderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
)}`;
Expand Down
31 changes: 13 additions & 18 deletions packages/garbo/src/combat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<M extends StrictMacro>(
macro: M,
options: Partial<CustomizeMacroOptions> = {},
{
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<CustomizeMacroOptions>,
) {
const { freeWanderer, tentacle, innateWanderer } = {
...DEFAULT_MACRO_OPTIONS,
...options,
};
return Macro.if_(
$monsters`giant rubber spider, time-spinner prank`,
freeWanderer(macro),
Expand Down
36 changes: 13 additions & 23 deletions packages/garbo/src/familiar/freeFightFamiliar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -179,7 +169,7 @@ export function getAllJellyfishDrops(): {
}

export function freeFightFamiliarData(
options: MenuOptions = {},
options: Partial<MenuOptions> = {},
): GeneralFamiliar {
const compareFamiliars = (a: GeneralFamiliar, b: GeneralFamiliar) => {
if (a === null) return b;
Expand Down
23 changes: 8 additions & 15 deletions packages/garbo/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LastAdventureOptions> = {},
{
extraEncounters = [],
includeGhostDog = true,
includeHolidayWanderers = true,
includeJuneCleaver = true,
includeVioletFog = true,
} = {} as Partial<LastAdventureOptions>,
): boolean {
const {
extraEncounters,
includeGhostDog,
includeHolidayWanderers,
includeJuneCleaver,
includeVioletFog,
} = { ...DEFAULT_LAST_ADVENTURE_OPTIONS, ...options };
return [
...extraEncounters,
...(includeGhostDog ? GHOST_DOG_ADVENTURES : []),
Expand Down
Loading