Fix Disable implementation
parent
1fd5f6c01f
commit
e0acb1e737
|
@ -940,7 +940,7 @@ export class CommandPhase extends FieldPhase {
|
||||||
|
|
||||||
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 && (!playerPokemon.getMoveset().find(m => m.moveId === moveQueue[0].move)
|
||||||
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m.moveId === moveQueue[0].move)].isUsable(moveQueue[0].ignorePP)))
|
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m.moveId === moveQueue[0].move)].isUsable(playerPokemon, moveQueue[0].ignorePP)))
|
||||||
moveQueue.shift();
|
moveQueue.shift();
|
||||||
|
|
||||||
if (moveQueue.length) {
|
if (moveQueue.length) {
|
||||||
|
@ -949,7 +949,7 @@ export class CommandPhase extends FieldPhase {
|
||||||
this.handleCommand(Command.FIGHT, -1, false);
|
this.handleCommand(Command.FIGHT, -1, false);
|
||||||
else {
|
else {
|
||||||
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(queuedMove.ignorePP)) {
|
if (moveIndex > -1 && playerPokemon.getMoveset()[moveIndex].isUsable(playerPokemon, queuedMove.ignorePP)) {
|
||||||
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
|
} else
|
||||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||||
|
@ -978,7 +978,7 @@ export class CommandPhase extends FieldPhase {
|
||||||
success = true;
|
success = true;
|
||||||
} else if (cursor < playerPokemon.getMoveset().length) {
|
} else if (cursor < playerPokemon.getMoveset().length) {
|
||||||
const move = playerPokemon.getMoveset()[cursor];
|
const move = playerPokemon.getMoveset()[cursor];
|
||||||
if (move.isDisabled()) {
|
if (playerPokemon.summonData.disabledMove === move.moveId) {
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
this.scene.ui.showText(`${move.getName()} is disabled!`, null, () => {
|
this.scene.ui.showText(`${move.getName()} is disabled!`, null, () => {
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
|
@ -1222,10 +1222,9 @@ export class TurnEndPhase extends FieldPhase {
|
||||||
const handlePokemon = (pokemon: Pokemon) => {
|
const handlePokemon = (pokemon: Pokemon) => {
|
||||||
pokemon.lapseTags(BattlerTagLapseType.TURN_END);
|
pokemon.lapseTags(BattlerTagLapseType.TURN_END);
|
||||||
|
|
||||||
const disabledMoves = pokemon.getMoveset().filter(m => m.isDisabled());
|
if (pokemon.summonData.disabledMove && !--pokemon.summonData.disabledTurns) {
|
||||||
for (let dm of disabledMoves) {
|
pokemon.summonData.disabledMove = Moves.NONE;
|
||||||
if (!--dm.disableTurns)
|
this.scene.pushPhase(new MessagePhase(this.scene, `${allMoves[pokemon.summonData.disabledMove].name} is disabled\nno more!`));
|
||||||
this.scene.pushPhase(new MessagePhase(this.scene, `${dm.getName()} is disabled\nno more!`));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ pokemon ]), pokemon.isPlayer());
|
const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ pokemon ]), pokemon.isPlayer());
|
||||||
|
@ -1321,7 +1320,7 @@ export class MovePhase extends BattlePhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
canMove(): boolean {
|
canMove(): boolean {
|
||||||
return this.pokemon.isActive(true) && this.move.isUsable(this.ignorePp) && !!this.targets.length;
|
return this.pokemon.isActive(true) && this.move.isUsable(this.pokemon, this.ignorePp) && !!this.targets.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel(): void {
|
cancel(): void {
|
||||||
|
@ -1334,7 +1333,7 @@ export class MovePhase extends BattlePhase {
|
||||||
console.log(Moves[this.move.moveId]);
|
console.log(Moves[this.move.moveId]);
|
||||||
|
|
||||||
if (!this.canMove()) {
|
if (!this.canMove()) {
|
||||||
if (this.move.isDisabled())
|
if (this.pokemon.summonData.disabledMove === this.move.moveId)
|
||||||
this.scene.queueMessage(`${this.move.getName()} is disabled!`);
|
this.scene.queueMessage(`${this.move.getName()} is disabled!`);
|
||||||
this.end();
|
this.end();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1671,7 +1671,8 @@ export class DisableMoveAttr extends MoveEffectAttr {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const disabledMove = target.getMoveset()[moveIndex];
|
const disabledMove = target.getMoveset()[moveIndex];
|
||||||
disabledMove.disableTurns = 4;
|
target.summonData.disabledMove = disabledMove.moveId;
|
||||||
|
target.summonData.disabledTurns = 4;
|
||||||
|
|
||||||
user.scene.queueMessage(getPokemonMessage(target, `'s ${disabledMove.getName()}\nwas disabled!`));
|
user.scene.queueMessage(getPokemonMessage(target, `'s ${disabledMove.getName()}\nwas disabled!`));
|
||||||
|
|
||||||
|
@ -1683,6 +1684,9 @@ export class DisableMoveAttr extends MoveEffectAttr {
|
||||||
|
|
||||||
getCondition(): MoveCondition {
|
getCondition(): MoveCondition {
|
||||||
return (user: Pokemon, target: Pokemon, move: Move) => {
|
return (user: Pokemon, target: Pokemon, move: Move) => {
|
||||||
|
if (target.summonData.disabledMove)
|
||||||
|
return false;
|
||||||
|
|
||||||
const moveQueue = target.getLastXMoves();
|
const moveQueue = target.getLastXMoves();
|
||||||
let turnMove: TurnMove;
|
let turnMove: TurnMove;
|
||||||
while (moveQueue.length) {
|
while (moveQueue.length) {
|
||||||
|
@ -1694,7 +1698,7 @@ export class DisableMoveAttr extends MoveEffectAttr {
|
||||||
if (!move)
|
if (!move)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return !move.isDisabled();
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { ArenaTagType, WeakenMoveTypeTag } from './data/arena-tag';
|
||||||
import { Biome } from './data/biome';
|
import { Biome } from './data/biome';
|
||||||
import { Abilities, Ability, BattleStatMultiplierAbAttr, BlockCritAbAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, abilities, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from './data/ability';
|
import { Abilities, Ability, BattleStatMultiplierAbAttr, BlockCritAbAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, abilities, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from './data/ability';
|
||||||
import PokemonData from './system/pokemon-data';
|
import PokemonData from './system/pokemon-data';
|
||||||
import { BattleType, BattlerIndex } from './battle';
|
import { BattlerIndex } from './battle';
|
||||||
|
|
||||||
export enum FieldPosition {
|
export enum FieldPosition {
|
||||||
CENTER,
|
CENTER,
|
||||||
|
@ -548,7 +548,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
const move = this.getMoveset().length > moveIndex
|
const move = this.getMoveset().length > moveIndex
|
||||||
? this.getMoveset()[moveIndex]
|
? this.getMoveset()[moveIndex]
|
||||||
: null;
|
: null;
|
||||||
return move?.isUsable(ignorePp);
|
return move?.isUsable(this, ignorePp);
|
||||||
}
|
}
|
||||||
|
|
||||||
showInfo() {
|
showInfo() {
|
||||||
|
@ -1207,7 +1207,7 @@ export class EnemyPokemon extends Pokemon {
|
||||||
? this.getMoveset().find(m => m.moveId === this.getMoveQueue()[0].move)
|
? this.getMoveset().find(m => m.moveId === this.getMoveQueue()[0].move)
|
||||||
: null;
|
: null;
|
||||||
if (queuedMove) {
|
if (queuedMove) {
|
||||||
if (queuedMove.isUsable(this.getMoveQueue()[0].ignorePP))
|
if (queuedMove.isUsable(this, this.getMoveQueue()[0].ignorePP))
|
||||||
return { move: queuedMove.moveId, targets: this.getMoveQueue()[0].targets, ignorePP: this.getMoveQueue()[0].ignorePP };
|
return { move: queuedMove.moveId, targets: this.getMoveQueue()[0].targets, ignorePP: this.getMoveQueue()[0].ignorePP };
|
||||||
else {
|
else {
|
||||||
this.getMoveQueue().shift();
|
this.getMoveQueue().shift();
|
||||||
|
@ -1215,7 +1215,7 @@ export class EnemyPokemon extends Pokemon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const movePool = this.getMoveset().filter(m => m.isUsable());
|
const movePool = this.getMoveset().filter(m => m.isUsable(this));
|
||||||
if (movePool.length) {
|
if (movePool.length) {
|
||||||
if (movePool.length === 1)
|
if (movePool.length === 1)
|
||||||
return { move: movePool[0].moveId, targets: this.getNextTargets(movePool[0].moveId) };
|
return { move: movePool[0].moveId, targets: this.getNextTargets(movePool[0].moveId) };
|
||||||
|
@ -1370,6 +1370,8 @@ export interface AttackMoveResult {
|
||||||
export class PokemonSummonData {
|
export class PokemonSummonData {
|
||||||
public battleStats: integer[] = [ 0, 0, 0, 0, 0, 0, 0 ];
|
public battleStats: integer[] = [ 0, 0, 0, 0, 0, 0, 0 ];
|
||||||
public moveQueue: QueuedMove[] = [];
|
public moveQueue: QueuedMove[] = [];
|
||||||
|
public disabledMove: Moves = Moves.NONE;
|
||||||
|
public disabledTurns: integer = 0;
|
||||||
public tags: BattlerTag[] = [];
|
public tags: BattlerTag[] = [];
|
||||||
public moveset: PokemonMove[];
|
public moveset: PokemonMove[];
|
||||||
public types: Type[];
|
public types: Type[];
|
||||||
|
@ -1420,26 +1422,20 @@ export class PokemonMove {
|
||||||
public ppUsed: integer;
|
public ppUsed: integer;
|
||||||
public ppUp: integer;
|
public ppUp: integer;
|
||||||
public virtual: boolean;
|
public virtual: boolean;
|
||||||
public disableTurns: integer;
|
|
||||||
|
|
||||||
constructor(moveId: Moves, ppUsed?: integer, ppUp?: integer, virtual?: boolean) {
|
constructor(moveId: Moves, ppUsed?: integer, ppUp?: integer, virtual?: boolean) {
|
||||||
this.moveId = moveId;
|
this.moveId = moveId;
|
||||||
this.ppUsed = ppUsed || 0;
|
this.ppUsed = ppUsed || 0;
|
||||||
this.ppUp = ppUp || 0;
|
this.ppUp = ppUp || 0;
|
||||||
this.virtual = !!virtual;
|
this.virtual = !!virtual;
|
||||||
this.disableTurns = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isUsable(ignorePp?: boolean): boolean {
|
isUsable(pokemon: Pokemon, ignorePp?: boolean): boolean {
|
||||||
if (this.isDisabled())
|
if (pokemon.summonData?.disabledMove === this.moveId)
|
||||||
return false;
|
return false;
|
||||||
return ignorePp || this.ppUsed < this.getMove().pp + this.ppUp || this.getMove().pp === -1;
|
return ignorePp || this.ppUsed < this.getMove().pp + this.ppUp || this.getMove().pp === -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
isDisabled(): boolean {
|
|
||||||
return !!this.disableTurns;
|
|
||||||
}
|
|
||||||
|
|
||||||
getMove(): Move {
|
getMove(): Move {
|
||||||
return allMoves[this.moveId];
|
return allMoves[this.moveId];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue