From 5a1de4d9a57b43c8daa8fae60ad3545c4900796a Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 18 Apr 2023 23:54:07 -0400 Subject: [PATCH] Fix weather and add wave display --- src/arena.ts | 2 +- src/battle-phases.ts | 7 ++++--- src/battle-scene.ts | 16 ++++++++++++++++ src/ui/starter-select-ui-handler.ts | 5 +---- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/arena.ts b/src/arena.ts index 5623b71ed..ffa5f8400 100644 --- a/src/arena.ts +++ b/src/arena.ts @@ -98,7 +98,7 @@ export class Arena { } trySetWeather(weather: WeatherType, viaMove: boolean): boolean { - if (this.weather?.weatherType === (weather || null)) + if (this.weather?.weatherType === (weather || undefined)) return false; const oldWeatherType = this.weather?.weatherType || WeatherType.NONE; diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 7ababcdd3..de7632c9e 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -65,6 +65,8 @@ export class EncounterPhase extends BattlePhase { start() { super.start(); + this.scene.updateWaveText(); + const battle = this.scene.currentBattle; const enemySpecies = this.scene.arena.randomSpecies(1, battle.enemyLevel); battle.enemyPokemon = new EnemyPokemon(this.scene, enemySpecies, battle.enemyLevel); @@ -617,7 +619,6 @@ export abstract class MovePhase extends BattlePhase { protected pokemon: Pokemon; protected move: PokemonMove; protected followUp: boolean; - protected hasFollowUp: boolean; protected cancelled: boolean; constructor(scene: BattleScene, pokemon: Pokemon, move: PokemonMove, followUp?: boolean) { @@ -644,7 +645,7 @@ export abstract class MovePhase extends BattlePhase { const target = this.pokemon.isPlayer() ? this.scene.getEnemyPokemon() : this.scene.getPlayerPokemon(); - if (!this.followUp) + if (!this.followUp && this.canMove()) this.pokemon.lapseTags(BattleTagLapseType.MOVE); const doMove = () => { @@ -1059,7 +1060,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { start() { const pokemon = this.getPokemon(); - if (pokemon.hp && pokemon.status && pokemon.status.isPostTurn()) { + if (pokemon?.hp && pokemon.status && pokemon.status.isPostTurn()) { pokemon.status.incrementTurn(); new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => { this.scene.unshiftPhase(new MessagePhase(this.scene, diff --git a/src/battle-scene.ts b/src/battle-scene.ts index acadfbca2..a91f289d6 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -16,6 +16,8 @@ import { initGameSpeed } from './game-speed'; import { Arena } from './arena'; import { GameData } from './game-data'; import StarterSelectUiHandler from './ui/starter-select-ui-handler'; +import { getRandomWeatherType } from './weather'; +import { TextStyle, addTextObject } from './text'; const enableAuto = true; @@ -60,6 +62,7 @@ export default class BattleScene extends Phaser.Scene { public currentBattle: Battle; public pokeballCounts = Object.fromEntries(Utils.getEnumValues(PokeballType).filter(p => p <= PokeballType.MASTER_BALL).map(t => [ t, 0 ])); private party: PlayerPokemon[]; + private waveCountText: Phaser.GameObjects.Text; private modifierBar: ModifierBar; private modifiers: PersistentModifier[]; public uiContainer: Phaser.GameObjects.Container; @@ -283,6 +286,10 @@ export default class BattleScene extends Phaser.Scene { this.add.existing(this.modifierBar); uiContainer.add(this.modifierBar); + this.waveCountText = addTextObject(this, (this.game.canvas.width / 6) - 2, -(this.game.canvas.height / 6), '1', TextStyle.BATTLE_INFO); + this.waveCountText.setOrigin(1, 0); + this.fieldUI.add(this.waveCountText); + this.party = []; let loadPokemonAssets = []; @@ -425,14 +432,23 @@ export default class BattleScene extends Phaser.Scene { } this.currentBattle = new Battle((this.currentBattle?.waveIndex || 0) + 1); + return this.currentBattle; } newArena(biome: Biome): Arena { this.arena = new Arena(this, biome, Biome[biome].toLowerCase()); + this.arena.trySetWeather(getRandomWeatherType(this.arena.biomeType), false); return this.arena; } + updateWaveText(): void { + const isBoss = !(this.currentBattle.waveIndex % 10); + this.waveCountText.setText(this.currentBattle.waveIndex.toString()); + this.waveCountText.setColor(!isBoss ? '#404040' : '#f89890'); + this.waveCountText.setShadowColor(!isBoss ? '#ded6b5' : '#984038'); + } + randomSpecies(level: integer, fromArenaPool?: boolean): PokemonSpecies { return fromArenaPool ? this.arena.randomSpecies(1, level) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 32768e1f7..fb8090ea3 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -162,7 +162,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`); this.starterSelectContainer.add(this.pokemonSprite); - this.instructionsText = addTextObject(this.scene, 1, 132, '', TextStyle.PARTY); + this.instructionsText = addTextObject(this.scene, 1, 132, '', TextStyle.PARTY, { fontSize: '52px' }); this.starterSelectContainer.add(this.instructionsText); this.starterSelectMessageBoxContainer = this.scene.add.container(0, this.scene.game.canvas.height / 6); @@ -346,9 +346,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler { instructionLines.push('G: Cycle Gender'); } - if (instructionLines.length >= 4) - instructionLines[2] += ` ${instructionLines.splice(3, 1)[0]}`; - this.instructionsText.setText(instructionLines.join('\n')); }