Fix some bugs
parent
fc4f98b203
commit
c6d9816318
|
@ -1,7 +1,7 @@
|
||||||
import BattleScene, { startingLevel, startingWave } from "./battle-scene";
|
import BattleScene, { startingLevel, startingWave } from "./battle-scene";
|
||||||
import { default as Pokemon, PlayerPokemon, EnemyPokemon, PokemonMove, MoveResult, DamageResult } from "./pokemon";
|
import { default as Pokemon, PlayerPokemon, EnemyPokemon, PokemonMove, MoveResult, DamageResult } from "./pokemon";
|
||||||
import * as Utils from './utils';
|
import * as Utils from './utils';
|
||||||
import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, HitsTagAttr, MissEffectAttr, MoveCategory, MoveEffectAttr, MoveFlags, MoveHitEffectAttr, Moves, MultiHitAttr, OverrideMoveEffectAttr, VariableAccuracyAttr } from "./data/move";
|
import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, applyFilteredMoveAttrs, HitsTagAttr, MissEffectAttr, MoveAttr, MoveCategory, MoveEffectAttr, MoveFlags, MoveHitEffectAttr, Moves, MultiHitAttr, OverrideMoveEffectAttr, VariableAccuracyAttr } from "./data/move";
|
||||||
import { Mode } from './ui/ui';
|
import { Mode } from './ui/ui';
|
||||||
import { Command } from "./ui/command-ui-handler";
|
import { Command } from "./ui/command-ui-handler";
|
||||||
import { Stat } from "./data/pokemon-stat";
|
import { Stat } from "./data/pokemon-stat";
|
||||||
|
@ -588,7 +588,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.moveset.find(m => m.moveId === moveQueue[0].move)
|
&& moveQueue[0].move && (!playerPokemon.moveset.find(m => m.moveId === moveQueue[0].move)
|
||||||
|| !playerPokemon.moveset[playerPokemon.moveset.findIndex(m => m.moveId === moveQueue[0].move)].isUsable(moveQueue[0].ignorePP)))
|
|| !playerPokemon.moveset[playerPokemon.moveset.findIndex(m => m.moveId === moveQueue[0].move)].isUsable(moveQueue[0].ignorePP)))
|
||||||
moveQueue.shift();
|
moveQueue.shift();
|
||||||
|
|
||||||
|
@ -659,9 +659,10 @@ export class CommandPhase extends FieldPhase {
|
||||||
break;
|
break;
|
||||||
case Command.BALL:
|
case Command.BALL:
|
||||||
if (this.scene.arena.biomeType === Biome.END) {
|
if (this.scene.arena.biomeType === Biome.END) {
|
||||||
|
this.scene.ui.setMode(Mode.COMMAND);
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
this.scene.ui.showText(`A strange force\nprevents using ${getPokeballName(PokeballType.POKEBALL)}s.`, null, () => {
|
this.scene.ui.showText(`A strange force\nprevents using POKé BALLS.`, null, () => {
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.showText(null, 0);
|
||||||
this.scene.ui.setMode(Mode.COMMAND);
|
this.scene.ui.setMode(Mode.COMMAND);
|
||||||
}, null, true);
|
}, null, true);
|
||||||
} else if (cursor < 4) {
|
} else if (cursor < 4) {
|
||||||
|
@ -1028,8 +1029,8 @@ abstract class MoveEffectPhase extends PokemonPhase {
|
||||||
target.addTag(BattlerTagType.FLINCHED, undefined, this.move.moveId, user.id);
|
target.addTag(BattlerTagType.FLINCHED, undefined, this.move.moveId, user.id);
|
||||||
}
|
}
|
||||||
// Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present
|
// Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present
|
||||||
if (!isProtected && target.hp && !this.move.getMove().getAttrs(ChargeAttr).filter(ca => (ca as ChargeAttr).chargeEffect).length)
|
if (!isProtected && !this.move.getMove().getAttrs(ChargeAttr).filter(ca => (ca as ChargeAttr).chargeEffect).length)
|
||||||
applyMoveAttrs(MoveHitEffectAttr, user, target, this.move.getMove());
|
applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveHitEffectAttr && (!!target.hp || (attr as MoveHitEffectAttr).selfTarget), user, target, this.move.getMove());
|
||||||
}
|
}
|
||||||
this.end();
|
this.end();
|
||||||
});
|
});
|
||||||
|
|
|
@ -749,6 +749,13 @@ export class MoveEffectAttr extends MoveAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MoveHitEffectAttr extends MoveAttr {
|
export class MoveHitEffectAttr extends MoveAttr {
|
||||||
|
public selfTarget: boolean;
|
||||||
|
|
||||||
|
constructor(selfTarget?: boolean) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.selfTarget = !!selfTarget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HighCritAttr extends MoveAttr {
|
export class HighCritAttr extends MoveAttr {
|
||||||
|
@ -905,7 +912,7 @@ export class HitHealAttr extends MoveHitEffectAttr {
|
||||||
private healRatio: number;
|
private healRatio: number;
|
||||||
|
|
||||||
constructor(healRatio?: number) {
|
constructor(healRatio?: number) {
|
||||||
super();
|
super(true);
|
||||||
|
|
||||||
this.healRatio = healRatio || 0.5;
|
this.healRatio = healRatio || 0.5;
|
||||||
}
|
}
|
||||||
|
@ -954,14 +961,12 @@ export class MultiHitAttr extends MoveAttr {
|
||||||
|
|
||||||
export class StatusEffectAttr extends MoveHitEffectAttr {
|
export class StatusEffectAttr extends MoveHitEffectAttr {
|
||||||
public effect: StatusEffect;
|
public effect: StatusEffect;
|
||||||
public selfTarget: boolean;
|
|
||||||
public cureTurn: integer;
|
public cureTurn: integer;
|
||||||
|
|
||||||
constructor(effect: StatusEffect, selfTarget?: boolean, cureTurn?: integer) {
|
constructor(effect: StatusEffect, selfTarget?: boolean, cureTurn?: integer) {
|
||||||
super();
|
super(selfTarget);
|
||||||
|
|
||||||
this.effect = effect;
|
this.effect = effect;
|
||||||
this.selfTarget = !!selfTarget;
|
|
||||||
this.cureTurn = cureTurn;
|
this.cureTurn = cureTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1789,10 +1794,12 @@ export class SketchAttr extends MoveEffectAttr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyMoveAttrs(attrType: { new(...args: any[]): MoveAttr }, user: Pokemon, target: Pokemon, move: Move, ...args: any[]): Promise<void> {
|
export type MoveAttrFilter = (attr: MoveAttr) => boolean;
|
||||||
|
|
||||||
|
function applyMoveAttrsInternal(attrFilter: MoveAttrFilter, user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<void> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const attrPromises: Promise<boolean>[] = [];
|
const attrPromises: Promise<boolean>[] = [];
|
||||||
const moveAttrs = move.attrs.filter(a => a instanceof attrType);
|
const moveAttrs = move.attrs.filter(a => attrFilter(a));
|
||||||
for (let attr of moveAttrs) {
|
for (let attr of moveAttrs) {
|
||||||
const result = attr.apply(user, target, move, args);
|
const result = attr.apply(user, target, move, args);
|
||||||
if (result instanceof Promise<boolean>)
|
if (result instanceof Promise<boolean>)
|
||||||
|
@ -1802,6 +1809,14 @@ export function applyMoveAttrs(attrType: { new(...args: any[]): MoveAttr }, user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function applyMoveAttrs(attrType: { new(...args: any[]): MoveAttr }, user: Pokemon, target: Pokemon, move: Move, ...args: any[]): Promise<void> {
|
||||||
|
return applyMoveAttrsInternal((attr: MoveAttr) => attr instanceof attrType, user, target, move, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function applyFilteredMoveAttrs(attrFilter: MoveAttrFilter, user: Pokemon, target: Pokemon, move: Move, ...args: any[]): Promise<void> {
|
||||||
|
return applyMoveAttrsInternal(attrFilter, user, target, move, args);
|
||||||
|
}
|
||||||
|
|
||||||
export const allMoves = [
|
export const allMoves = [
|
||||||
new StatusMove(Moves.NONE, "-", Type.NORMAL, MoveCategory.STATUS, -1, -1, "", -1, 0, 1),
|
new StatusMove(Moves.NONE, "-", Type.NORMAL, MoveCategory.STATUS, -1, -1, "", -1, 0, 1),
|
||||||
];
|
];
|
||||||
|
|
|
@ -804,7 +804,7 @@ function getNewModifierTypeOption(party: Pokemon[], player?: boolean, tier?: Mod
|
||||||
player = true;
|
player = true;
|
||||||
if (tier === undefined) {
|
if (tier === undefined) {
|
||||||
const tierValue = Utils.randInt(256);
|
const tierValue = Utils.randInt(256);
|
||||||
if (player) {
|
if (player && tierValue) {
|
||||||
const partyShinyCount = party.filter(p => p.shiny).length;
|
const partyShinyCount = party.filter(p => p.shiny).length;
|
||||||
const upgradeOdds = Math.floor(32 / Math.max((partyShinyCount * 2), 1));
|
const upgradeOdds = Math.floor(32 / Math.max((partyShinyCount * 2), 1));
|
||||||
upgrade = !Utils.randInt(upgradeOdds);
|
upgrade = !Utils.randInt(upgradeOdds);
|
||||||
|
|
|
@ -66,10 +66,11 @@ export default class BallUiHandler extends UiHandler {
|
||||||
success = true;
|
success = true;
|
||||||
if (button === Button.ACTION && this.cursor < pokeballTypeCount) {
|
if (button === Button.ACTION && this.cursor < pokeballTypeCount) {
|
||||||
if (this.scene.pokeballCounts[this.cursor]) {
|
if (this.scene.pokeballCounts[this.cursor]) {
|
||||||
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.BALL, this.cursor);
|
if ((this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.BALL, this.cursor)) {
|
||||||
this.scene.ui.setMode(Mode.COMMAND);
|
this.scene.ui.setMode(Mode.COMMAND);
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
success = true;
|
success = true;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
ui.playError();
|
ui.playError();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -113,14 +113,14 @@ export default class CommandUiHandler extends UiHandler {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear(): void {
|
||||||
super.clear();
|
super.clear();
|
||||||
this.commandsContainer.setVisible(false);
|
this.commandsContainer.setVisible(false);
|
||||||
this.getUi().getMessageHandler().clearText();
|
this.getUi().getMessageHandler().clearText();
|
||||||
this.eraseCursor();
|
this.eraseCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
eraseCursor() {
|
eraseCursor(): void {
|
||||||
if (this.cursorObj)
|
if (this.cursorObj)
|
||||||
this.cursorObj.destroy();
|
this.cursorObj.destroy();
|
||||||
this.cursorObj = null;
|
this.cursorObj = null;
|
||||||
|
|
Loading…
Reference in New Issue