mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-17 13:52:18 +02:00
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 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 { Command } from "./ui/command-ui-handler";
|
||||||
import * as Utils from "./utils";
|
import * as Utils from "./utils";
|
||||||
import Trainer, { TrainerVariant } from "./field/trainer";
|
import Trainer, { TrainerVariant } from "./field/trainer";
|
||||||
@ -32,7 +32,7 @@ export enum BattlerIndex {
|
|||||||
export interface TurnCommand {
|
export interface TurnCommand {
|
||||||
command: Command;
|
command: Command;
|
||||||
cursor?: number;
|
cursor?: number;
|
||||||
move?: QueuedMove;
|
move?: TurnMove;
|
||||||
targets?: BattlerIndex[];
|
targets?: BattlerIndex[];
|
||||||
skip?: boolean;
|
skip?: boolean;
|
||||||
args?: any[];
|
args?: any[];
|
||||||
|
@ -435,7 +435,7 @@ export class InterruptedTag extends BattlerTag {
|
|||||||
super.onAdd(pokemon);
|
super.onAdd(pokemon);
|
||||||
|
|
||||||
pokemon.getMoveQueue().shift();
|
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 {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
|
@ -2452,8 +2452,9 @@ export class ChargeAttr extends OverrideMoveEffectAttr {
|
|||||||
if (this.chargeEffect) {
|
if (this.chargeEffect) {
|
||||||
applyMoveAttrs(MoveEffectAttr, user, target, move);
|
applyMoveAttrs(MoveEffectAttr, user, target, move);
|
||||||
}
|
}
|
||||||
user.pushMoveHistory({ move: move.id, targets: [ target.getBattlerIndex() ], result: MoveResult.OTHER });
|
const isVirtual = args[1] as boolean;
|
||||||
user.getMoveQueue().push({ move: move.id, targets: [ target.getBattlerIndex() ], ignorePP: true });
|
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);
|
user.addTag(BattlerTagType.CHARGING, 1, move.id, user.id);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
@ -5277,7 +5278,7 @@ export class CallMoveAttr extends OverrideMoveEffectAttr {
|
|||||||
: moveTargets.targets.indexOf(target.getBattlerIndex()) > -1
|
: moveTargets.targets.indexOf(target.getBattlerIndex()) > -1
|
||||||
? [ target.getBattlerIndex() ]
|
? [ target.getBattlerIndex() ]
|
||||||
: [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ];
|
: [ 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));
|
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(() => {
|
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();
|
return moveHistory.slice(turnCount >= 0 ? Math.max(moveHistory.length - (turnCount || 1), 0) : 0, moveHistory.length).reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
getMoveQueue(): QueuedMove[] {
|
getMoveQueue(): TurnMove[] {
|
||||||
return this.summonData.moveQueue;
|
return this.summonData.moveQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4084,7 +4084,7 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
* the Pokemon the move will target.
|
* the Pokemon the move will target.
|
||||||
* @returns this Pokemon's next move in the format {move, moveTargets}
|
* @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.
|
// If this Pokemon has a move already queued, return it.
|
||||||
const queuedMove = this.getMoveQueue().length
|
const queuedMove = this.getMoveQueue().length
|
||||||
? this.getMoveset().find(m => m?.moveId === this.getMoveQueue()[0].move)
|
? this.getMoveset().find(m => m?.moveId === this.getMoveQueue()[0].move)
|
||||||
@ -4479,15 +4479,10 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
|
|
||||||
export interface TurnMove {
|
export interface TurnMove {
|
||||||
move: Moves;
|
move: Moves;
|
||||||
targets?: BattlerIndex[];
|
targets: BattlerIndex[];
|
||||||
result: MoveResult;
|
result?: MoveResult;
|
||||||
virtual?: boolean;
|
virtual?: boolean;
|
||||||
turn?: number;
|
turn?: number;
|
||||||
}
|
|
||||||
|
|
||||||
export interface QueuedMove {
|
|
||||||
move: Moves;
|
|
||||||
targets: BattlerIndex[];
|
|
||||||
ignorePP?: boolean;
|
ignorePP?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4502,7 +4497,7 @@ export interface AttackMoveResult {
|
|||||||
|
|
||||||
export class PokemonSummonData {
|
export class PokemonSummonData {
|
||||||
public statStages: number[] = [ 0, 0, 0, 0, 0, 0, 0 ];
|
public statStages: number[] = [ 0, 0, 0, 0, 0, 0, 0 ];
|
||||||
public moveQueue: QueuedMove[] = [];
|
public moveQueue: TurnMove[] = [];
|
||||||
public tags: BattlerTag[] = [];
|
public tags: BattlerTag[] = [];
|
||||||
public abilitySuppressed: boolean = false;
|
public abilitySuppressed: boolean = false;
|
||||||
public abilitiesApplied: Abilities[] = [];
|
public abilitiesApplied: Abilities[] = [];
|
||||||
|
@ -8,7 +8,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type";
|
|||||||
import { Biome } from "#app/enums/biome";
|
import { Biome } from "#app/enums/biome";
|
||||||
import { Moves } from "#app/enums/moves";
|
import { Moves } from "#app/enums/moves";
|
||||||
import { PokeballType } from "#app/enums/pokeball";
|
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 { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { Command } from "#app/ui/command-ui-handler";
|
import { Command } from "#app/ui/command-ui-handler";
|
||||||
import { Mode } from "#app/ui/ui";
|
import { Mode } from "#app/ui/ui";
|
||||||
@ -50,7 +50,7 @@ export class CommandPhase extends FieldPhase {
|
|||||||
const moveQueue = playerPokemon.getMoveQueue();
|
const moveQueue = playerPokemon.getMoveQueue();
|
||||||
|
|
||||||
while (moveQueue.length && moveQueue[0]
|
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?
|
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct?
|
||||||
moveQueue.shift();
|
moveQueue.shift();
|
||||||
}
|
}
|
||||||
@ -63,6 +63,8 @@ export class CommandPhase extends FieldPhase {
|
|||||||
const moveIndex = playerPokemon.getMoveset().findIndex(m => m?.moveId === queuedMove.move);
|
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?
|
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 });
|
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 {
|
} else {
|
||||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||||
}
|
}
|
||||||
@ -82,7 +84,9 @@ export class CommandPhase extends FieldPhase {
|
|||||||
if (cursor === -1 ||
|
if (cursor === -1 ||
|
||||||
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
|
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
|
||||||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) {
|
(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 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];
|
const moveTargets: MoveTargetSet = args.length < 3 ? getMoveTargets(playerPokemon, moveId) : args[2];
|
||||||
if (!moveId) {
|
if (!moveId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user