Replace mass getters with a single method

This commit is contained in:
Sirz Benjie 2025-08-11 17:25:20 -05:00
parent 6d4bc5f3bf
commit a7e8f9a7e1
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
2 changed files with 11 additions and 111 deletions

View File

@ -96,115 +96,12 @@ export class RibbonData {
} }
} }
//#region getters /**
/** Ribbon for completing the game in classic mode */ * Check if a specific ribbon has been awarded
public get classic(): boolean { * @param flag - The ribbon to check
return !!(this.payload & RibbonData.CLASSIC); * @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
} }

View File

@ -45,6 +45,7 @@ import type { Variant } from "#sprites/variant";
import { getVariantIcon, getVariantTint } from "#sprites/variant"; import { getVariantIcon, getVariantTint } from "#sprites/variant";
import { achvs } from "#system/achv"; import { achvs } from "#system/achv";
import type { DexAttrProps, StarterAttributes, StarterMoveset } from "#system/game-data"; import type { DexAttrProps, StarterAttributes, StarterMoveset } from "#system/game-data";
import { RibbonData } from "#system/ribbons/ribbon-data";
import { SettingKeyboard } from "#system/settings-keyboard"; import { SettingKeyboard } from "#system/settings-keyboard";
import type { DexEntry } from "#types/dex-data"; import type { DexEntry } from "#types/dex-data";
import type { OptionSelectItem } from "#ui/abstract-option-select-ui-handler"; import type { OptionSelectItem } from "#ui/abstract-option-select-ui-handler";
@ -3290,7 +3291,9 @@ export class StarterSelectUiHandler extends MessageUiHandler {
); );
container.classicWinIcon container.classicWinIcon
.setVisible(gameData.starterData[speciesId].classicWinCount > 0) .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); container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false);
// 'Candy Icon' mode // 'Candy Icon' mode