Fix weather and add wave display
parent
89356fbfda
commit
5a1de4d9a5
|
@ -98,7 +98,7 @@ export class Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
trySetWeather(weather: WeatherType, viaMove: boolean): boolean {
|
trySetWeather(weather: WeatherType, viaMove: boolean): boolean {
|
||||||
if (this.weather?.weatherType === (weather || null))
|
if (this.weather?.weatherType === (weather || undefined))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const oldWeatherType = this.weather?.weatherType || WeatherType.NONE;
|
const oldWeatherType = this.weather?.weatherType || WeatherType.NONE;
|
||||||
|
|
|
@ -65,6 +65,8 @@ export class EncounterPhase extends BattlePhase {
|
||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
this.scene.updateWaveText();
|
||||||
|
|
||||||
const battle = this.scene.currentBattle;
|
const battle = this.scene.currentBattle;
|
||||||
const enemySpecies = this.scene.arena.randomSpecies(1, battle.enemyLevel);
|
const enemySpecies = this.scene.arena.randomSpecies(1, battle.enemyLevel);
|
||||||
battle.enemyPokemon = new EnemyPokemon(this.scene, enemySpecies, 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 pokemon: Pokemon;
|
||||||
protected move: PokemonMove;
|
protected move: PokemonMove;
|
||||||
protected followUp: boolean;
|
protected followUp: boolean;
|
||||||
protected hasFollowUp: boolean;
|
|
||||||
protected cancelled: boolean;
|
protected cancelled: boolean;
|
||||||
|
|
||||||
constructor(scene: BattleScene, pokemon: Pokemon, move: PokemonMove, followUp?: 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();
|
const target = this.pokemon.isPlayer() ? this.scene.getEnemyPokemon() : this.scene.getPlayerPokemon();
|
||||||
|
|
||||||
if (!this.followUp)
|
if (!this.followUp && this.canMove())
|
||||||
this.pokemon.lapseTags(BattleTagLapseType.MOVE);
|
this.pokemon.lapseTags(BattleTagLapseType.MOVE);
|
||||||
|
|
||||||
const doMove = () => {
|
const doMove = () => {
|
||||||
|
@ -1059,7 +1060,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
const pokemon = this.getPokemon();
|
const pokemon = this.getPokemon();
|
||||||
if (pokemon.hp && pokemon.status && pokemon.status.isPostTurn()) {
|
if (pokemon?.hp && pokemon.status && pokemon.status.isPostTurn()) {
|
||||||
pokemon.status.incrementTurn();
|
pokemon.status.incrementTurn();
|
||||||
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => {
|
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => {
|
||||||
this.scene.unshiftPhase(new MessagePhase(this.scene,
|
this.scene.unshiftPhase(new MessagePhase(this.scene,
|
||||||
|
|
|
@ -16,6 +16,8 @@ import { initGameSpeed } from './game-speed';
|
||||||
import { Arena } from './arena';
|
import { Arena } from './arena';
|
||||||
import { GameData } from './game-data';
|
import { GameData } from './game-data';
|
||||||
import StarterSelectUiHandler from './ui/starter-select-ui-handler';
|
import StarterSelectUiHandler from './ui/starter-select-ui-handler';
|
||||||
|
import { getRandomWeatherType } from './weather';
|
||||||
|
import { TextStyle, addTextObject } from './text';
|
||||||
|
|
||||||
const enableAuto = true;
|
const enableAuto = true;
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
public currentBattle: Battle;
|
public currentBattle: Battle;
|
||||||
public pokeballCounts = Object.fromEntries(Utils.getEnumValues(PokeballType).filter(p => p <= PokeballType.MASTER_BALL).map(t => [ t, 0 ]));
|
public pokeballCounts = Object.fromEntries(Utils.getEnumValues(PokeballType).filter(p => p <= PokeballType.MASTER_BALL).map(t => [ t, 0 ]));
|
||||||
private party: PlayerPokemon[];
|
private party: PlayerPokemon[];
|
||||||
|
private waveCountText: Phaser.GameObjects.Text;
|
||||||
private modifierBar: ModifierBar;
|
private modifierBar: ModifierBar;
|
||||||
private modifiers: PersistentModifier[];
|
private modifiers: PersistentModifier[];
|
||||||
public uiContainer: Phaser.GameObjects.Container;
|
public uiContainer: Phaser.GameObjects.Container;
|
||||||
|
@ -283,6 +286,10 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
this.add.existing(this.modifierBar);
|
this.add.existing(this.modifierBar);
|
||||||
uiContainer.add(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 = [];
|
this.party = [];
|
||||||
|
|
||||||
let loadPokemonAssets = [];
|
let loadPokemonAssets = [];
|
||||||
|
@ -425,14 +432,23 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentBattle = new Battle((this.currentBattle?.waveIndex || 0) + 1);
|
this.currentBattle = new Battle((this.currentBattle?.waveIndex || 0) + 1);
|
||||||
|
|
||||||
return this.currentBattle;
|
return this.currentBattle;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
randomSpecies(level: integer, fromArenaPool?: boolean): PokemonSpecies {
|
||||||
return fromArenaPool
|
return fromArenaPool
|
||||||
? this.arena.randomSpecies(1, level)
|
? this.arena.randomSpecies(1, level)
|
||||||
|
|
|
@ -162,7 +162,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`);
|
this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`);
|
||||||
this.starterSelectContainer.add(this.pokemonSprite);
|
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.starterSelectContainer.add(this.instructionsText);
|
||||||
|
|
||||||
this.starterSelectMessageBoxContainer = this.scene.add.container(0, this.scene.game.canvas.height / 6);
|
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');
|
instructionLines.push('G: Cycle Gender');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instructionLines.length >= 4)
|
|
||||||
instructionLines[2] += ` ${instructionLines.splice(3, 1)[0]}`;
|
|
||||||
|
|
||||||
this.instructionsText.setText(instructionLines.join('\n'));
|
this.instructionsText.setText(instructionLines.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue