Fix crash related to weather and issue with level up stats

pull/1/head
Flashfyre 2023-04-19 00:35:06 -04:00
parent 5a1de4d9a5
commit 5ab3b2dab6
4 changed files with 15 additions and 13 deletions

View File

@ -22,6 +22,7 @@ import { BattleTagLapseType, BattleTagType, HideSpriteTag as HiddenTag } from ".
import { getPokemonMessage } from "./messages"; import { getPokemonMessage } from "./messages";
import { Starter } from "./ui/starter-select-ui-handler"; import { Starter } from "./ui/starter-select-ui-handler";
import { Gender } from "./gender"; import { Gender } from "./gender";
import { getRandomWeatherType } from "./weather";
export class SelectStarterPhase extends BattlePhase { export class SelectStarterPhase extends BattlePhase {
constructor(scene: BattleScene) { constructor(scene: BattleScene) {
@ -151,6 +152,8 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase {
} }
doEncounter(): void { doEncounter(): void {
this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena.biomeType), false);
const enemyPokemon = this.scene.getEnemyPokemon(); const enemyPokemon = this.scene.getEnemyPokemon();
this.scene.tweens.add({ this.scene.tweens.add({
targets: [ this.scene.arenaEnemy, enemyPokemon ], targets: [ this.scene.arenaEnemy, enemyPokemon ],
@ -1081,10 +1084,6 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
} }
} }
export class WeatherPhase extends BattlePhase {
}
export class MessagePhase extends BattlePhase { export class MessagePhase extends BattlePhase {
private text: string; private text: string;
private callbackDelay: integer; private callbackDelay: integer;
@ -1296,7 +1295,7 @@ export class LevelUpPhase extends PartyMemberPokemonPhase {
pokemon.calculateStats(); pokemon.calculateStats();
pokemon.updateInfo(); pokemon.updateInfo();
this.scene.playSoundWithoutBgm('level_up_fanfare', 1500); 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); const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1);
for (let lm of levelMoves) for (let lm of levelMoves)
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm));

View File

@ -438,7 +438,6 @@ export default class BattleScene extends Phaser.Scene {
newArena(biome: Biome): Arena { newArena(biome: Biome): Arena {
this.arena = new Arena(this, biome, Biome[biome].toLowerCase()); this.arena = new Arena(this, biome, Biome[biome].toLowerCase());
this.arena.trySetWeather(getRandomWeatherType(this.arena.biomeType), false);
return this.arena; return this.arena;
} }
@ -482,7 +481,7 @@ export default class BattleScene extends Phaser.Scene {
} }
else if (this.isButtonPressed(Button.SPEED_UP)) { else if (this.isButtonPressed(Button.SPEED_UP)) {
if (!this.auto) { if (!this.auto) {
if (this.gameSpeed < 2) if (this.gameSpeed < 2.5)
this.gameSpeed += 0.25; this.gameSpeed += 0.25;
} else if (this.gameSpeed < 20) } else if (this.gameSpeed < 20)
this.gameSpeed++; this.gameSpeed++;
@ -498,8 +497,8 @@ export default class BattleScene extends Phaser.Scene {
this.auto = !this.auto; this.auto = !this.auto;
if (this.auto) if (this.auto)
this.gameSpeed = Math.floor(this.gameSpeed); this.gameSpeed = Math.floor(this.gameSpeed);
else if (this.gameSpeed > 2) else if (this.gameSpeed > 2.5)
this.gameSpeed = 2; this.gameSpeed = 2.5;
} else } else
return; return;
} else } else

View File

@ -402,7 +402,7 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier {
restorePoints = Math.floor(restorePoints * (args[1] as number)); restorePoints = Math.floor(restorePoints * (args[1] as number));
else else
pokemon.resetStatus(); 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; return true;
@ -625,6 +625,10 @@ export class ExpShareModifier extends PersistentModifier {
super(type); super(type);
} }
match(modifier: Modifier): boolean {
return modifier instanceof ExpShareModifier;
}
apply(_args: any[]): boolean { apply(_args: any[]): boolean {
return true; return true;
} }

View File

@ -105,8 +105,8 @@ export default class BattleMessageUiHandler extends MessageUiHandler {
super.clear(); super.clear();
} }
promptLevelUpStats(prevStats: integer[], showTotals: boolean, callback?: Function) { promptLevelUpStats(partyMemberIndex: integer, prevStats: integer[], showTotals: boolean, callback?: Function) {
const newStats = (this.scene as BattleScene).getPlayerPokemon().stats; const newStats = (this.scene as BattleScene).getParty()[partyMemberIndex].stats;
let levelUpStatsValuesText = ''; let levelUpStatsValuesText = '';
const stats = Utils.getEnumValues(Stat); const stats = Utils.getEnumValues(Stat);
for (let s of stats) for (let s of stats)
@ -117,7 +117,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler {
this.awaitingActionInput = true; this.awaitingActionInput = true;
this.onActionInput = () => { this.onActionInput = () => {
if (!showTotals) if (!showTotals)
this.promptLevelUpStats(null, true, callback); this.promptLevelUpStats(partyMemberIndex, null, true, callback);
else { else {
this.levelUpStatsContainer.setVisible(false); this.levelUpStatsContainer.setVisible(false);
if (callback) if (callback)