Refactor logic for summons and returns
This commit is contained in:
parent
5ec3991cb3
commit
fbcd372068
|
@ -34,7 +34,6 @@ import { Species } from "./data/species";
|
||||||
import { HealAchv, LevelAchv, MoneyAchv, achvs } from "./system/achv";
|
import { HealAchv, LevelAchv, MoneyAchv, achvs } from "./system/achv";
|
||||||
import { DexEntry } from "./system/game-data";
|
import { DexEntry } from "./system/game-data";
|
||||||
import { pokemonPrevolutions } from "./data/pokemon-evolutions";
|
import { pokemonPrevolutions } from "./data/pokemon-evolutions";
|
||||||
import { getPokemonSpecies } from "./data/pokemon-species";
|
|
||||||
|
|
||||||
export class CheckLoadPhase extends BattlePhase {
|
export class CheckLoadPhase extends BattlePhase {
|
||||||
private loaded: boolean;
|
private loaded: boolean;
|
||||||
|
@ -79,16 +78,19 @@ export class CheckLoadPhase extends BattlePhase {
|
||||||
} else
|
} else
|
||||||
this.scene.playBgm();
|
this.scene.playBgm();
|
||||||
|
|
||||||
const availablePartyMembers = this.scene.getParty().filter(p => !p.isFainted()).length;
|
|
||||||
|
|
||||||
this.scene.pushPhase(new EncounterPhase(this.scene, this.loaded));
|
this.scene.pushPhase(new EncounterPhase(this.scene, this.loaded));
|
||||||
this.scene.pushPhase(new SummonPhase(this.scene, 0));
|
|
||||||
if (this.scene.currentBattle.double && availablePartyMembers > 1)
|
if (this.loaded) {
|
||||||
this.scene.pushPhase(new SummonPhase(this.scene, 1));
|
const availablePartyMembers = this.scene.getParty().filter(p => !p.isFainted()).length;
|
||||||
if (this.scene.currentBattle.waveIndex > 1 && this.scene.currentBattle.battleType !== BattleType.TRAINER) {
|
|
||||||
this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double));
|
this.scene.pushPhase(new SummonPhase(this.scene, 0));
|
||||||
if (this.scene.currentBattle.double && availablePartyMembers > 1)
|
if (this.scene.currentBattle.double && availablePartyMembers > 1)
|
||||||
this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double));
|
this.scene.pushPhase(new SummonPhase(this.scene, 1));
|
||||||
|
if (this.scene.currentBattle.waveIndex > 1 && this.scene.currentBattle.battleType !== BattleType.TRAINER) {
|
||||||
|
this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double));
|
||||||
|
if (this.scene.currentBattle.double && availablePartyMembers > 1)
|
||||||
|
this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.end();
|
super.end();
|
||||||
|
@ -370,8 +372,9 @@ export class EncounterPhase extends BattlePhase {
|
||||||
ease: 'Sine.easeInOut',
|
ease: 'Sine.easeInOut',
|
||||||
duration: 750
|
duration: 750
|
||||||
});
|
});
|
||||||
|
const availablePartyMembers = this.scene.getEnemyParty().filter(p => !p.isFainted()).length;
|
||||||
this.scene.unshiftPhase(new SummonPhase(this.scene, 0, false));
|
this.scene.unshiftPhase(new SummonPhase(this.scene, 0, false));
|
||||||
if (this.scene.currentBattle.double)
|
if (this.scene.currentBattle.double && availablePartyMembers > 1)
|
||||||
this.scene.unshiftPhase(new SummonPhase(this.scene, 1, false));
|
this.scene.unshiftPhase(new SummonPhase(this.scene, 1, false));
|
||||||
this.end();
|
this.end();
|
||||||
}, 1500, true);
|
}, 1500, true);
|
||||||
|
@ -407,6 +410,31 @@ export class EncounterPhase extends BattlePhase {
|
||||||
if (ivScannerModifier)
|
if (ivScannerModifier)
|
||||||
enemyField.map(p => this.scene.pushPhase(new ScanIvsPhase(this.scene, p.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount(), 6))));
|
enemyField.map(p => this.scene.pushPhase(new ScanIvsPhase(this.scene, p.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount(), 6))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
const availablePartyMembers = this.scene.getParty().filter(p => !p.isFainted());
|
||||||
|
|
||||||
|
if (!availablePartyMembers[0].isOnField())
|
||||||
|
this.scene.pushPhase(new SummonPhase(this.scene, 0));
|
||||||
|
|
||||||
|
if (this.scene.currentBattle.double) {
|
||||||
|
if (availablePartyMembers.length > 1) {
|
||||||
|
this.scene.pushPhase(new ToggleDoublePositionPhase(this.scene, true));
|
||||||
|
if (!availablePartyMembers[1].isOnField())
|
||||||
|
this.scene.pushPhase(new SummonPhase(this.scene, 1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField())
|
||||||
|
this.scene.pushPhase(new ReturnPhase(this.scene, 1));
|
||||||
|
this.scene.pushPhase(new ToggleDoublePositionPhase(this.scene, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.scene.currentBattle.waveIndex > startingWave && this.scene.currentBattle.battleType !== BattleType.TRAINER) {
|
||||||
|
this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double));
|
||||||
|
if (this.scene.currentBattle.double && availablePartyMembers.length > 1)
|
||||||
|
this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Remove
|
// TODO: Remove
|
||||||
//this.scene.unshiftPhase(new SelectModifierPhase(this.scene));
|
//this.scene.unshiftPhase(new SelectModifierPhase(this.scene));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Phaser from 'phaser';
|
import Phaser from 'phaser';
|
||||||
import { Biome } from './data/biome';
|
import { Biome } from './data/biome';
|
||||||
import UI, { Mode } from './ui/ui';
|
import UI, { Mode } from './ui/ui';
|
||||||
import { EncounterPhase, SummonPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase, TurnInitPhase, ReturnPhase, ToggleDoublePositionPhase, CheckSwitchPhase, LevelCapPhase, TestMessagePhase, ShowTrainerPhase } from './battle-phases';
|
import { EncounterPhase, SummonPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase, TurnInitPhase, ReturnPhase, LevelCapPhase, TestMessagePhase, ShowTrainerPhase } from './battle-phases';
|
||||||
import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon';
|
import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon';
|
||||||
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies } from './data/pokemon-species';
|
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies } from './data/pokemon-species';
|
||||||
import * as Utils from './utils';
|
import * as Utils from './utils';
|
||||||
|
@ -675,7 +675,6 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
if (!waveIndex) {
|
if (!waveIndex) {
|
||||||
const isNewBiome = !lastBattle || !(lastBattle.waveIndex % 10);
|
const isNewBiome = !lastBattle || !(lastBattle.waveIndex % 10);
|
||||||
const showTrainer = isNewBiome || this.currentBattle.battleType === BattleType.TRAINER;
|
const showTrainer = isNewBiome || this.currentBattle.battleType === BattleType.TRAINER;
|
||||||
const availablePartyMemberCount = this.getParty().filter(p => !p.isFainted()).length;
|
|
||||||
if (lastBattle) {
|
if (lastBattle) {
|
||||||
this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy());
|
this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy());
|
||||||
this.trySpreadPokerus();
|
this.trySpreadPokerus();
|
||||||
|
@ -697,39 +696,10 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
if (newMaxExpLevel > maxExpLevel)
|
if (newMaxExpLevel > maxExpLevel)
|
||||||
this.pushPhase(new LevelCapPhase(this));
|
this.pushPhase(new LevelCapPhase(this));
|
||||||
}
|
}
|
||||||
if (showTrainer) {
|
} else if (!this.quickStart)
|
||||||
this.pushPhase(new SummonPhase(this, 0));
|
this.pushPhase(new CheckLoadPhase(this));
|
||||||
if (this.currentBattle.double && availablePartyMemberCount > 1)
|
else
|
||||||
this.pushPhase(new SummonPhase(this, 1));
|
this.pushPhase(new EncounterPhase(this));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!this.quickStart)
|
|
||||||
this.pushPhase(new CheckLoadPhase(this));
|
|
||||||
else {
|
|
||||||
this.pushPhase(new EncounterPhase(this));
|
|
||||||
this.pushPhase(new SummonPhase(this, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!showTrainer && (lastBattle?.double || false) !== newDouble) {
|
|
||||||
if (newDouble) {
|
|
||||||
if (availablePartyMemberCount > 1) {
|
|
||||||
this.pushPhase(new ToggleDoublePositionPhase(this, true));
|
|
||||||
this.pushPhase(new SummonPhase(this, 1));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (availablePartyMemberCount > 1)
|
|
||||||
this.pushPhase(new ReturnPhase(this, 1));
|
|
||||||
this.pushPhase(new ToggleDoublePositionPhase(this, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastBattle && this.currentBattle.battleType !== BattleType.TRAINER) {
|
|
||||||
const availablePartyMembers = this.getParty().filter(p => !p.isFainted()).length;
|
|
||||||
this.pushPhase(new CheckSwitchPhase(this, 0, newDouble));
|
|
||||||
if (newDouble && availablePartyMembers > 1)
|
|
||||||
this.pushPhase(new CheckSwitchPhase(this, 1, newDouble));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.currentBattle;
|
return this.currentBattle;
|
||||||
|
|
Loading…
Reference in New Issue