Replaces QueuedMove with TurnMove, refactors to attempt two-turn move fix for metronome
This commit is contained in:
parent
d874f98bf6
commit
714211d381
|
@ -1,5 +1,5 @@
|
|||
import BattleScene from "./battle-scene";
|
||||
import { EnemyPokemon, PlayerPokemon, QueuedMove } from "./field/pokemon";
|
||||
import { EnemyPokemon, PlayerPokemon, TurnMove } from "./field/pokemon";
|
||||
import { Command } from "./ui/command-ui-handler";
|
||||
import * as Utils from "./utils";
|
||||
import Trainer, { TrainerVariant } from "./field/trainer";
|
||||
|
@ -32,7 +32,7 @@ export enum BattlerIndex {
|
|||
export interface TurnCommand {
|
||||
command: Command;
|
||||
cursor?: number;
|
||||
move?: QueuedMove;
|
||||
move?: TurnMove;
|
||||
targets?: BattlerIndex[];
|
||||
skip?: boolean;
|
||||
args?: any[];
|
||||
|
|
|
@ -435,7 +435,7 @@ export class InterruptedTag extends BattlerTag {
|
|||
super.onAdd(pokemon);
|
||||
|
||||
pokemon.getMoveQueue().shift();
|
||||
pokemon.pushMoveHistory({move: Moves.NONE, result: MoveResult.OTHER});
|
||||
pokemon.pushMoveHistory({move: Moves.NONE, result: MoveResult.OTHER, targets: []});
|
||||
}
|
||||
|
||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||
|
|
|
@ -2452,8 +2452,9 @@ export class ChargeAttr extends OverrideMoveEffectAttr {
|
|||
if (this.chargeEffect) {
|
||||
applyMoveAttrs(MoveEffectAttr, user, target, move);
|
||||
}
|
||||
user.pushMoveHistory({ move: move.id, targets: [ target.getBattlerIndex() ], result: MoveResult.OTHER });
|
||||
user.getMoveQueue().push({ move: move.id, targets: [ target.getBattlerIndex() ], ignorePP: true });
|
||||
const isVirtual = args[1] as boolean;
|
||||
user.pushMoveHistory({ move: move.id, targets: [ target.getBattlerIndex() ], result: MoveResult.OTHER});
|
||||
user.getMoveQueue().push({ move: move.id, targets: [ target.getBattlerIndex() ], virtual: isVirtual });
|
||||
user.addTag(BattlerTagType.CHARGING, 1, move.id, user.id);
|
||||
resolve(true);
|
||||
});
|
||||
|
@ -5277,7 +5278,7 @@ export class CallMoveAttr extends OverrideMoveEffectAttr {
|
|||
: moveTargets.targets.indexOf(target.getBattlerIndex()) > -1
|
||||
? [ target.getBattlerIndex() ]
|
||||
: [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ];
|
||||
user.getMoveQueue().push({ move: move.id, targets: targets, ignorePP: true });
|
||||
user.getMoveQueue().push({ move: move.id, targets: targets, virtual: true, ignorePP: true });
|
||||
user.scene.unshiftPhase(new MovePhase(user.scene, user, targets, new PokemonMove(move.id, 0, 0, true), true));
|
||||
|
||||
await Promise.resolve(initMoveAnim(user.scene, move.id).then(() => {
|
||||
|
|
|
@ -2711,7 +2711,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
return moveHistory.slice(turnCount >= 0 ? Math.max(moveHistory.length - (turnCount || 1), 0) : 0, moveHistory.length).reverse();
|
||||
}
|
||||
|
||||
getMoveQueue(): QueuedMove[] {
|
||||
getMoveQueue(): TurnMove[] {
|
||||
return this.summonData.moveQueue;
|
||||
}
|
||||
|
||||
|
@ -4084,7 +4084,7 @@ export class EnemyPokemon extends Pokemon {
|
|||
* the Pokemon the move will target.
|
||||
* @returns this Pokemon's next move in the format {move, moveTargets}
|
||||
*/
|
||||
getNextMove(): QueuedMove {
|
||||
getNextMove(): TurnMove {
|
||||
// If this Pokemon has a move already queued, return it.
|
||||
const queuedMove = this.getMoveQueue().length
|
||||
? this.getMoveset().find(m => m?.moveId === this.getMoveQueue()[0].move)
|
||||
|
@ -4479,15 +4479,10 @@ export class EnemyPokemon extends Pokemon {
|
|||
|
||||
export interface TurnMove {
|
||||
move: Moves;
|
||||
targets?: BattlerIndex[];
|
||||
result: MoveResult;
|
||||
targets: BattlerIndex[];
|
||||
result?: MoveResult;
|
||||
virtual?: boolean;
|
||||
turn?: number;
|
||||
}
|
||||
|
||||
export interface QueuedMove {
|
||||
move: Moves;
|
||||
targets: BattlerIndex[];
|
||||
ignorePP?: boolean;
|
||||
}
|
||||
|
||||
|
@ -4502,7 +4497,7 @@ export interface AttackMoveResult {
|
|||
|
||||
export class PokemonSummonData {
|
||||
public statStages: number[] = [ 0, 0, 0, 0, 0, 0, 0 ];
|
||||
public moveQueue: QueuedMove[] = [];
|
||||
public moveQueue: TurnMove[] = [];
|
||||
public tags: BattlerTag[] = [];
|
||||
public abilitySuppressed: boolean = false;
|
||||
public abilitiesApplied: Abilities[] = [];
|
||||
|
|
|
@ -8,7 +8,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type";
|
|||
import { Biome } from "#app/enums/biome";
|
||||
import { Moves } from "#app/enums/moves";
|
||||
import { PokeballType } from "#app/enums/pokeball";
|
||||
import { FieldPosition, PlayerPokemon } from "#app/field/pokemon";
|
||||
import { FieldPosition, PlayerPokemon, TurnMove } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { Command } from "#app/ui/command-ui-handler";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
|
@ -50,7 +50,7 @@ export class CommandPhase extends FieldPhase {
|
|||
const moveQueue = playerPokemon.getMoveQueue();
|
||||
|
||||
while (moveQueue.length && moveQueue[0]
|
||||
&& moveQueue[0].move && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move)
|
||||
&& moveQueue[0].move && !moveQueue[0].virtual && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move)
|
||||
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct?
|
||||
moveQueue.shift();
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ export class CommandPhase extends FieldPhase {
|
|||
const moveIndex = playerPokemon.getMoveset().findIndex(m => m?.moveId === queuedMove.move);
|
||||
if (moveIndex > -1 && playerPokemon.getMoveset()[moveIndex]!.isUsable(playerPokemon, queuedMove.ignorePP)) { // TODO: is the bang correct?
|
||||
this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, { targets: queuedMove.targets, multiple: queuedMove.targets.length > 1 });
|
||||
} else if (moveQueue[0].virtual) {
|
||||
this.handleCommand(Command.FIGHT, moveIndex, queuedMove);
|
||||
} else {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}
|
||||
|
@ -82,7 +84,9 @@ export class CommandPhase extends FieldPhase {
|
|||
if (cursor === -1 ||
|
||||
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
|
||||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) {
|
||||
const moveId = !useStruggle ? cursor > -1 ? playerPokemon.getMoveset()[cursor]!.moveId : Moves.NONE : Moves.STRUGGLE; // TODO: is the bang correct?
|
||||
const turnMove: TurnMove | undefined = args.length === 1 ? (args[0] as TurnMove) : undefined;
|
||||
/* THIS NEEDS FURTHER TESTING */
|
||||
const moveId = !useStruggle ? !turnMove ? cursor > -1 ? playerPokemon.getMoveset()[cursor]!.moveId : Moves.NONE : turnMove.move : Moves.STRUGGLE; // TODO: is the bang correct?
|
||||
const turnCommand: TurnCommand = { command: Command.FIGHT, cursor: cursor, move: { move: moveId, targets: [], ignorePP: args[0] }, args: args };
|
||||
const moveTargets: MoveTargetSet = args.length < 3 ? getMoveTargets(playerPokemon, moveId) : args[2];
|
||||
if (!moveId) {
|
||||
|
|
Loading…
Reference in New Issue