mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-04-08 10:52:39 +01:00
[Refactor] Moveset arrays can no longer hold null
values (#4919)
* Pokemon movesets no longer allow `null` values * Clean up all the bangs caused by movesets allowing `null` * Pokemon movesets no longer allow `null` values * Clean up all the bangs caused by movesets allowing `null` * Fix merge issues * Remove various unnecessary `?` * Apply biome * Fix `global-trade-system-encounter.ts` * Fix merge issue * Remove unnecessary parentheses * Remove missed `?` * Match formatting of `pokemon.ts`
This commit is contained in:
parent
0b1f324f97
commit
db850c79cd
@ -1371,6 +1371,7 @@ export default class BattleScene extends SceneBase {
|
||||
return Math.max(doubleChance.value, 1);
|
||||
}
|
||||
|
||||
// TODO: ...this never actually returns `null`, right?
|
||||
newBattle(
|
||||
waveIndex?: number,
|
||||
battleType?: BattleType,
|
||||
|
@ -179,7 +179,7 @@ class TimeOfDayEvolutionCondition extends SpeciesEvolutionCondition {
|
||||
class MoveEvolutionCondition extends SpeciesEvolutionCondition {
|
||||
public move: Moves;
|
||||
constructor(move: Moves) {
|
||||
super(p => p.moveset.filter(m => m?.moveId === move).length > 0);
|
||||
super(p => p.moveset.filter(m => m.moveId === move).length > 0);
|
||||
this.move = move;
|
||||
const moveKey = Moves[this.move].split("_").filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join("");
|
||||
this.description = i18next.t("pokemonEvolutions:move", { move: i18next.t(`move:${moveKey}.name`) });
|
||||
@ -282,7 +282,7 @@ class TyrogueEvolutionCondition extends SpeciesEvolutionCondition {
|
||||
public move: Moves;
|
||||
constructor(move: Moves) {
|
||||
super(p =>
|
||||
p.getMoveset(true).find(m => m && [ Moves.LOW_SWEEP, Moves.MACH_PUNCH, Moves.RAPID_SPIN ].includes(m?.moveId))?.moveId === move);
|
||||
p.getMoveset(true).find(m => m && [ Moves.LOW_SWEEP, Moves.MACH_PUNCH, Moves.RAPID_SPIN ].includes(m.moveId))?.moveId === move);
|
||||
this.move = move;
|
||||
const moveKey = Moves[this.move].split("_").filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join("");
|
||||
this.description = i18next.t("pokemonEvolutions:move", { move: i18next.t(`move:${moveKey}.name`) });
|
||||
@ -303,11 +303,11 @@ class MoveTimeOfDayEvolutionCondition extends SpeciesEvolutionCondition {
|
||||
public timesOfDay: TimeOfDay[];
|
||||
constructor(move: Moves, tod: "day" | "night") {
|
||||
if (tod === "day") {
|
||||
super(p => p.moveset.filter(m => m?.moveId === move).length > 0 && (globalScene.arena.getTimeOfDay() === TimeOfDay.DAWN || globalScene.arena.getTimeOfDay() === TimeOfDay.DAY));
|
||||
super(p => p.moveset.filter(m => m.moveId === move).length > 0 && (globalScene.arena.getTimeOfDay() === TimeOfDay.DAWN || globalScene.arena.getTimeOfDay() === TimeOfDay.DAY));
|
||||
this.move = move;
|
||||
this.timesOfDay = [ TimeOfDay.DAWN, TimeOfDay.DAY ];
|
||||
} else if (tod === "night") {
|
||||
super(p => p.moveset.filter(m => m?.moveId === move).length > 0 && (globalScene.arena.getTimeOfDay() === TimeOfDay.DUSK || globalScene.arena.getTimeOfDay() === TimeOfDay.NIGHT));
|
||||
super(p => p.moveset.filter(m => m.moveId === move).length > 0 && (globalScene.arena.getTimeOfDay() === TimeOfDay.DUSK || globalScene.arena.getTimeOfDay() === TimeOfDay.NIGHT));
|
||||
this.move = move;
|
||||
this.timesOfDay = [ TimeOfDay.DUSK, TimeOfDay.NIGHT ];
|
||||
} else {
|
||||
@ -332,7 +332,7 @@ class DunsparceEvolutionCondition extends SpeciesEvolutionCondition {
|
||||
constructor() {
|
||||
super(p => {
|
||||
let ret = false;
|
||||
if (p.moveset.filter(m => m?.moveId === Moves.HYPER_DRILL).length > 0) {
|
||||
if (p.moveset.filter(m => m.moveId === Moves.HYPER_DRILL).length > 0) {
|
||||
globalScene.executeWithSeedOffset(() => ret = !Utils.randSeedInt(4), p.id);
|
||||
}
|
||||
return ret;
|
||||
@ -1540,13 +1540,13 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesEvolution(Species.TOGEKISS, 1, EvolutionItem.SHINY_STONE, null, SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
],
|
||||
[Species.AIPOM]: [
|
||||
new SpeciesEvolution(Species.AMBIPOM, 32, null, new MoveEvolutionCondition(Moves.DOUBLE_HIT), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.AMBIPOM, 32, null, new MoveEvolutionCondition(Moves.DOUBLE_HIT), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.SUNKERN]: [
|
||||
new SpeciesEvolution(Species.SUNFLORA, 1, EvolutionItem.SUN_STONE, null, SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.YANMA]: [
|
||||
new SpeciesEvolution(Species.YANMEGA, 33, null, new MoveEvolutionCondition(Moves.ANCIENT_POWER), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.YANMEGA, 33, null, new MoveEvolutionCondition(Moves.ANCIENT_POWER), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.MURKROW]: [
|
||||
new SpeciesEvolution(Species.HONCHKROW, 1, EvolutionItem.DUSK_STONE, null, SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
@ -1555,11 +1555,11 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesEvolution(Species.MISMAGIUS, 1, EvolutionItem.DUSK_STONE, null, SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
],
|
||||
[Species.GIRAFARIG]: [
|
||||
new SpeciesEvolution(Species.FARIGIRAF, 32, null, new MoveEvolutionCondition(Moves.TWIN_BEAM), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.FARIGIRAF, 32, null, new MoveEvolutionCondition(Moves.TWIN_BEAM), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.DUNSPARCE]: [
|
||||
new SpeciesFormEvolution(Species.DUDUNSPARCE, "", "three-segment", 32, null, new DunsparceEvolutionCondition(), SpeciesWildEvolutionDelay.LONG),
|
||||
new SpeciesFormEvolution(Species.DUDUNSPARCE, "", "two-segment", 32, null, new MoveEvolutionCondition(Moves.HYPER_DRILL), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesFormEvolution(Species.DUDUNSPARCE, "", "two-segment", 32, null, new MoveEvolutionCondition(Moves.HYPER_DRILL), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.GLIGAR]: [
|
||||
new SpeciesEvolution(Species.GLISCOR, 1, EvolutionItem.RAZOR_FANG, new TimeOfDayEvolutionCondition("night") /* Razor fang at night*/, SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
@ -1571,10 +1571,10 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesEvolution(Species.URSALUNA, 1, EvolutionItem.PEAT_BLOCK, null, SpeciesWildEvolutionDelay.VERY_LONG) //Ursaring does not evolve into Bloodmoon Ursaluna
|
||||
],
|
||||
[Species.PILOSWINE]: [
|
||||
new SpeciesEvolution(Species.MAMOSWINE, 1, null, new MoveEvolutionCondition(Moves.ANCIENT_POWER), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
new SpeciesEvolution(Species.MAMOSWINE, 1, null, new MoveEvolutionCondition(Moves.ANCIENT_POWER), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
],
|
||||
[Species.STANTLER]: [
|
||||
new SpeciesEvolution(Species.WYRDEER, 25, null, new MoveEvolutionCondition(Moves.PSYSHIELD_BASH), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
new SpeciesEvolution(Species.WYRDEER, 25, null, new MoveEvolutionCondition(Moves.PSYSHIELD_BASH), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
],
|
||||
[Species.LOMBRE]: [
|
||||
new SpeciesEvolution(Species.LUDICOLO, 1, EvolutionItem.WATER_STONE, null, SpeciesWildEvolutionDelay.LONG)
|
||||
@ -1592,7 +1592,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesEvolution(Species.ROSERADE, 1, EvolutionItem.SHINY_STONE, null, SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
],
|
||||
[Species.BONSLY]: [
|
||||
new SpeciesEvolution(Species.SUDOWOODO, 1, null, new MoveEvolutionCondition(Moves.MIMIC), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.SUDOWOODO, 1, null, new MoveEvolutionCondition(Moves.MIMIC), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.MIME_JR]: [
|
||||
new SpeciesEvolution(Species.GALAR_MR_MIME, 1, null, new MoveTimeOfDayEvolutionCondition(Moves.MIMIC, "night"), SpeciesWildEvolutionDelay.MEDIUM),
|
||||
@ -1651,10 +1651,10 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesFormEvolution(Species.LYCANROC, "", "midnight", 25, null, new TimeOfDayEvolutionCondition("night"))
|
||||
],
|
||||
[Species.STEENEE]: [
|
||||
new SpeciesEvolution(Species.TSAREENA, 28, null, new MoveEvolutionCondition(Moves.STOMP), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.TSAREENA, 28, null, new MoveEvolutionCondition(Moves.STOMP), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.POIPOLE]: [
|
||||
new SpeciesEvolution(Species.NAGANADEL, 1, null, new MoveEvolutionCondition(Moves.DRAGON_PULSE), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.NAGANADEL, 1, null, new MoveEvolutionCondition(Moves.DRAGON_PULSE), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.ALOLA_SANDSHREW]: [
|
||||
new SpeciesEvolution(Species.ALOLA_SANDSLASH, 1, EvolutionItem.ICE_STONE, null, SpeciesWildEvolutionDelay.LONG)
|
||||
@ -1720,7 +1720,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesEvolution(Species.HISUI_ELECTRODE, 1, EvolutionItem.LEAF_STONE, null, SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.HISUI_QWILFISH]: [
|
||||
new SpeciesEvolution(Species.OVERQWIL, 28, null, new MoveEvolutionCondition(Moves.BARB_BARRAGE), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.OVERQWIL, 28, null, new MoveEvolutionCondition(Moves.BARB_BARRAGE), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.HISUI_SNEASEL]: [
|
||||
new SpeciesEvolution(Species.SNEASLER, 1, EvolutionItem.RAZOR_CLAW, new TimeOfDayEvolutionCondition("day") /* Razor claw at day*/, SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
|
@ -1174,13 +1174,13 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
|
||||
const movePhase = globalScene.findPhase(m => m instanceof MovePhase && m.pokemon === pokemon);
|
||||
if (movePhase) {
|
||||
const movesetMove = pokemon.getMoveset().find(m => m!.moveId === this.moveId); // TODO: is this bang correct?
|
||||
const movesetMove = pokemon.getMoveset().find(m => m.moveId === this.moveId);
|
||||
if (movesetMove) {
|
||||
const lastMove = pokemon.getLastXMoves(1)[0];
|
||||
globalScene.tryReplacePhase(
|
||||
m => m instanceof MovePhase && m.pokemon === pokemon,
|
||||
new MovePhase(pokemon, lastMove.targets!, movesetMove),
|
||||
); // TODO: is this bang correct?
|
||||
new MovePhase(pokemon, lastMove.targets ?? [], movesetMove),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
*/
|
||||
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||
if (lapseType === BattlerTagLapseType.CUSTOM) {
|
||||
const encoredMove = pokemon.getMoveset().find(m => m?.moveId === this.moveId);
|
||||
const encoredMove = pokemon.getMoveset().find(m => m.moveId === this.moveId);
|
||||
if (encoredMove && encoredMove?.getPpRatio() > 0) {
|
||||
return true;
|
||||
}
|
||||
@ -3184,7 +3184,7 @@ export class ImprisonTag extends MoveRestrictionBattlerTag {
|
||||
public override isMoveRestricted(move: Moves, _user: Pokemon): boolean {
|
||||
const source = this.getSourcePokemon();
|
||||
if (source) {
|
||||
const sourceMoveset = source.getMoveset().map(m => m!.moveId);
|
||||
const sourceMoveset = source.getMoveset().map(m => m.moveId);
|
||||
return sourceMoveset?.includes(move) && source.isActive(true);
|
||||
}
|
||||
return false;
|
||||
@ -3354,7 +3354,7 @@ export class GrudgeTag extends BattlerTag {
|
||||
if (lapseType === BattlerTagLapseType.CUSTOM && sourcePokemon) {
|
||||
if (sourcePokemon.isActive() && pokemon.isOpponent(sourcePokemon)) {
|
||||
const lastMove = pokemon.turnData.attacksReceived[0];
|
||||
const lastMoveData = sourcePokemon.getMoveset().find(m => m?.moveId === lastMove.move);
|
||||
const lastMoveData = sourcePokemon.getMoveset().find(m => m.moveId === lastMove.move);
|
||||
if (lastMoveData && lastMove.move !== Moves.STRUGGLE) {
|
||||
lastMoveData.ppUsed = lastMoveData.getMovePp();
|
||||
globalScene.queueMessage(
|
||||
|
@ -65,7 +65,7 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate {
|
||||
return (pokemon: Pokemon) => {
|
||||
const threshold = new Utils.NumberHolder(0.25);
|
||||
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold);
|
||||
return !!pokemon.getMoveset().find(m => !m?.getPpRatio());
|
||||
return !!pokemon.getMoveset().find(m => !m.getPpRatio());
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -147,9 +147,9 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
const ppRestoreMove = pokemon.getMoveset().find(m => !m?.getPpRatio())
|
||||
? pokemon.getMoveset().find(m => !m?.getPpRatio())
|
||||
: pokemon.getMoveset().find(m => m!.getPpRatio() < 1); // TODO: is this bang correct?
|
||||
const ppRestoreMove = pokemon.getMoveset().find(m => !m.getPpRatio())
|
||||
? pokemon.getMoveset().find(m => !m.getPpRatio())
|
||||
: pokemon.getMoveset().find(m => m.getPpRatio() < 1);
|
||||
if (ppRestoreMove !== undefined) {
|
||||
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
|
||||
globalScene.queueMessage(
|
||||
|
@ -450,7 +450,7 @@ export class SingleGenerationChallenge extends Challenge {
|
||||
|
||||
applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean {
|
||||
const baseGeneration = getPokemonSpecies(pokemon.species.speciesId).generation;
|
||||
const fusionGeneration = pokemon.isFusion() ? getPokemonSpecies(pokemon.fusionSpecies!.speciesId).generation : 0; // TODO: is the bang on fusionSpecies correct?
|
||||
const fusionGeneration = pokemon.isFusion() ? getPokemonSpecies(pokemon.fusionSpecies!.speciesId).generation : 0;
|
||||
if (
|
||||
pokemon.isPlayer() &&
|
||||
(baseGeneration !== this.value || (pokemon.isFusion() && fusionGeneration !== this.value))
|
||||
|
@ -1881,14 +1881,14 @@ export class HealAttr extends MoveEffectAttr {
|
||||
*/
|
||||
export class PartyStatusCureAttr extends MoveEffectAttr {
|
||||
/** Message to display after using move */
|
||||
private message: string;
|
||||
private message: string | null;
|
||||
/** Skips mons with this ability, ie. Soundproof */
|
||||
private abilityCondition: Abilities;
|
||||
|
||||
constructor(message: string | null, abilityCondition: Abilities) {
|
||||
super();
|
||||
|
||||
this.message = message!; // TODO: is this bang correct?
|
||||
this.message = message;
|
||||
this.abilityCondition = abilityCondition;
|
||||
}
|
||||
|
||||
@ -2103,10 +2103,10 @@ export class BoostHealAttr extends HealAttr {
|
||||
/** The lambda expression to check against when boosting the healing value */
|
||||
private condition?: MoveConditionFunc;
|
||||
|
||||
constructor(normalHealRatio?: number, boostedHealRatio?: number, showAnim?: boolean, selfTarget?: boolean, condition?: MoveConditionFunc) {
|
||||
constructor(normalHealRatio: number = 0.5, boostedHealRatio: number = 2 / 3, showAnim?: boolean, selfTarget?: boolean, condition?: MoveConditionFunc) {
|
||||
super(normalHealRatio, showAnim, selfTarget);
|
||||
this.normalHealRatio = normalHealRatio!; // TODO: is this bang correct?
|
||||
this.boostedHealRatio = boostedHealRatio!; // TODO: is this bang correct?
|
||||
this.normalHealRatio = normalHealRatio;
|
||||
this.boostedHealRatio = boostedHealRatio;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
@ -3374,14 +3374,14 @@ export class SecretPowerAttr extends MoveEffectAttr {
|
||||
export class PostVictoryStatStageChangeAttr extends MoveAttr {
|
||||
private stats: BattleStat[];
|
||||
private stages: number;
|
||||
private condition: MoveConditionFunc | null;
|
||||
private condition?: MoveConditionFunc;
|
||||
private showMessage: boolean;
|
||||
|
||||
constructor(stats: BattleStat[], stages: number, selfTarget?: boolean, condition?: MoveConditionFunc, showMessage: boolean = true, firstHitOnly: boolean = false) {
|
||||
super();
|
||||
this.stats = stats;
|
||||
this.stages = stages;
|
||||
this.condition = condition!; // TODO: is this bang correct?
|
||||
this.condition = condition;
|
||||
this.showMessage = showMessage;
|
||||
}
|
||||
applyPostVictory(user: Pokemon, target: Pokemon, move: Move): void {
|
||||
@ -3653,7 +3653,7 @@ export class LessPPMorePowerAttr extends VariablePowerAttr {
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const ppMax = move.pp;
|
||||
const ppUsed = user.moveset.find((m) => m?.moveId === move.id)?.ppUsed!; // TODO: is the bang correct?
|
||||
const ppUsed = user.moveset.find((m) => m.moveId === move.id)?.ppUsed ?? 0;
|
||||
|
||||
let ppRemains = ppMax - ppUsed;
|
||||
/** Reduce to 0 to avoid negative numbers if user has 1PP before attack and target has Ability.PRESSURE */
|
||||
@ -3779,7 +3779,13 @@ export abstract class ConsecutiveUsePowerMultiplierAttr extends MovePowerMultipl
|
||||
let count = 0;
|
||||
let turnMove: TurnMove | undefined;
|
||||
|
||||
while (((turnMove = moveHistory.shift())?.move === move.id || (comboMoves.length && comboMoves.includes(turnMove?.move!))) && (!resetOnFail || turnMove?.result === MoveResult.SUCCESS)) { // TODO: is this bang correct?
|
||||
while (
|
||||
(
|
||||
(turnMove = moveHistory.shift())?.move === move.id
|
||||
|| (comboMoves.length && comboMoves.includes(turnMove?.move ?? Moves.NONE))
|
||||
)
|
||||
&& (!resetOnFail || turnMove?.result === MoveResult.SUCCESS)
|
||||
) {
|
||||
if (count < (limit - 1)) {
|
||||
count++;
|
||||
} else if (resetOnLimit) {
|
||||
@ -4365,8 +4371,8 @@ export class LastMoveDoublePowerAttr extends VariablePowerAttr {
|
||||
|
||||
for (const p of pokemonActed) {
|
||||
const [ lastMove ] = p.getLastXMoves(1);
|
||||
if (lastMove?.result !== MoveResult.FAIL) {
|
||||
if ((lastMove?.result === MoveResult.SUCCESS) && (lastMove?.move === this.move)) {
|
||||
if (lastMove.result !== MoveResult.FAIL) {
|
||||
if ((lastMove.result === MoveResult.SUCCESS) && (lastMove.move === this.move)) {
|
||||
power.value *= 2;
|
||||
return true;
|
||||
} else {
|
||||
@ -5461,7 +5467,7 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
|
||||
: null;
|
||||
}
|
||||
|
||||
getTagTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number | void {
|
||||
getTagTargetBenefitScore(): number {
|
||||
switch (this.tagType) {
|
||||
case BattlerTagType.RECHARGING:
|
||||
case BattlerTagType.PERISH_SONG:
|
||||
@ -5506,6 +5512,9 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
|
||||
case BattlerTagType.CRIT_BOOST:
|
||||
case BattlerTagType.ALWAYS_CRIT:
|
||||
return 5;
|
||||
default:
|
||||
console.warn(`BattlerTag ${BattlerTagType[this.tagType]} is missing a score!`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5514,7 +5523,7 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
|
||||
if (moveChance < 0) {
|
||||
moveChance = 100;
|
||||
}
|
||||
return Math.floor(this.getTagTargetBenefitScore(user, target, move)! * (moveChance / 100)); // TODO: is the bang correct?
|
||||
return Math.floor(this.getTagTargetBenefitScore() * (moveChance / 100));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5769,7 +5778,7 @@ export class ProtectAttr extends AddBattlerTagAttr {
|
||||
|
||||
while (moveHistory.length) {
|
||||
turnMove = moveHistory.shift();
|
||||
if (!allMoves[turnMove?.move!].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) { // TODO: is the bang correct?
|
||||
if (!allMoves[turnMove?.move ?? Moves.NONE].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) {
|
||||
break;
|
||||
}
|
||||
timesUsed++;
|
||||
@ -6688,7 +6697,7 @@ export class FirstMoveTypeAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
const firstMoveType = target.getMoveset()[0]?.getMove().type!; // TODO: is this bang correct?
|
||||
const firstMoveType = target.getMoveset()[0].getMove().type;
|
||||
user.summonData.types = [ firstMoveType ];
|
||||
globalScene.queueMessage(i18next.t("battle:transformedIntoType", { pokemonName: getPokemonNameWithAffix(user), type: i18next.t(`pokemonInfo:Type.${PokemonType[firstMoveType]}`) }));
|
||||
|
||||
@ -7005,7 +7014,7 @@ export class RepeatMoveAttr extends MoveEffectAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
// get the last move used (excluding status based failures) as well as the corresponding moveset slot
|
||||
const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE)!;
|
||||
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move)!;
|
||||
const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move)!;
|
||||
// If the last move used can hit more than one target or has variable targets,
|
||||
// re-compute the targets for the attack
|
||||
// (mainly for alternating double/single battle shenanigans)
|
||||
@ -7039,7 +7048,7 @@ export class RepeatMoveAttr extends MoveEffectAttr {
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user, target, move) => {
|
||||
const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE);
|
||||
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move);
|
||||
const movesetMove = target.getMoveset().find(m => m.moveId === lastMove?.move);
|
||||
const uninstructableMoves = [
|
||||
// Locking/Continually Executed moves
|
||||
Moves.OUTRAGE,
|
||||
@ -7134,19 +7143,19 @@ export class ReducePpMoveAttr extends MoveEffectAttr {
|
||||
*
|
||||
* @param user {@linkcode Pokemon} that used the attack
|
||||
* @param target {@linkcode Pokemon} targeted by the attack
|
||||
* @param move {@linkcode Move} being used
|
||||
* @param move N/A
|
||||
* @param args N/A
|
||||
* @returns {boolean} true
|
||||
* @returns `true`
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
// Null checks can be skipped due to condition function
|
||||
const lastMove = target.getLastXMoves().find(() => true);
|
||||
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move);
|
||||
const lastPpUsed = movesetMove?.ppUsed!; // TODO: is the bang correct?
|
||||
movesetMove!.ppUsed = Math.min((movesetMove?.ppUsed!) + this.reduction, movesetMove?.getMovePp()!); // TODO: is the bang correct?
|
||||
const lastMove = target.getLastXMoves()[0];
|
||||
const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move)!;
|
||||
const lastPpUsed = movesetMove.ppUsed;
|
||||
movesetMove.ppUsed = Math.min((lastPpUsed) + this.reduction, movesetMove.getMovePp());
|
||||
|
||||
const message = i18next.t("battle:ppReduced", { targetName: getPokemonNameWithAffix(target), moveName: movesetMove?.getName(), reduction: (movesetMove?.ppUsed!) - lastPpUsed }); // TODO: is the bang correct?
|
||||
globalScene.eventTarget.dispatchEvent(new MoveUsedEvent(target?.id, movesetMove?.getMove()!, movesetMove?.ppUsed!)); // TODO: are these bangs correct?
|
||||
const message = i18next.t("battle:ppReduced", { targetName: getPokemonNameWithAffix(target), moveName: movesetMove.getName(), reduction: (movesetMove.ppUsed) - lastPpUsed });
|
||||
globalScene.eventTarget.dispatchEvent(new MoveUsedEvent(target.id, movesetMove.getMove(), movesetMove.ppUsed));
|
||||
globalScene.queueMessage(message);
|
||||
|
||||
return true;
|
||||
@ -7154,9 +7163,9 @@ export class ReducePpMoveAttr extends MoveEffectAttr {
|
||||
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user, target, move) => {
|
||||
const lastMove = target.getLastXMoves().find(() => true);
|
||||
const lastMove = target.getLastXMoves()[0];
|
||||
if (lastMove) {
|
||||
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move);
|
||||
const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move);
|
||||
return !!movesetMove?.getPpRatio();
|
||||
}
|
||||
return false;
|
||||
@ -7164,9 +7173,9 @@ export class ReducePpMoveAttr extends MoveEffectAttr {
|
||||
}
|
||||
|
||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
|
||||
const lastMove = target.getLastXMoves().find(() => true);
|
||||
const lastMove = target.getLastXMoves()[0];
|
||||
if (lastMove) {
|
||||
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move);
|
||||
const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move);
|
||||
if (movesetMove) {
|
||||
const maxPp = movesetMove.getMovePp();
|
||||
const ppLeft = maxPp - movesetMove.ppUsed;
|
||||
@ -7203,7 +7212,7 @@ export class AttackReducePpMoveAttr extends ReducePpMoveAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const lastMove = target.getLastXMoves().find(() => true);
|
||||
if (lastMove) {
|
||||
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move);
|
||||
const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move);
|
||||
if (Boolean(movesetMove?.getPpRatio())) {
|
||||
super.apply(user, target, move, args);
|
||||
}
|
||||
@ -7249,7 +7258,7 @@ export class MovesetCopyMoveAttr extends OverrideMoveEffectAttr {
|
||||
|
||||
const copiedMove = allMoves[targetMoves[0].move];
|
||||
|
||||
const thisMoveIndex = user.getMoveset().findIndex(m => m?.moveId === move.id);
|
||||
const thisMoveIndex = user.getMoveset().findIndex(m => m.moveId === move.id);
|
||||
|
||||
if (thisMoveIndex === -1) {
|
||||
return false;
|
||||
@ -7301,7 +7310,7 @@ export class SketchAttr extends MoveEffectAttr {
|
||||
}
|
||||
|
||||
const sketchedMove = allMoves[targetMove.move];
|
||||
const sketchIndex = user.getMoveset().findIndex(m => m?.moveId === move.id);
|
||||
const sketchIndex = user.getMoveset().findIndex(m => m.moveId === move.id);
|
||||
if (sketchIndex === -1) {
|
||||
return false;
|
||||
}
|
||||
@ -7340,7 +7349,7 @@ export class SketchAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (user.getMoveset().find(m => m?.moveId === targetMove.move)) {
|
||||
if (user.getMoveset().find(m => m.moveId === targetMove.move)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7790,7 +7799,7 @@ export class LastResortAttr extends MoveAttr {
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user: Pokemon, target: Pokemon, move: Move) => {
|
||||
const uniqueUsedMoveIds = new Set<Moves>();
|
||||
const movesetMoveIds = user.getMoveset().map(m => m?.moveId);
|
||||
const movesetMoveIds = user.getMoveset().map(m => m.moveId);
|
||||
user.getMoveHistory().map(m => {
|
||||
if (m.move !== move.id && movesetMoveIds.find(mm => mm === m.move)) {
|
||||
uniqueUsedMoveIds.add(m.move);
|
||||
@ -9186,7 +9195,17 @@ export function initMoves() {
|
||||
.attr(FlinchAttr),
|
||||
new AttackMove(Moves.WEATHER_BALL, PokemonType.NORMAL, MoveCategory.SPECIAL, 50, 100, 10, -1, 0, 3)
|
||||
.attr(WeatherBallTypeAttr)
|
||||
.attr(MovePowerMultiplierAttr, (user, target, move) => [ WeatherType.SUNNY, WeatherType.RAIN, WeatherType.SANDSTORM, WeatherType.HAIL, WeatherType.SNOW, WeatherType.FOG, WeatherType.HEAVY_RAIN, WeatherType.HARSH_SUN ].includes(globalScene.arena.weather?.weatherType!) && !globalScene.arena.weather?.isEffectSuppressed() ? 2 : 1) // TODO: is this bang correct?
|
||||
.attr(MovePowerMultiplierAttr, (user, target, move) => {
|
||||
const weather = globalScene.arena.weather;
|
||||
if (!weather) {
|
||||
return 1;
|
||||
}
|
||||
const weatherTypes = [ WeatherType.SUNNY, WeatherType.RAIN, WeatherType.SANDSTORM, WeatherType.HAIL, WeatherType.SNOW, WeatherType.FOG, WeatherType.HEAVY_RAIN, WeatherType.HARSH_SUN ];
|
||||
if (weatherTypes.includes(weather.weatherType) && !weather.isEffectSuppressed()) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
.ballBombMove(),
|
||||
new StatusMove(Moves.AROMATHERAPY, PokemonType.GRASS, -1, 5, -1, 0, 3)
|
||||
.attr(PartyStatusCureAttr, i18next.t("moveTriggers:soothingAromaWaftedThroughArea"), Abilities.SAP_SIPPER)
|
||||
@ -9426,7 +9445,13 @@ export function initMoves() {
|
||||
.attr(AbilityChangeAttr, Abilities.INSOMNIA)
|
||||
.reflectable(),
|
||||
new AttackMove(Moves.SUCKER_PUNCH, PokemonType.DARK, MoveCategory.PHYSICAL, 70, 100, 5, -1, 1, 4)
|
||||
.condition((user, target, move) => globalScene.currentBattle.turnCommands[target.getBattlerIndex()]?.command === Command.FIGHT && !target.turnData.acted && allMoves[globalScene.currentBattle.turnCommands[target.getBattlerIndex()]?.move?.move!].category !== MoveCategory.STATUS), // TODO: is this bang correct?
|
||||
.condition((user, target, move) => {
|
||||
const turnCommand = globalScene.currentBattle.turnCommands[target.getBattlerIndex()];
|
||||
if (!turnCommand || !turnCommand.move) {
|
||||
return false;
|
||||
}
|
||||
return (turnCommand.command === Command.FIGHT && !target.turnData.acted && allMoves[turnCommand.move.move].category !== MoveCategory.STATUS);
|
||||
}),
|
||||
new StatusMove(Moves.TOXIC_SPIKES, PokemonType.POISON, -1, 20, -1, 0, 4)
|
||||
.attr(AddArenaTrapTagAttr, ArenaTagType.TOXIC_SPIKES)
|
||||
.target(MoveTarget.ENEMY_SIDE)
|
||||
@ -10321,8 +10346,12 @@ export function initMoves() {
|
||||
.ignoresSubstitute(),
|
||||
new AttackMove(Moves.SMART_STRIKE, PokemonType.STEEL, MoveCategory.PHYSICAL, 70, -1, 10, -1, 0, 7),
|
||||
new StatusMove(Moves.PURIFY, PokemonType.POISON, -1, 20, -1, 0, 7)
|
||||
.condition(
|
||||
(user: Pokemon, target: Pokemon, move: Move) => isNonVolatileStatusEffect(target.status?.effect!)) // TODO: is this bang correct?
|
||||
.condition((user, target, move) => {
|
||||
if (!target.status) {
|
||||
return false;
|
||||
}
|
||||
return isNonVolatileStatusEffect(target.status.effect);
|
||||
})
|
||||
.attr(HealAttr, 0.5)
|
||||
.attr(HealStatusEffectAttr, false, getNonVolatileStatusEffects())
|
||||
.triageMove()
|
||||
@ -11041,7 +11070,13 @@ export function initMoves() {
|
||||
.slicingMove(),
|
||||
new AttackMove(Moves.HYDRO_STEAM, PokemonType.WATER, MoveCategory.SPECIAL, 80, 100, 15, -1, 0, 9)
|
||||
.attr(IgnoreWeatherTypeDebuffAttr, WeatherType.SUNNY)
|
||||
.attr(MovePowerMultiplierAttr, (user, target, move) => [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(globalScene.arena.weather?.weatherType!) && !globalScene.arena.weather?.isEffectSuppressed() ? 1.5 : 1), // TODO: is this bang correct?
|
||||
.attr(MovePowerMultiplierAttr, (user, target, move) => {
|
||||
const weather = globalScene.arena.weather;
|
||||
if (!weather) {
|
||||
return 1;
|
||||
}
|
||||
return [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(weather.weatherType) && !weather.isEffectSuppressed() ? 1.5 : 1;
|
||||
}),
|
||||
new AttackMove(Moves.RUINATION, PokemonType.DARK, MoveCategory.SPECIAL, -1, 90, 10, -1, 0, 9)
|
||||
.attr(TargetHalfHpDamageAttr),
|
||||
new AttackMove(Moves.COLLISION_COURSE, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 100, 100, 5, -1, 0, 9)
|
||||
@ -11156,7 +11191,13 @@ export function initMoves() {
|
||||
.attr(ProtectAttr, BattlerTagType.BURNING_BULWARK)
|
||||
.condition(failIfLastCondition),
|
||||
new AttackMove(Moves.THUNDERCLAP, PokemonType.ELECTRIC, MoveCategory.SPECIAL, 70, 100, 5, -1, 1, 9)
|
||||
.condition((user, target, move) => globalScene.currentBattle.turnCommands[target.getBattlerIndex()]?.command === Command.FIGHT && !target.turnData.acted && allMoves[globalScene.currentBattle.turnCommands[target.getBattlerIndex()]?.move?.move!].category !== MoveCategory.STATUS), // TODO: is this bang correct?
|
||||
.condition((user, target, move) => {
|
||||
const turnCommand = globalScene.currentBattle.turnCommands[target.getBattlerIndex()];
|
||||
if (!turnCommand || !turnCommand.move) {
|
||||
return false;
|
||||
}
|
||||
return (turnCommand.command === Command.FIGHT && !target.turnData.acted && allMoves[turnCommand.move.move].category !== MoveCategory.STATUS);
|
||||
}),
|
||||
new AttackMove(Moves.MIGHTY_CLEAVE, PokemonType.ROCK, MoveCategory.PHYSICAL, 95, 100, 5, -1, 0, 9)
|
||||
.slicingMove()
|
||||
.ignoresProtect(),
|
||||
|
@ -306,7 +306,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter = MysteryEncounterBuil
|
||||
if (eggMoves) {
|
||||
// Cannot gen the rare egg move, only 1 of the first 3 common moves
|
||||
const eggMove = eggMoves[randSeedInt(3)];
|
||||
if (!tradePokemon.moveset.some(m => m?.moveId === eggMove)) {
|
||||
if (!tradePokemon.moveset.some(m => m.moveId === eggMove)) {
|
||||
if (tradePokemon.moveset.length < 4) {
|
||||
tradePokemon.moveset.push(new PokemonMove(eggMove));
|
||||
} else {
|
||||
|
@ -781,7 +781,7 @@ async function addEggMoveToNewPokemonMoveset(
|
||||
let randomEggMoveIndex = eggMoveIndices.pop();
|
||||
let randomEggMove = !isNullOrUndefined(randomEggMoveIndex) ? eggMoves[randomEggMoveIndex] : null;
|
||||
let retries = 0;
|
||||
while (retries < 3 && (!randomEggMove || newPokemon.moveset.some(m => m?.moveId === randomEggMove))) {
|
||||
while (retries < 3 && (!randomEggMove || newPokemon.moveset.some(m => m.moveId === randomEggMove))) {
|
||||
// If Pokemon already knows this move, roll for another egg move
|
||||
randomEggMoveIndex = eggMoveIndices.pop();
|
||||
randomEggMove = !isNullOrUndefined(randomEggMoveIndex) ? eggMoves[randomEggMoveIndex] : null;
|
||||
@ -789,7 +789,7 @@ async function addEggMoveToNewPokemonMoveset(
|
||||
}
|
||||
|
||||
if (randomEggMove) {
|
||||
if (!newPokemon.moveset.some(m => m?.moveId === randomEggMove)) {
|
||||
if (!newPokemon.moveset.some(m => m.moveId === randomEggMove)) {
|
||||
if (newPokemon.moveset.length < 4) {
|
||||
newPokemon.moveset.push(new PokemonMove(randomEggMove));
|
||||
} else {
|
||||
@ -820,16 +820,13 @@ async function addEggMoveToNewPokemonMoveset(
|
||||
*/
|
||||
function addFavoredMoveToNewPokemonMoveset(
|
||||
newPokemon: PlayerPokemon,
|
||||
newPokemonGeneratedMoveset: (PokemonMove | null)[],
|
||||
newPokemonGeneratedMoveset: PokemonMove[],
|
||||
newEggMoveIndex: number | null,
|
||||
) {
|
||||
let favoredMove: PokemonMove | null = null;
|
||||
for (const move of newPokemonGeneratedMoveset) {
|
||||
// Needs to match first type, second type will be replaced
|
||||
if (
|
||||
move?.getMove().type === newPokemon.getTypes()[0] &&
|
||||
!newPokemon.moveset.some(m => m?.moveId === move?.moveId)
|
||||
) {
|
||||
if (move?.getMove().type === newPokemon.getTypes()[0] && !newPokemon.moveset.some(m => m.moveId === move.moveId)) {
|
||||
favoredMove = move;
|
||||
break;
|
||||
}
|
||||
@ -839,7 +836,7 @@ function addFavoredMoveToNewPokemonMoveset(
|
||||
if (!favoredMove) {
|
||||
for (const move of newPokemonGeneratedMoveset) {
|
||||
// Needs to match first type, second type will be replaced
|
||||
if (!newPokemon.moveset.some(m => m?.moveId === move?.moveId)) {
|
||||
if (!newPokemon.moveset.some(m => m.moveId === move.moveId)) {
|
||||
favoredMove = move;
|
||||
break;
|
||||
}
|
||||
|
@ -576,19 +576,19 @@ export class MoveRequirement extends EncounterPokemonRequirement {
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) &&
|
||||
pokemon.moveset.some(move => move?.moveId && this.requiredMoves.includes(move.moveId)),
|
||||
pokemon.moveset.some(move => move.moveId && this.requiredMoves.includes(move.moveId)),
|
||||
);
|
||||
}
|
||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed moves
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) &&
|
||||
!pokemon.moveset.some(move => move?.moveId && this.requiredMoves.includes(move.moveId)),
|
||||
!pokemon.moveset.some(move => move.moveId && this.requiredMoves.includes(move.moveId)),
|
||||
);
|
||||
}
|
||||
|
||||
override getDialogueToken(pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedMoves = pokemon?.moveset.filter(move => move?.moveId && this.requiredMoves.includes(move.moveId));
|
||||
const includedMoves = pokemon?.moveset.filter(move => move.moveId && this.requiredMoves.includes(move.moveId));
|
||||
if (includedMoves && includedMoves.length > 0 && includedMoves[0]) {
|
||||
return ["move", includedMoves[0].getName()];
|
||||
}
|
||||
@ -626,7 +626,7 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement {
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
this.requiredMoves.filter(learnableMove =>
|
||||
pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(learnableMove),
|
||||
pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(learnableMove),
|
||||
).length > 0,
|
||||
);
|
||||
}
|
||||
@ -634,14 +634,14 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement {
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
this.requiredMoves.filter(learnableMove =>
|
||||
pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(learnableMove),
|
||||
pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(learnableMove),
|
||||
).length === 0,
|
||||
);
|
||||
}
|
||||
|
||||
override getDialogueToken(pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedCompatMoves = this.requiredMoves.filter(reqMove =>
|
||||
pokemon?.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(reqMove),
|
||||
pokemon?.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(reqMove),
|
||||
);
|
||||
if (includedCompatMoves.length > 0) {
|
||||
return ["compatibleMove", Moves[includedCompatMoves[0]]];
|
||||
|
@ -363,7 +363,7 @@ export class SpeciesFormChangeMoveLearnedTrigger extends SpeciesFormChangeTrigge
|
||||
}
|
||||
|
||||
canChange(pokemon: Pokemon): boolean {
|
||||
return !!pokemon.moveset.filter(m => m?.moveId === this.move).length === this.known;
|
||||
return !!pokemon.moveset.filter(m => m.moveId === this.move).length === this.known;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
public stats: number[];
|
||||
public ivs: number[];
|
||||
public nature: Nature;
|
||||
public moveset: (PokemonMove | null)[];
|
||||
public moveset: PokemonMove[];
|
||||
public status: Status | null;
|
||||
public friendship: number;
|
||||
public metLevel: number;
|
||||
@ -694,7 +694,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
loadAssets(ignoreOverride = true): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const moveIds = this.getMoveset().map(m => m!.getMove().id); // TODO: is this bang correct?
|
||||
const moveIds = this.getMoveset().map(m => m.getMove().id);
|
||||
Promise.allSettled(moveIds.map(m => initMoveAnim(m))).then(() => {
|
||||
loadMoveAnimAssets(moveIds);
|
||||
this.getSpeciesForm().loadAssets(
|
||||
@ -1751,7 +1751,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
abstract isBoss(): boolean;
|
||||
|
||||
getMoveset(ignoreOverride?: boolean): (PokemonMove | null)[] {
|
||||
getMoveset(ignoreOverride?: boolean): PokemonMove[] {
|
||||
const ret =
|
||||
!ignoreOverride && this.summonData?.moveset
|
||||
? this.summonData.moveset
|
||||
@ -1826,9 +1826,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
.filter(m => !levelMoves.includes(m))
|
||||
.concat(levelMoves);
|
||||
}
|
||||
levelMoves = levelMoves.filter(
|
||||
lm => !this.moveset.some(m => m?.moveId === lm),
|
||||
);
|
||||
levelMoves = levelMoves.filter(lm => !this.moveset.some(m => m.moveId === lm));
|
||||
return levelMoves;
|
||||
}
|
||||
|
||||
@ -2942,7 +2940,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
setMove(moveIndex: number, moveId: Moves): void {
|
||||
const move = moveId ? new PokemonMove(moveId) : null;
|
||||
if (moveId === Moves.NONE) {
|
||||
return;
|
||||
}
|
||||
const move = new PokemonMove(moveId);
|
||||
this.moveset[moveIndex] = move;
|
||||
if (this.summonData?.moveset) {
|
||||
this.summonData.moveset[moveIndex] = move;
|
||||
@ -3487,14 +3488,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
// Other damaging moves 2x weight if 0-1 damaging moves, 0.5x if 2, 0.125x if 3. These weights get 20x if STAB.
|
||||
// Status moves remain unchanged on weight, this encourages 1-2
|
||||
movePool = baseWeights
|
||||
.filter(m => !this.moveset.some(mo => m[0] === mo?.moveId))
|
||||
.filter(m => !this.moveset.some(mo => m[0] === mo.moveId))
|
||||
.map(m => {
|
||||
let ret: number;
|
||||
if (
|
||||
this.moveset.some(
|
||||
mo =>
|
||||
mo?.getMove().category !== MoveCategory.STATUS &&
|
||||
mo?.getMove().type === allMoves[m[0]].type,
|
||||
mo.getMove().category !== MoveCategory.STATUS &&
|
||||
mo.getMove().type === allMoves[m[0]].type,
|
||||
)
|
||||
) {
|
||||
ret = Math.ceil(Math.sqrt(m[1]));
|
||||
@ -3504,7 +3505,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
Math.max(
|
||||
Math.pow(
|
||||
4,
|
||||
this.moveset.filter(mo => (mo?.getMove().power ?? 0) > 1)
|
||||
this.moveset.filter(mo => (mo.getMove().power ?? 0) > 1)
|
||||
.length,
|
||||
) / 8,
|
||||
0.5,
|
||||
@ -3518,9 +3519,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
});
|
||||
} else {
|
||||
// Non-trainer pokemon just use normal weights
|
||||
movePool = baseWeights.filter(
|
||||
m => !this.moveset.some(mo => m[0] === mo?.moveId),
|
||||
);
|
||||
movePool = baseWeights.filter(m => !this.moveset.some(mo => m[0] === mo.moveId));
|
||||
}
|
||||
const totalWeight = movePool.reduce((v, m) => v + m[1], 0);
|
||||
let rand = Utils.randSeedInt(totalWeight);
|
||||
@ -6852,18 +6851,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
copyMoveset(): PokemonMove[] {
|
||||
const newMoveset: PokemonMove[] = [];
|
||||
this.moveset.forEach(move => {
|
||||
// TODO: refactor `moveset` to not accept `null`s
|
||||
if (move) {
|
||||
newMoveset.push(
|
||||
new PokemonMove(
|
||||
move.moveId,
|
||||
0,
|
||||
move.ppUp,
|
||||
move.virtual,
|
||||
move.maxPpOverride,
|
||||
),
|
||||
);
|
||||
}
|
||||
newMoveset.push(new PokemonMove(move.moveId, 0, move.ppUp, move.virtual, move.maxPpOverride));
|
||||
});
|
||||
|
||||
return newMoveset;
|
||||
@ -7050,17 +7038,8 @@ export class EnemyPokemon extends Pokemon {
|
||||
if (moveQueue.length !== 0) {
|
||||
const queuedMove = moveQueue[0];
|
||||
if (queuedMove) {
|
||||
const moveIndex = this.getMoveset().findIndex(
|
||||
m => m?.moveId === queuedMove.move,
|
||||
);
|
||||
if (
|
||||
(moveIndex > -1 &&
|
||||
this.getMoveset()[moveIndex]!.isUsable(
|
||||
this,
|
||||
queuedMove.ignorePP,
|
||||
)) ||
|
||||
queuedMove.virtual
|
||||
) {
|
||||
const moveIndex = this.getMoveset().findIndex(m => m.moveId === queuedMove.move);
|
||||
if ((moveIndex > -1 && this.getMoveset()[moveIndex].isUsable(this, queuedMove.ignorePP)) || queuedMove.virtual) {
|
||||
return queuedMove;
|
||||
} else {
|
||||
this.getMoveQueue().shift();
|
||||
@ -7070,20 +7049,17 @@ export class EnemyPokemon extends Pokemon {
|
||||
}
|
||||
|
||||
// Filter out any moves this Pokemon cannot use
|
||||
let movePool = this.getMoveset().filter(m => m?.isUsable(this));
|
||||
let movePool = this.getMoveset().filter(m => m.isUsable(this));
|
||||
// If no moves are left, use Struggle. Otherwise, continue with move selection
|
||||
if (movePool.length) {
|
||||
// If there's only 1 move in the move pool, use it.
|
||||
if (movePool.length === 1) {
|
||||
return {
|
||||
move: movePool[0]!.moveId,
|
||||
targets: this.getNextTargets(movePool[0]!.moveId),
|
||||
}; // TODO: are the bangs correct?
|
||||
return { move: movePool[0].moveId, targets: this.getNextTargets(movePool[0].moveId) };
|
||||
}
|
||||
// If a move is forced because of Encore, use it.
|
||||
const encoreTag = this.getTag(EncoreTag) as EncoreTag;
|
||||
if (encoreTag) {
|
||||
const encoreMove = movePool.find(m => m?.moveId === encoreTag.moveId);
|
||||
const encoreMove = movePool.find(m => m.moveId === encoreTag.moveId);
|
||||
if (encoreMove) {
|
||||
return {
|
||||
move: encoreMove.moveId,
|
||||
@ -7093,8 +7069,7 @@ export class EnemyPokemon extends Pokemon {
|
||||
}
|
||||
switch (this.aiType) {
|
||||
case AiType.RANDOM: // No enemy should spawn with this AI type in-game
|
||||
const moveId =
|
||||
movePool[globalScene.randBattleSeedInt(movePool.length)]!.moveId; // TODO: is the bang correct?
|
||||
const moveId = movePool[globalScene.randBattleSeedInt(movePool.length)].moveId;
|
||||
return { move: moveId, targets: this.getNextTargets(moveId) };
|
||||
case AiType.SMART_RANDOM:
|
||||
case AiType.SMART:
|
||||
@ -7156,11 +7131,9 @@ export class EnemyPokemon extends Pokemon {
|
||||
* For more information on how benefit scores are calculated, see `docs/enemy-ai.md`.
|
||||
*/
|
||||
const moveScores = movePool.map(() => 0);
|
||||
const moveTargets = Object.fromEntries(
|
||||
movePool.map(m => [m!.moveId, this.getNextTargets(m!.moveId)]),
|
||||
); // TODO: are those bangs correct?
|
||||
const moveTargets = Object.fromEntries(movePool.map(m => [ m.moveId, this.getNextTargets(m.moveId) ]));
|
||||
for (const m in movePool) {
|
||||
const pokemonMove = movePool[m]!; // TODO: is the bang correct?
|
||||
const pokemonMove = movePool[m];
|
||||
const move = pokemonMove.getMove();
|
||||
|
||||
let moveScore = moveScores[m];
|
||||
@ -7269,16 +7242,8 @@ export class EnemyPokemon extends Pokemon {
|
||||
r++;
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
movePool.map(m => m!.getName()),
|
||||
moveScores,
|
||||
r,
|
||||
sortedMovePool.map(m => m!.getName()),
|
||||
); // TODO: are those bangs correct?
|
||||
return {
|
||||
move: sortedMovePool[r]!.moveId,
|
||||
targets: moveTargets[sortedMovePool[r]!.moveId],
|
||||
};
|
||||
console.log(movePool.map(m => m.getName()), moveScores, r, sortedMovePool.map(m => m.getName()));
|
||||
return { move: sortedMovePool[r]!.moveId, targets: moveTargets[sortedMovePool[r]!.moveId] };
|
||||
}
|
||||
}
|
||||
|
||||
@ -7637,7 +7602,7 @@ export class PokemonSummonData {
|
||||
public gender: Gender;
|
||||
public fusionGender: Gender;
|
||||
public stats: number[] = [0, 0, 0, 0, 0, 0];
|
||||
public moveset: (PokemonMove | null)[];
|
||||
public moveset: PokemonMove[];
|
||||
// If not initialized this value will not be populated from save data.
|
||||
public types: PokemonType[] = [];
|
||||
public addedType: PokemonType | null = null;
|
||||
|
@ -627,7 +627,7 @@ export class PokemonAllMovePpRestoreModifierType extends PokemonModifierType {
|
||||
iconImage,
|
||||
(_type, args) => new PokemonAllMovePpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints),
|
||||
(pokemon: PlayerPokemon) => {
|
||||
if (!pokemon.getMoveset().filter(m => m?.ppUsed).length) {
|
||||
if (!pokemon.getMoveset().filter(m => m.ppUsed).length) {
|
||||
return PartyUiHandler.NoEffectMessage;
|
||||
}
|
||||
return null;
|
||||
@ -1170,7 +1170,7 @@ export class TmModifierType extends PokemonModifierType {
|
||||
(pokemon: PlayerPokemon) => {
|
||||
if (
|
||||
pokemon.compatibleTms.indexOf(moveId) === -1 ||
|
||||
pokemon.getMoveset().filter(m => m?.moveId === moveId).length
|
||||
pokemon.getMoveset().filter(m => m.moveId === moveId).length
|
||||
) {
|
||||
return PartyUiHandler.NoEffectMessage;
|
||||
}
|
||||
@ -1333,7 +1333,7 @@ class AttackTypeBoosterModifierTypeGenerator extends ModifierTypeGenerator {
|
||||
const attackMoveTypes = party.flatMap(p =>
|
||||
p
|
||||
.getMoveset()
|
||||
.map(m => m?.getMove())
|
||||
.map(m => m.getMove())
|
||||
.filter(m => m instanceof AttackMove)
|
||||
.map(m => m.type),
|
||||
);
|
||||
@ -1468,7 +1468,7 @@ class SpeciesStatBoosterModifierTypeGenerator extends ModifierTypeGenerator {
|
||||
const speciesId = p.getSpeciesForm(true).speciesId;
|
||||
const fusionSpeciesId = p.isFusion() ? p.getFusionSpeciesForm(true).speciesId : null;
|
||||
// TODO: Use commented boolean when Fling is implemented
|
||||
const hasFling = false; /* p.getMoveset(true).some(m => m?.moveId === Moves.FLING) */
|
||||
const hasFling = false; /* p.getMoveset(true).some(m => m.moveId === Moves.FLING) */
|
||||
|
||||
for (const i in values) {
|
||||
const checkedSpecies = values[i].species;
|
||||
@ -1529,7 +1529,7 @@ class TmModifierTypeGenerator extends ModifierTypeGenerator {
|
||||
const partyMemberCompatibleTms = party.map(p => {
|
||||
const previousLevelMoves = p.getLearnableLevelMoves();
|
||||
return (p as PlayerPokemon).compatibleTms.filter(
|
||||
tm => !p.moveset.find(m => m?.moveId === tm) && !previousLevelMoves.find(lm => lm === tm),
|
||||
tm => !p.moveset.find(m => m.moveId === tm) && !previousLevelMoves.find(lm => lm === tm),
|
||||
);
|
||||
});
|
||||
const tierUniqueCompatibleTms = partyMemberCompatibleTms
|
||||
@ -2433,7 +2433,7 @@ const modifierPool: ModifierPool = {
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
@ -2452,7 +2452,7 @@ const modifierPool: ModifierPool = {
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
@ -2574,7 +2574,7 @@ const modifierPool: ModifierPool = {
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
@ -2593,7 +2593,7 @@ const modifierPool: ModifierPool = {
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
|
@ -104,15 +104,14 @@ export class CommandPhase extends FieldPhase {
|
||||
moveQueue[0] &&
|
||||
moveQueue[0].move &&
|
||||
!moveQueue[0].virtual &&
|
||||
(!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move) ||
|
||||
(!playerPokemon.getMoveset().find(m => m.moveId === moveQueue[0].move) ||
|
||||
!playerPokemon
|
||||
.getMoveset()
|
||||
[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(
|
||||
[playerPokemon.getMoveset().findIndex(m => m.moveId === moveQueue[0].move)].isUsable(
|
||||
playerPokemon,
|
||||
moveQueue[0].ignorePP,
|
||||
))
|
||||
) {
|
||||
// TODO: is the bang correct?
|
||||
moveQueue.shift();
|
||||
}
|
||||
|
||||
@ -121,12 +120,11 @@ export class CommandPhase extends FieldPhase {
|
||||
if (!queuedMove.move) {
|
||||
this.handleCommand(Command.FIGHT, -1);
|
||||
} 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(playerPokemon, queuedMove.ignorePP)) ||
|
||||
(moveIndex > -1 && playerPokemon.getMoveset()[moveIndex].isUsable(playerPokemon, queuedMove.ignorePP)) ||
|
||||
queuedMove.virtual
|
||||
) {
|
||||
// TODO: is the bang correct?
|
||||
this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, queuedMove);
|
||||
} else {
|
||||
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
@ -157,7 +155,7 @@ 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)
|
||||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)
|
||||
) {
|
||||
let moveId: Moves;
|
||||
if (useStruggle) {
|
||||
@ -165,7 +163,7 @@ export class CommandPhase extends FieldPhase {
|
||||
} else if (turnMove !== undefined) {
|
||||
moveId = turnMove.move;
|
||||
} else if (cursor > -1) {
|
||||
moveId = playerPokemon.getMoveset()[cursor]!.moveId;
|
||||
moveId = playerPokemon.getMoveset()[cursor].moveId;
|
||||
} else {
|
||||
moveId = Moves.NONE;
|
||||
}
|
||||
@ -195,10 +193,14 @@ export class CommandPhase extends FieldPhase {
|
||||
if (moveTargets.targets.length > 1 && moveTargets.multiple) {
|
||||
globalScene.unshiftPhase(new SelectTargetPhase(this.fieldIndex));
|
||||
}
|
||||
if (moveTargets.targets.length <= 1 || moveTargets.multiple) {
|
||||
turnCommand.move!.targets = moveTargets.targets; //TODO: is the bang correct here?
|
||||
} else if (playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) {
|
||||
turnCommand.move!.targets = playerPokemon.getMoveQueue()[0].targets; //TODO: is the bang correct here?
|
||||
if (turnCommand.move && (moveTargets.targets.length <= 1 || moveTargets.multiple)) {
|
||||
turnCommand.move.targets = moveTargets.targets;
|
||||
} else if (
|
||||
turnCommand.move &&
|
||||
playerPokemon.getTag(BattlerTagType.CHARGING) &&
|
||||
playerPokemon.getMoveQueue().length >= 1
|
||||
) {
|
||||
turnCommand.move.targets = playerPokemon.getMoveQueue()[0].targets;
|
||||
} else {
|
||||
globalScene.unshiftPhase(new SelectTargetPhase(this.fieldIndex));
|
||||
}
|
||||
@ -206,7 +208,7 @@ export class CommandPhase extends FieldPhase {
|
||||
globalScene.currentBattle.turnCommands[this.fieldIndex] = turnCommand;
|
||||
success = true;
|
||||
} else if (cursor < playerPokemon.getMoveset().length) {
|
||||
const move = playerPokemon.getMoveset()[cursor]!; //TODO: is this bang correct?
|
||||
const move = playerPokemon.getMoveset()[cursor];
|
||||
globalScene.ui.setMode(Mode.MESSAGE);
|
||||
|
||||
// Decides between a Disabled, Not Implemented, or No PP translation message
|
||||
|
@ -49,7 +49,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
||||
const currentMoveset = pokemon.getMoveset();
|
||||
|
||||
// The game first checks if the Pokemon already has the move and ends the phase if it does.
|
||||
const hasMoveAlready = currentMoveset.some(m => m?.moveId === move.id) && this.moveId !== Moves.SKETCH;
|
||||
const hasMoveAlready = currentMoveset.some(m => m.moveId === move.id) && this.moveId !== Moves.SKETCH;
|
||||
if (hasMoveAlready) {
|
||||
return this.end();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export class PartyHealPhase extends BattlePhase {
|
||||
pokemon.hp = pokemon.getMaxHp();
|
||||
pokemon.resetStatus();
|
||||
for (const move of pokemon.moveset) {
|
||||
move!.ppUsed = 0; // TODO: is this bang correct?
|
||||
move.ppUsed = 0;
|
||||
}
|
||||
pokemon.updateInfo(true);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ export class TurnStartPhase extends FieldPhase {
|
||||
continue;
|
||||
}
|
||||
const move =
|
||||
pokemon.getMoveset().find(m => m?.moveId === queuedMove.move && m?.ppUsed < m?.getMovePp()) ||
|
||||
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ||
|
||||
new PokemonMove(queuedMove.move);
|
||||
if (move.getMove().hasAttr(MoveHeaderAttr)) {
|
||||
globalScene.unshiftPhase(new MoveHeaderPhase(pokemon, move));
|
||||
|
@ -35,7 +35,7 @@ export default class PokemonData {
|
||||
public stats: number[];
|
||||
public ivs: number[];
|
||||
public nature: Nature;
|
||||
public moveset: (PokemonMove | null)[];
|
||||
public moveset: PokemonMove[];
|
||||
public status: Status | null;
|
||||
public friendship: number;
|
||||
public metLevel: number;
|
||||
|
@ -243,7 +243,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle {
|
||||
const hasMove = cursor < moveset.length;
|
||||
|
||||
if (hasMove) {
|
||||
const pokemonMove = moveset[cursor]!; // TODO: is the bang correct?
|
||||
const pokemonMove = moveset[cursor];
|
||||
const moveType = pokemon.getMoveType(pokemonMove.getMove());
|
||||
const textureKey = Utils.getLocalizedSpriteKey("types");
|
||||
this.typeIcon.setTexture(textureKey, PokemonType[moveType].toLowerCase()).setScale(0.8);
|
||||
|
@ -478,7 +478,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
filterResult = this.FilterChallengeLegal(pokemon);
|
||||
}
|
||||
if (filterResult === null && this.partyUiMode === PartyUiMode.MOVE_MODIFIER) {
|
||||
filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]!); // TODO: is this bang correct?
|
||||
filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]);
|
||||
}
|
||||
} else {
|
||||
filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)(
|
||||
@ -1182,7 +1182,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
case PartyOption.MOVE_2:
|
||||
case PartyOption.MOVE_3:
|
||||
case PartyOption.MOVE_4:
|
||||
const move = pokemon.moveset[option - PartyOption.MOVE_1]!; // TODO: is the bang correct?
|
||||
const move = pokemon.moveset[option - PartyOption.MOVE_1];
|
||||
if (this.showMovePp) {
|
||||
const maxPP = move.getMovePp();
|
||||
const currPP = maxPP - move.ppUsed;
|
||||
@ -1647,7 +1647,7 @@ class PartySlot extends Phaser.GameObjects.Container {
|
||||
this.slotHpText.setVisible(false);
|
||||
let slotTmText: string;
|
||||
|
||||
if (this.pokemon.getMoveset().filter(m => m?.moveId === tmMoveId).length > 0) {
|
||||
if (this.pokemon.getMoveset().filter(m => m.moveId === tmMoveId).length > 0) {
|
||||
slotTmText = i18next.t("partyUiHandler:learned");
|
||||
} else if (this.pokemon.compatibleTms.indexOf(tmMoveId) === -1) {
|
||||
slotTmText = i18next.t("partyUiHandler:notAble");
|
||||
|
@ -1208,7 +1208,7 @@ export default class SummaryUiHandler extends UiHandler {
|
||||
}
|
||||
|
||||
if (this.moveCursor < 4 && this.pokemon && this.moveCursor < this.pokemon.moveset.length) {
|
||||
return this.pokemon.moveset[this.moveCursor]!.getMove(); // TODO: is this bang correct?
|
||||
return this.pokemon.moveset[this.moveCursor].getMove();
|
||||
}
|
||||
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE && this.moveCursor === 4) {
|
||||
return this.newMove;
|
||||
|
@ -24,7 +24,7 @@ describe("Abilities - Lightningrod", () => {
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.moveset([ Moves.SPLASH, Moves.SHOCK_WAVE ])
|
||||
.moveset([Moves.SPLASH, Moves.SHOCK_WAVE])
|
||||
.ability(Abilities.BALL_FETCH)
|
||||
.battleType("double")
|
||||
.disableCrits()
|
||||
@ -34,7 +34,7 @@ describe("Abilities - Lightningrod", () => {
|
||||
});
|
||||
|
||||
it("should redirect electric type moves", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
@ -49,8 +49,8 @@ describe("Abilities - Lightningrod", () => {
|
||||
});
|
||||
|
||||
it("should not redirect non-electric type moves", async () => {
|
||||
game.override.moveset([ Moves.SPLASH, Moves.AERIAL_ACE ]);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
game.override.moveset([Moves.SPLASH, Moves.AERIAL_ACE]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
@ -65,7 +65,7 @@ describe("Abilities - Lightningrod", () => {
|
||||
});
|
||||
|
||||
it("should boost the user's spatk without damaging", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
|
||||
@ -81,7 +81,7 @@ describe("Abilities - Lightningrod", () => {
|
||||
|
||||
it("should not redirect moves changed from electric type via ability", async () => {
|
||||
game.override.ability(Abilities.NORMALIZE);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
@ -96,9 +96,8 @@ describe("Abilities - Lightningrod", () => {
|
||||
});
|
||||
|
||||
it("should redirect moves changed to electric type via ability", async () => {
|
||||
game.override.ability(Abilities.GALVANIZE)
|
||||
.moveset(Moves.TACKLE);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
game.override.ability(Abilities.GALVANIZE).moveset(Moves.TACKLE);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
|
@ -176,11 +176,8 @@ describe("Abilities - Neutralizing Gas", () => {
|
||||
});
|
||||
|
||||
it("should not activate abilities of pokemon no longer on the field", async () => {
|
||||
game.override
|
||||
.battleType("single")
|
||||
.ability(Abilities.NEUTRALIZING_GAS)
|
||||
.enemyAbility(Abilities.DELTA_STREAM);
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
game.override.battleType("single").ability(Abilities.NEUTRALIZING_GAS).enemyAbility(Abilities.DELTA_STREAM);
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
const weatherChangeAttr = enemy.getAbilityAttrs(PostSummonWeatherChangeAbAttr, false)[0];
|
||||
|
@ -24,7 +24,7 @@ describe("Abilities - Storm Drain", () => {
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.moveset([ Moves.SPLASH, Moves.WATER_GUN ])
|
||||
.moveset([Moves.SPLASH, Moves.WATER_GUN])
|
||||
.ability(Abilities.BALL_FETCH)
|
||||
.battleType("double")
|
||||
.disableCrits()
|
||||
@ -34,7 +34,7 @@ describe("Abilities - Storm Drain", () => {
|
||||
});
|
||||
|
||||
it("should redirect water type moves", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
@ -49,8 +49,8 @@ describe("Abilities - Storm Drain", () => {
|
||||
});
|
||||
|
||||
it("should not redirect non-water type moves", async () => {
|
||||
game.override.moveset([ Moves.SPLASH, Moves.AERIAL_ACE ]);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
game.override.moveset([Moves.SPLASH, Moves.AERIAL_ACE]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
@ -65,7 +65,7 @@ describe("Abilities - Storm Drain", () => {
|
||||
});
|
||||
|
||||
it("should boost the user's spatk without damaging", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
|
||||
@ -81,7 +81,7 @@ describe("Abilities - Storm Drain", () => {
|
||||
|
||||
it("should not redirect moves changed from water type via ability", async () => {
|
||||
game.override.ability(Abilities.NORMALIZE);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
@ -96,9 +96,8 @@ describe("Abilities - Storm Drain", () => {
|
||||
});
|
||||
|
||||
it("should redirect moves changed to water type via ability", async () => {
|
||||
game.override.ability(Abilities.LIQUID_VOICE)
|
||||
.moveset(Moves.PSYCHIC_NOISE);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]);
|
||||
game.override.ability(Abilities.LIQUID_VOICE).moveset(Moves.PSYCHIC_NOISE);
|
||||
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);
|
||||
|
||||
const enemy1 = game.scene.getEnemyField()[0];
|
||||
const enemy2 = game.scene.getEnemyField()[1];
|
||||
|
@ -41,7 +41,7 @@ describe("Moves - Grudge", () => {
|
||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
const playerMove = playerPokemon?.getMoveset().find(m => m?.moveId === Moves.EMBER);
|
||||
const playerMove = playerPokemon?.getMoveset().find(m => m.moveId === Moves.EMBER);
|
||||
|
||||
expect(playerMove?.getPpRatio()).toBe(0);
|
||||
});
|
||||
@ -60,7 +60,7 @@ describe("Moves - Grudge", () => {
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
const playerMove = playerPokemon?.getMoveset().find(m => m?.moveId === Moves.EMBER);
|
||||
const playerMove = playerPokemon?.getMoveset().find(m => m.moveId === Moves.EMBER);
|
||||
|
||||
expect(playerMove?.getPpRatio()).toBe(0);
|
||||
});
|
||||
@ -84,7 +84,7 @@ describe("Moves - Grudge", () => {
|
||||
|
||||
expect(enemyPokemon?.isFainted()).toBe(true);
|
||||
|
||||
const playerMove = playerPokemon?.getMoveset().find(m => m?.moveId === Moves.FALSE_SWIPE);
|
||||
const playerMove = playerPokemon?.getMoveset().find(m => m.moveId === Moves.FALSE_SWIPE);
|
||||
expect(playerMove?.getPpRatio()).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
@ -136,7 +136,7 @@ describe("Absolute Avarice - Mystery Encounter", () => {
|
||||
expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
|
||||
expect(enemyField.length).toBe(1);
|
||||
expect(enemyField[0].species.speciesId).toBe(Species.GREEDENT);
|
||||
const moveset = enemyField[0].moveset.map(m => m?.moveId);
|
||||
const moveset = enemyField[0].moveset.map(m => m.moveId);
|
||||
expect(moveset?.length).toBe(4);
|
||||
expect(moveset).toEqual([Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH]);
|
||||
|
||||
@ -259,7 +259,7 @@ describe("Absolute Avarice - Mystery Encounter", () => {
|
||||
expect(partyCountBefore + 1).toBe(partyCountAfter);
|
||||
const greedent = scene.getPlayerParty()[scene.getPlayerParty().length - 1];
|
||||
expect(greedent.species.speciesId).toBe(Species.GREEDENT);
|
||||
const moveset = greedent.moveset.map(m => m?.moveId);
|
||||
const moveset = greedent.moveset.map(m => m.moveId);
|
||||
expect(moveset?.length).toBe(4);
|
||||
expect(moveset).toEqual([Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.SLACK_OFF]);
|
||||
});
|
||||
|
@ -112,7 +112,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
|
||||
expect(enemyField.length).toBe(1);
|
||||
expect(enemyField[0].species.speciesId).toBe(Species.ORICORIO);
|
||||
expect(enemyField[0].summonData.statStages).toEqual([1, 1, 1, 1, 0, 0, 0]);
|
||||
const moveset = enemyField[0].moveset.map(m => m?.moveId);
|
||||
const moveset = enemyField[0].moveset.map(m => m.moveId);
|
||||
expect(moveset.some(m => m === Moves.REVELATION_DANCE)).toBeTruthy();
|
||||
|
||||
const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]);
|
||||
@ -208,7 +208,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
|
||||
expect(partyCountBefore + 1).toBe(partyCountAfter);
|
||||
const oricorio = scene.getPlayerParty()[scene.getPlayerParty().length - 1];
|
||||
expect(oricorio.species.speciesId).toBe(Species.ORICORIO);
|
||||
const moveset = oricorio.moveset.map(m => m?.moveId);
|
||||
const moveset = oricorio.moveset.map(m => m.moveId);
|
||||
expect(moveset?.some(m => m === Moves.REVELATION_DANCE)).toBeTruthy();
|
||||
expect(moveset?.some(m => m === Moves.DRAGON_DANCE)).toBeTruthy();
|
||||
});
|
||||
|
@ -292,7 +292,7 @@ export default class GameManager {
|
||||
const move = (this.scene.getCurrentPhase() as SelectTargetPhase)
|
||||
.getPokemon()
|
||||
.getMoveset()
|
||||
[movePosition]!.getMove(); // TODO: is the bang correct?
|
||||
[movePosition].getMove();
|
||||
if (!move.isMultiTarget()) {
|
||||
handler.setCursor(targetIndex !== undefined ? targetIndex : BattlerIndex.ENEMY);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ export function waitUntil(truth): Promise<unknown> {
|
||||
export function getMovePosition(scene: BattleScene, pokemonIndex: 0 | 1, move: Moves): number {
|
||||
const playerPokemon = scene.getPlayerField()[pokemonIndex];
|
||||
const moveSet = playerPokemon.getMoveset();
|
||||
const index = moveSet.findIndex(m => m?.moveId === move && m?.ppUsed < m?.getMovePp());
|
||||
const index = moveSet.findIndex(m => m.moveId === move && m.ppUsed < m.getMovePp());
|
||||
console.log(`Move position for ${Moves[move]} (=${move}):`, index);
|
||||
return index;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user