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 = {