diff --git a/src/battle.ts b/src/battle.ts index b80caa9e679..c7a26a0487c 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -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[]; diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ddb85600c18..6ca253b16df 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -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 { diff --git a/src/data/move.ts b/src/data/move.ts index 9f411f1866d..83e1f25a221 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -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(() => { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index f522d50f357..6c2ebf05c29 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -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[] = []; diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 47d212aa598..4855e516b7b 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -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) {