Fix display issue with unlocked hidden achievements

pull/2/head
Flashfyre 2023-11-12 00:55:13 -05:00
parent 729b70c6a6
commit c2b5135627
4 changed files with 19 additions and 6 deletions

View File

@ -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<void> {
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))

View File

@ -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(() => {

View File

@ -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(),

View File

@ -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;
}