Add WiP features related to forms and save data
This commit is contained in:
1 parent
bcafa47673
commit
00ad27247c
274 files changed
+1507
-440761
No files matched your search
+22
-77
@@ -1,6 +1,7 @@
|
||||
import BattleScene from "./battle-scene";
|
||||
import { default as Pokemon, PlayerPokemon, EnemyPokemon, PokemonMove, MoveResult, DamageResult } from "./pokemon";
|
||||
import { applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveAttr, HitsTagAttr, MissEffectAttr, MoveCategory, MoveEffectAttr, MoveHitEffectAttr, MultiHitAttr, OverrideMoveEffectAttr, VariableAccuracyAttr } from "./move";
|
||||
import * as Utils from './utils';
|
||||
import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveAttr, HitsTagAttr, MissEffectAttr, MoveCategory, MoveEffectAttr, MoveHitEffectAttr, Moves, MultiHitAttr, OverrideMoveEffectAttr } from "./move";
|
||||
import { Mode } from './ui/ui';
|
||||
import { Command } from "./ui/command-ui-handler";
|
||||
import { Stat } from "./pokemon-stat";
|
||||
@@ -20,9 +21,8 @@ import PokemonSpecies from "./pokemon-species";
|
||||
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
|
||||
import { BattleTagLapseType, BattleTagType, HideSpriteTag as HiddenTag } from "./battle-tag";
|
||||
import { getPokemonMessage } from "./messages";
|
||||
import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, getWeatherLapseMessage as getWeatherEffectMessage } from "./weather";
|
||||
import { Moves, allMoves } from "./move";
|
||||
import * as Utils from './utils';
|
||||
import { Starter } from "./ui/starter-select-ui-handler";
|
||||
import { Gender } from "./gender";
|
||||
|
||||
export class SelectStarterPhase extends BattlePhase {
|
||||
constructor(scene: BattleScene) {
|
||||
@@ -34,14 +34,17 @@ export class SelectStarterPhase extends BattlePhase {
|
||||
|
||||
this.scene.sound.play('menu', { loop: true });
|
||||
|
||||
this.scene.ui.setMode(Mode.STARTER_SELECT, (starterSpecies: PokemonSpecies[]) => {
|
||||
this.scene.ui.setMode(Mode.STARTER_SELECT, (starters: Starter[]) => {
|
||||
const party = this.scene.getParty();
|
||||
const loadPokemonAssets: Promise<void>[] = [];
|
||||
for (let species of starterSpecies) {
|
||||
const starter = new PlayerPokemon(this.scene, species, 5);
|
||||
starter.setVisible(false);
|
||||
party.push(starter);
|
||||
loadPokemonAssets.push(starter.loadAssets());
|
||||
for (let starter of starters) {
|
||||
const starterGender = starter.species.malePercent !== null
|
||||
? !starter.female ? Gender.MALE : Gender.FEMALE
|
||||
: Gender.GENDERLESS;
|
||||
const starterPokemon = new PlayerPokemon(this.scene, starter.species, 5, starter.formIndex, starterGender, starter.shiny);
|
||||
starterPokemon.setVisible(false);
|
||||
party.push(starterPokemon);
|
||||
loadPokemonAssets.push(starterPokemon.loadAssets());
|
||||
}
|
||||
Promise.all(loadPokemonAssets).then(() => {
|
||||
this.scene.ui.clearText();
|
||||
@@ -205,8 +208,7 @@ export class SwitchBiomePhase extends BattlePhase {
|
||||
onComplete: () => {
|
||||
this.scene.arenaEnemy.setX(this.scene.arenaEnemy.x - 600);
|
||||
|
||||
this.scene.newArena(this.nextBiome)
|
||||
.trySetWeather(getRandomWeatherType(this.nextBiome), false);
|
||||
this.scene.newArena(this.nextBiome);
|
||||
|
||||
const biomeKey = this.scene.arena.getBiomeKey();
|
||||
const bgTexture = `${biomeKey}_bg`;
|
||||
@@ -396,13 +398,9 @@ export class CheckSwitchPhase extends BattlePhase {
|
||||
|
||||
this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => {
|
||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true));
|
||||
this.end();
|
||||
}, () => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
this.end();
|
||||
});
|
||||
}, () => this.end());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -450,12 +448,10 @@ export class CommandPhase extends BattlePhase {
|
||||
let isDelayed = (command: Command, playerMove: PokemonMove, enemyMove: PokemonMove) => {
|
||||
switch (command) {
|
||||
case Command.FIGHT:
|
||||
if (playerMove && enemyMove) {
|
||||
const playerMovePriority = playerMove.getMove().priority;
|
||||
const enemyMovePriority = enemyMove.getMove().priority;
|
||||
if (playerMovePriority !== enemyMovePriority)
|
||||
return playerMovePriority < enemyMovePriority;
|
||||
}
|
||||
const playerMovePriority = playerMove.getMove().priority;
|
||||
const enemyMovePriority = enemyMove.getMove().priority;
|
||||
if (playerMovePriority !== enemyMovePriority)
|
||||
return playerMovePriority < enemyMovePriority;
|
||||
break;
|
||||
case Command.BALL:
|
||||
case Command.POKEMON:
|
||||
@@ -495,9 +491,6 @@ export class CommandPhase extends BattlePhase {
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if (this.scene.arena.weather)
|
||||
this.scene.unshiftPhase(new WeatherEffectPhase(this.scene, this.scene.arena.weather, isDelayed(command, null, null)));
|
||||
|
||||
const enemyMove = enemyPokemon.getNextMove();
|
||||
const enemyPhase = new EnemyMovePhase(this.scene, enemyPokemon, enemyMove);
|
||||
if (isDelayed(command, playerMove, enemyMove))
|
||||
@@ -546,9 +539,6 @@ export class TurnEndPhase extends BattlePhase {
|
||||
playerPokemon.battleSummonData.turnCount++;
|
||||
enemyPokemon.battleSummonData.turnCount++;
|
||||
|
||||
if (this.scene.arena.weather && !this.scene.arena.weather.lapse())
|
||||
this.scene.arena.trySetWeather(WeatherType.NONE, false);
|
||||
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
@@ -643,8 +633,6 @@ export abstract class MovePhase extends BattlePhase {
|
||||
|
||||
const failed = new Utils.BooleanHolder(false);
|
||||
applyMoveAttrs(ConditionalMoveAttr, this.pokemon, target, this.move.getMove(), failed);
|
||||
if (!failed.value && this.scene.arena.isMoveWeatherCancelled(this.move.getMove()))
|
||||
failed.value = true;
|
||||
if (failed.value)
|
||||
this.scene.unshiftPhase(new MessagePhase(this.scene, 'But it failed!'));
|
||||
else
|
||||
@@ -806,12 +794,6 @@ abstract class MoveEffectPhase extends PokemonPhase {
|
||||
if (!this.move.getMove().getAttrs(HitsTagAttr).filter(hta => (hta as HitsTagAttr).tagType === hiddenTag.tagType).length)
|
||||
return false;
|
||||
}
|
||||
|
||||
const moveAccuracy = new Utils.NumberHolder(this.move.getMove().accuracy);
|
||||
applyMoveAttrs(VariableAccuracyAttr, this.getUserPokemon(), this.getTargetPokemon(), this.move.getMove(), moveAccuracy);
|
||||
|
||||
if (moveAccuracy.value === -1)
|
||||
return true;
|
||||
|
||||
if (this.move.getMove().category !== MoveCategory.STATUS) {
|
||||
const userAccuracyLevel = this.getUserPokemon().summonData.battleStats[BattleStat.ACC];
|
||||
@@ -823,9 +805,8 @@ abstract class MoveEffectPhase extends PokemonPhase {
|
||||
? (3 + Math.min(userAccuracyLevel - targetEvasionLevel, 6)) / 3
|
||||
: 3 / (3 + Math.min(targetEvasionLevel - userAccuracyLevel, 6));
|
||||
}
|
||||
return rand <= moveAccuracy.value * accuracyMultiplier;
|
||||
return rand <= this.move.getMove().accuracy * accuracyMultiplier;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1067,41 +1048,8 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
|
||||
}
|
||||
}
|
||||
|
||||
export class WeatherEffectPhase extends CommonAnimPhase {
|
||||
private weather: Weather;
|
||||
private playerDelayed: boolean;
|
||||
export class WeatherPhase extends BattlePhase {
|
||||
|
||||
constructor(scene: BattleScene, weather: Weather, playerDelayed: boolean) {
|
||||
super(scene, true, CommonAnim.SUNNY + (weather.weatherType - 1));
|
||||
|
||||
this.weather = weather;
|
||||
this.playerDelayed = playerDelayed;
|
||||
}
|
||||
|
||||
start() {
|
||||
if (this.weather.isDamaging()) {
|
||||
const inflictDamage = (pokemon: Pokemon) => {
|
||||
this.scene.unshiftPhase(new MessagePhase(this.scene, getWeatherDamageMessage(this.weather.weatherType, pokemon)));
|
||||
pokemon.damage(Math.ceil(pokemon.getMaxHp() / 16));
|
||||
this.scene.unshiftPhase(new DamagePhase(this.scene, pokemon.isPlayer()));
|
||||
};
|
||||
|
||||
const playerPokemon = this.scene.getPlayerPokemon();
|
||||
const enemyPokemon = this.scene.getEnemyPokemon();
|
||||
|
||||
const playerImmune = !!playerPokemon.getTypes().filter(t => this.weather.isTypeDamageImmune(t)).length;
|
||||
const enemyImmune = !!playerPokemon.getTypes().filter(t => this.weather.isTypeDamageImmune(t)).length;
|
||||
|
||||
if (!this.playerDelayed && !playerImmune)
|
||||
inflictDamage(playerPokemon);
|
||||
if (!enemyImmune)
|
||||
inflictDamage(enemyPokemon);
|
||||
if (this.playerDelayed && !playerImmune)
|
||||
inflictDamage(playerPokemon);
|
||||
}
|
||||
|
||||
this.scene.ui.showText(getWeatherEffectMessage(this.weather.weatherType), null, () => super.start());
|
||||
}
|
||||
}
|
||||
|
||||
export class MessagePhase extends BattlePhase {
|
||||
@@ -1120,10 +1068,7 @@ export class MessagePhase extends BattlePhase {
|
||||
start() {
|
||||
super.start();
|
||||
|
||||
if (this.text)
|
||||
this.scene.ui.showText(this.text, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.prompt);
|
||||
else
|
||||
this.end();
|
||||
this.scene.ui.showText(this.text, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.prompt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user