From 5ab3b2dab6090b24f5c18dd0df56ed50ab285073 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 19 Apr 2023 00:35:06 -0400 Subject: [PATCH] Fix crash related to weather and issue with level up stats --- src/battle-phases.ts | 9 ++++----- src/battle-scene.ts | 7 +++---- src/modifier.ts | 6 +++++- src/ui/battle-message-ui-handler.ts | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index de7632c9e95..e3a888ef22c 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -22,6 +22,7 @@ import { BattleTagLapseType, BattleTagType, HideSpriteTag as HiddenTag } from ". import { getPokemonMessage } from "./messages"; import { Starter } from "./ui/starter-select-ui-handler"; import { Gender } from "./gender"; +import { getRandomWeatherType } from "./weather"; export class SelectStarterPhase extends BattlePhase { constructor(scene: BattleScene) { @@ -151,6 +152,8 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase { } doEncounter(): void { + this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena.biomeType), false); + const enemyPokemon = this.scene.getEnemyPokemon(); this.scene.tweens.add({ targets: [ this.scene.arenaEnemy, enemyPokemon ], @@ -1081,10 +1084,6 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { } } -export class WeatherPhase extends BattlePhase { - -} - export class MessagePhase extends BattlePhase { private text: string; private callbackDelay: integer; @@ -1296,7 +1295,7 @@ export class LevelUpPhase extends PartyMemberPokemonPhase { pokemon.calculateStats(); pokemon.updateInfo(); this.scene.playSoundWithoutBgm('level_up_fanfare', 1500); - this.scene.ui.showText(`${this.getPokemon().name} grew to\nLV. ${this.level}!`, null, () => this.scene.ui.getMessageHandler().promptLevelUpStats(prevStats, false, () => this.end()), null, true); + this.scene.ui.showText(`${this.getPokemon().name} grew to\nLV. ${this.level}!`, null, () => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false, () => this.end()), null, true); const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1); for (let lm of levelMoves) this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); diff --git a/src/battle-scene.ts b/src/battle-scene.ts index a91f289d63f..f6417544a5a 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -438,7 +438,6 @@ export default class BattleScene extends Phaser.Scene { newArena(biome: Biome): Arena { this.arena = new Arena(this, biome, Biome[biome].toLowerCase()); - this.arena.trySetWeather(getRandomWeatherType(this.arena.biomeType), false); return this.arena; } @@ -482,7 +481,7 @@ export default class BattleScene extends Phaser.Scene { } else if (this.isButtonPressed(Button.SPEED_UP)) { if (!this.auto) { - if (this.gameSpeed < 2) + if (this.gameSpeed < 2.5) this.gameSpeed += 0.25; } else if (this.gameSpeed < 20) this.gameSpeed++; @@ -498,8 +497,8 @@ export default class BattleScene extends Phaser.Scene { this.auto = !this.auto; if (this.auto) this.gameSpeed = Math.floor(this.gameSpeed); - else if (this.gameSpeed > 2) - this.gameSpeed = 2; + else if (this.gameSpeed > 2.5) + this.gameSpeed = 2.5; } else return; } else diff --git a/src/modifier.ts b/src/modifier.ts index 15ee6387fa7..ec8e85db6bb 100644 --- a/src/modifier.ts +++ b/src/modifier.ts @@ -402,7 +402,7 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { restorePoints = Math.floor(restorePoints * (args[1] as number)); else pokemon.resetStatus(); - pokemon.hp = Math.min(pokemon.hp + (this.percent ? (restorePoints * 0.01) * pokemon.getMaxHp() : restorePoints), pokemon.getMaxHp()); + pokemon.hp = Math.min(pokemon.hp + Math.ceil((this.percent ? (restorePoints * 0.01) * pokemon.getMaxHp() : restorePoints)), pokemon.getMaxHp()); } return true; @@ -625,6 +625,10 @@ export class ExpShareModifier extends PersistentModifier { super(type); } + match(modifier: Modifier): boolean { + return modifier instanceof ExpShareModifier; + } + apply(_args: any[]): boolean { return true; } diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index d417d4f33e1..e9caa9786fe 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -105,8 +105,8 @@ export default class BattleMessageUiHandler extends MessageUiHandler { super.clear(); } - promptLevelUpStats(prevStats: integer[], showTotals: boolean, callback?: Function) { - const newStats = (this.scene as BattleScene).getPlayerPokemon().stats; + promptLevelUpStats(partyMemberIndex: integer, prevStats: integer[], showTotals: boolean, callback?: Function) { + const newStats = (this.scene as BattleScene).getParty()[partyMemberIndex].stats; let levelUpStatsValuesText = ''; const stats = Utils.getEnumValues(Stat); for (let s of stats) @@ -117,7 +117,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler { this.awaitingActionInput = true; this.onActionInput = () => { if (!showTotals) - this.promptLevelUpStats(null, true, callback); + this.promptLevelUpStats(partyMemberIndex, null, true, callback); else { this.levelUpStatsContainer.setVisible(false); if (callback)