From c2b51356275eae32b420fbf6eca0a335a3abaf2a Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 12 Nov 2023 00:55:13 -0500 Subject: [PATCH] Fix display issue with unlocked hidden achievements --- src/battle-scene.ts | 3 ++- src/pokemon.ts | 2 ++ src/system/achv.ts | 12 +++++++++++- src/ui/achvs-ui-handler.ts | 8 ++++---- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 57febab7f35..b170308f534 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -34,7 +34,7 @@ import SettingsUiHandler from './ui/settings-ui-handler'; import MessageUiHandler from './ui/message-ui-handler'; import { Species } from './data/species'; import InvertPostFX from './pipelines/invert'; -import { Achv, achvs } from './system/achv'; +import { Achv, ModifierAchv, achvs } from './system/achv'; const enableAuto = true; const quickStart = false; @@ -1177,6 +1177,7 @@ export default class BattleScene extends Phaser.Scene { addModifier(modifier: Modifier, ignoreUpdate?: boolean, playSound?: boolean, virtual?: boolean): Promise { return new Promise(resolve => { const soundName = modifier.type.soundName; + this.validateAchvs(ModifierAchv, modifier); if (modifier instanceof PersistentModifier) { if ((modifier as PersistentModifier).add(this.modifiers, !!virtual)) { if (playSound && !this.sound.get(soundName)) diff --git a/src/pokemon.ts b/src/pokemon.ts index fe8910826b0..0f0bf227826 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -1466,6 +1466,8 @@ export class PlayerPokemon extends Pokemon { this.fusionGender = pokemon.gender; } + this.scene.validateAchv(achvs.SPLICE); + this.calculateStats(); this.generateCompatibleTms(); this.updateInfo(true).then(() => { diff --git a/src/system/achv.ts b/src/system/achv.ts index 0a5f791c31c..ab6d7ab1462 100644 --- a/src/system/achv.ts +++ b/src/system/achv.ts @@ -1,5 +1,7 @@ +import { Modifier } from "typescript"; import BattleScene from "../battle-scene"; import * as Utils from "../utils"; +import { TurnHeldItemTransferModifier } from "../modifier/modifier"; export enum AchvTier { COMMON, @@ -90,6 +92,12 @@ export class LevelAchv extends Achv { } } +export class ModifierAchv extends Achv { + constructor(name: string, description: string, iconImage: string, score: integer, modifierFunc: (modifier: Modifier) => boolean) { + super(name, description, iconImage, score, (_scene: BattleScene, args: any[]) => modifierFunc((args[0] as Modifier))); + } +} + export const achvs = { _10K_MONEY: new MoneyAchv('Money Haver', 10000, 'nugget', 10), _100K_MONEY: new MoneyAchv('Rich', 100000, 'big_nugget', 25).setSecret(true), @@ -106,7 +114,9 @@ export const achvs = { LV_100: new LevelAchv('But Wait, There\'s More!', 50, 'rare_candy', 50).setSecret(), LV_250: new LevelAchv('Elite', 250, 'rarer_candy', 150).setSecret(true), LV_1000: new LevelAchv('To Go Even Further Beyond', 250, 'candy_jar', 400).setSecret(true), - TRANSFER_MAX_BATTLE_STAT: new Achv('Teamwork', 'Baton pass to another party member with at least one stat maxed out', 'stick', 25), + TRANSFER_MAX_BATTLE_STAT: new Achv('Teamwork', 'Baton pass to another party member with at least one stat maxed out', 'stick', 40), + SPLICE: new Achv('Infinite Fusion', 'Splice two Pokémon together with DNA Splicers', 'dna_splicers', 25), + MINI_BLACK_HOLE: new ModifierAchv('A Hole Lot of Items', 'Acquire a Mini Black Hole', 'mini_black_hole', 40, modifier => modifier instanceof TurnHeldItemTransferModifier).setSecret(), CATCH_LEGENDARY: new Achv('Legendary', 'Catch a legendary Pokémon', 'mb', 100).setSecret(), CATCH_MYTHICAL: new Achv('Mythical', 'Catch a mythical Pokémon', 'strange_ball', 100).setSecret(), SEE_SHINY: new Achv('Shiny', 'Find a shiny Pokémon in the wild', 'pb_gold', 150).setSecret(), diff --git a/src/ui/achvs-ui-handler.ts b/src/ui/achvs-ui-handler.ts index e693e6f7514..ab08f4600cd 100644 --- a/src/ui/achvs-ui-handler.ts +++ b/src/ui/achvs-ui-handler.ts @@ -112,7 +112,7 @@ export default class AchvsUiHandler extends MessageUiHandler { Object.values(achvs).forEach((achv: Achv, i: integer) => { const icon = this.achvIcons[i]; const unlocked = achvUnlocks.hasOwnProperty(achv.id); - const hidden = achv.secret && (!achv.parentId || !achvUnlocks.hasOwnProperty(achv.parentId)); + const hidden = !unlocked && achv.secret && (!achv.parentId || !achvUnlocks.hasOwnProperty(achv.parentId)); const tinted = !hidden && !unlocked; icon.setFrame(!hidden ? achv.iconImage : 'unknown'); @@ -133,7 +133,7 @@ export default class AchvsUiHandler extends MessageUiHandler { protected showAchv(achv: Achv) { const achvUnlocks = this.scene.gameData.achvUnlocks; const unlocked = achvUnlocks.hasOwnProperty(achv.id); - const hidden = achv.secret && (!achv.parentId || !achvUnlocks.hasOwnProperty(achv.parentId)); + const hidden = !unlocked && achv.secret && (!achv.parentId || !achvUnlocks.hasOwnProperty(achv.parentId)); this.titleText.setText(unlocked ? achv.name : '???'); this.showText(!hidden ? achv.description : ''); @@ -160,11 +160,11 @@ export default class AchvsUiHandler extends MessageUiHandler { success = this.setCursor(this.cursor + 17); break; case Button.LEFT: - if (this.cursor % 17) + if (this.cursor) success = this.setCursor(this.cursor - 1); break; case Button.RIGHT: - if (this.cursor % 17 < 16 && this.cursor < Object.keys(achvs).length - 1) + if (this.cursor < Object.keys(achvs).length - 1) success = this.setCursor(this.cursor + 1); break; }