From 3a517fbffa1a9c3b74b06cb9db4270f0ec3327e0 Mon Sep 17 00:00:00 2001 From: Richard Snider Date: Fri, 20 Mar 2026 00:55:58 -0600 Subject: [PATCH] add botanics completion amount support --- src/patches/botanics.ts | 34 ++++++++++++++++++++++++++++++++++ src/patches/index.ts | 2 ++ src/types/multiworld-model.ts | 3 ++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/patches/botanics.ts diff --git a/src/patches/botanics.ts b/src/patches/botanics.ts new file mode 100644 index 0000000..d164f2c --- /dev/null +++ b/src/patches/botanics.ts @@ -0,0 +1,34 @@ +import type MwRandomizer from "../plugin"; + +declare global { + namespace sc { + interface MenuModel { + } + } +} + +export function patch(plugin: MwRandomizer) { + sc.MenuModel.inject({ + getTotalDropsFoundAndCompleted(percentage) { + const max = sc.multiworld.options.botanicsCompletionAmount; + if (max === undefined) { + return this.parent(percentage); + } + + let numFound = 0; + + Object.entries(this.drops).forEach(([key, drop]) => { + if ( + drop.track && + sc.stats.getMap("exploration", "dropFound-" + key) && + this.dropCounts[key] && + this.dropCounts[key].completed + ) { + numFound++; + } + }); + + return percentage ? numFound / max : numFound; + } + }); +} diff --git a/src/patches/index.ts b/src/patches/index.ts index c444885..bd885e9 100644 --- a/src/patches/index.ts +++ b/src/patches/index.ts @@ -1,6 +1,7 @@ import type MwRandomizer from "../plugin"; import { patch as patchMwModel } from "./multiworld-model"; +import { patch as patchBotanics } from "./botanics"; import { patch as patchChest } from "./chest"; import { patch as patchEntities } from "./entity"; import { patch as patchEvent } from "./event"; @@ -18,6 +19,7 @@ import { patch as patchDeathLink } from "./deathlink.ts"; export function applyPatches(plugin: MwRandomizer) { patchMwModel(plugin); + patchBotanics(plugin); patchChest(plugin); patchEntities(plugin); patchEvent(plugin); diff --git a/src/types/multiworld-model.ts b/src/types/multiworld-model.ts index b34d72d..893426e 100644 --- a/src/types/multiworld-model.ts +++ b/src/types/multiworld-model.ts @@ -92,7 +92,8 @@ declare global { shopSendMode?: string, shopReceiveMode?: string, shopDialogHints?: boolean, - chestClearanceLevels?: Record + chestClearanceLevels?: Record, + botanicsCompletionAmount?: number, }; export type MultiworldVars = {