From a7e8f9a7e12f7dcb7022f654c4ef00d6845bd93b Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Mon, 11 Aug 2025 17:25:20 -0500 Subject: [PATCH] Replace mass getters with a single method --- src/system/ribbons/ribbon-data.ts | 117 ++-------------------------- src/ui/starter-select-ui-handler.ts | 5 +- 2 files changed, 11 insertions(+), 111 deletions(-) diff --git a/src/system/ribbons/ribbon-data.ts b/src/system/ribbons/ribbon-data.ts index d85c6d931ba..a0e29e9e2f2 100644 --- a/src/system/ribbons/ribbon-data.ts +++ b/src/system/ribbons/ribbon-data.ts @@ -96,115 +96,12 @@ export class RibbonData { } } - //#region getters - /** Ribbon for completing the game in classic mode */ - public get classic(): boolean { - return !!(this.payload & RibbonData.CLASSIC); + /** + * Check if a specific ribbon has been awarded + * @param flag - The ribbon to check + * @returns Whether the specified flag has been awarded + */ + public has(flag: RibbonFlag): boolean { + return !!(this.payload & flag); } - - /** Ribbon for completing a Nuzlocke challenge */ - public get nuzlocke(): boolean { - return !!(this.payload & RibbonData.NUZLOCKE); - } - - /** Ribbon for reaching max friendship with a Pokémon */ - public get maxFriendship(): boolean { - return !!(this.payload & RibbonData.FRIENDSHIP); - } - - /** Ribbon for completing the normal monotype challenge */ - public get monoNormal(): boolean { - return !!(this.payload & RibbonData.MONO_NORMAL); - } - - /** Ribbon for completing the flying monotype challenge */ - public get monoFlying(): boolean { - return !!(this.payload & RibbonData.MONO_FLYING); - } - - /** Ribbon for completing the poison monotype challenge */ - public get monoPoison(): boolean { - return !!(this.payload & RibbonData.MONO_POISON); - } - - /** Ribbon for completing the ground monotype challenge */ - public get monoGround(): boolean { - return !!(this.payload & RibbonData.MONO_GROUND); - } - - /** Ribbon for completing the rock monotype challenge */ - public get monoRock(): boolean { - return !!(this.payload & RibbonData.MONO_ROCK); - } - - /** Ribbon for completing the bug monotype challenge */ - public get monoBug(): boolean { - return !!(this.payload & RibbonData.MONO_BUG); - } - - /** Ribbon for completing the ghost monotype challenge */ - public get monoGhost(): boolean { - return !!(this.payload & RibbonData.MONO_GHOST); - } - - /** Ribbon for completing the steel monotype challenge */ - public get monoSteel(): boolean { - return !!(this.payload & RibbonData.MONO_STEEL); - } - - /** Ribbon for completing the fire monotype challenge */ - public get monoFire(): boolean { - return !!(this.payload & RibbonData.MONO_FIRE); - } - - /** Ribbon for completing the water monotype challenge */ - public get monoWater(): boolean { - return !!(this.payload & RibbonData.MONO_WATER); - } - - /** Ribbon for completing the grass monotype challenge */ - public get monoGrass(): boolean { - return !!(this.payload & RibbonData.MONO_GRASS); - } - - /** Ribbon for completing the electric monotype challenge */ - public get monoElectric(): boolean { - return !!(this.payload & RibbonData.MONO_ELECTRIC); - } - - /** Ribbon for completing the psychic monotype challenge */ - public get monoPsychic(): boolean { - return !!(this.payload & RibbonData.MONO_PSYCHIC); - } - - /** Ribbon for completing the ice monotype challenge */ - public get monoIce(): boolean { - return !!(this.payload & RibbonData.MONO_ICE); - } - - /** Ribbon for completing the dragon monotype challenge */ - public get monoDragon(): boolean { - return !!(this.payload & RibbonData.MONO_DRAGON); - } - - /** Ribbon for completing the dark monotype challenge */ - public get monoDark(): boolean { - return !!(this.payload & RibbonData.MONO_DARK); - } - - /** Ribbon for completing the fairy monotype challenge */ - public get monoFairy(): boolean { - return !!(this.payload & RibbonData.MONO_FAIRY); - } - - /** Ribbon for completing fighting the monotype challenge */ - public get monoFighting(): boolean { - return !!(this.payload & RibbonData.MONO_FIGHTING); - } - - /** Ribbon for completing any monogen challenge */ - public get monoGen(): boolean { - return !!(this.payload & RibbonData.MONO_GEN); - } - //#endregion getters } diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 19663bd8606..82467506720 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -45,6 +45,7 @@ import type { Variant } from "#sprites/variant"; import { getVariantIcon, getVariantTint } from "#sprites/variant"; import { achvs } from "#system/achv"; import type { DexAttrProps, StarterAttributes, StarterMoveset } from "#system/game-data"; +import { RibbonData } from "#system/ribbons/ribbon-data"; import { SettingKeyboard } from "#system/settings-keyboard"; import type { DexEntry } from "#types/dex-data"; import type { OptionSelectItem } from "#ui/abstract-option-select-ui-handler"; @@ -3290,7 +3291,9 @@ export class StarterSelectUiHandler extends MessageUiHandler { ); container.classicWinIcon .setVisible(gameData.starterData[speciesId].classicWinCount > 0) - .setTexture(gameData.dexData[speciesId].ribbons.nuzlocke ? "champion_ribbon_emerald" : "champion_ribbon"); + .setTexture( + gameData.dexData[speciesId].ribbons.has(RibbonData.NUZLOCKE) ? "champion_ribbon_emerald" : "champion_ribbon", + ); container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false); // 'Candy Icon' mode