diff --git a/public/fonts/PokePT_Wansung.woff2 b/public/fonts/PokePT_Wansung.woff2 index 02b299ef7a0..15aab3eb4f4 100644 Binary files a/public/fonts/PokePT_Wansung.woff2 and b/public/fonts/PokePT_Wansung.woff2 differ diff --git a/public/images/pokemon/back/821.png b/public/images/pokemon/back/821.png index a102a0491de..24e0edd705d 100644 Binary files a/public/images/pokemon/back/821.png and b/public/images/pokemon/back/821.png differ diff --git a/public/images/pokemon/back/shiny/821.png b/public/images/pokemon/back/shiny/821.png index 200489518c4..6d29988ed9f 100644 Binary files a/public/images/pokemon/back/shiny/821.png and b/public/images/pokemon/back/shiny/821.png differ diff --git a/public/images/pokemon/exp/821.png b/public/images/pokemon/exp/821.png index e4a73a66140..8bb00063bcb 100644 Binary files a/public/images/pokemon/exp/821.png and b/public/images/pokemon/exp/821.png differ diff --git a/public/images/pokemon/exp/953.png b/public/images/pokemon/exp/953.png index fb4255a112b..8a6ca2e7eff 100644 Binary files a/public/images/pokemon/exp/953.png and b/public/images/pokemon/exp/953.png differ diff --git a/public/images/pokemon/exp/back/821.png b/public/images/pokemon/exp/back/821.png index 80d88dce2f9..13aa5c24e83 100644 Binary files a/public/images/pokemon/exp/back/821.png and b/public/images/pokemon/exp/back/821.png differ diff --git a/public/images/pokemon/exp/back/shiny/821.png b/public/images/pokemon/exp/back/shiny/821.png index 426a1e81fea..d069d59ef72 100644 Binary files a/public/images/pokemon/exp/back/shiny/821.png and b/public/images/pokemon/exp/back/shiny/821.png differ diff --git a/public/images/pokemon/exp/shiny/821.png b/public/images/pokemon/exp/shiny/821.png index 5c03c17c793..6f6cf7f2991 100644 Binary files a/public/images/pokemon/exp/shiny/821.png and b/public/images/pokemon/exp/shiny/821.png differ diff --git a/public/images/pokemon/variant/exp/953.json b/public/images/pokemon/variant/exp/953.json index df4262f3ed2..6f2885be607 100644 --- a/public/images/pokemon/variant/exp/953.json +++ b/public/images/pokemon/variant/exp/953.json @@ -2,79 +2,35 @@ "1": { "5a4d37": "1c1e76", "766348": "323aa5", - "9d8361": "4059bd", "c5b4aa": "d3e6e6", "37332b": "104139", "9e8360": "4059bd", - "f18725": "2e8c19", - "f18625": "2e8c19", - "bb6f2a": "2f7410", "0f0f0f": "0f0f0f", "575243": "18734a", - "b8702d": "2f7410", "777462": "199e46", - "585243": "18734a", - "4f4531": "b29c3e", - "4d4530": "b29c3e", - "aea56b": "f9fba2", - "afa667": "f9fba2", - "a28e85": "c1d8db", - "a28c8c": "c1d8db", - "b64c95": "dedb64", + "afa668": "f9fba2", + "a28c88": "c1d8db", "f2f2f2": "e8eab5", - "b05f8f": "dedb64", - "776348": "323aa5", + "b45492": "dedb64", "f28625": "2e8c19", - "bc6e28": "2f7410", - "bb6e27": "2f7410", - "4d4430": "b29c3e", - "b0a766": "f9fba2", - "a18f8d": "c1d8db", - "a28f86": "c1d8db", - "b74a94": "dedb64", - "9e8461": "4059bd", - "777362": "199e46", - "ba6d27": "2f7410", - "afa567": "f9fba2", - "a18f85": "c1d8db" + "4e4530": "b29c3e", + "ba6e29": "2f7410" }, "2": { "5a4d37": "333e5f", "766348": "8c9fbf", - "9d8361": "dbedec", "c5b4aa": "39cfbc", "37332b": "261031", "9e8360": "dbedec", - "f18725": "4baecd", - "f18625": "4baecd", - "bb6f2a": "4792bd", "0f0f0f": "0f0f0f", "575243": "5e2d72", - "b8702d": "4792bd", "777462": "8358a1", - "585243": "5e2d72", - "4f4531": "534b8c", - "4d4530": "534b8c", - "aea56b": "c9dbac", - "afa667": "c9dbac", - "a28e85": "52b0b0", - "a28c8c": "52b0b0", - "b64c95": "b56c3e", + "afa668": "c9dbac", + "a28e88": "52b0b0", "f2f2f2": "d9c951", - "b05f8f": "b56c3e", - "776348": "8c9fbf", + "b45492": "b56c3e", "f28625": "4baecd", - "bc6e28": "4792bd", - "bb6e27": "4792bd", - "4d4430": "534b8c", - "b0a766": "c9dbac", - "a18f8d": "52b0b0", - "a28f86": "52b0b0", - "b74a94": "b56c3e", - "9e8461": "dbedec", - "777362": "8358a1", - "ba6d27": "4792bd", - "afa567": "c9dbac", - "a18f85": "52b0b0" + "4e4530": "534b8c", + "ba6e29": "4792bd" } -} \ No newline at end of file +} diff --git a/src/battle-scene.ts b/src/battle-scene.ts index b72e79c866d..eaf550e7d10 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -83,6 +83,7 @@ import { SwitchPhase } from "./phases/switch-phase"; import { TitlePhase } from "./phases/title-phase"; import { ToggleDoublePositionPhase } from "./phases/toggle-double-position-phase"; import { TurnInitPhase } from "./phases/turn-init-phase"; +import { ShopCursorTarget } from "./enums/shop-cursor-target"; export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; @@ -127,6 +128,7 @@ export default class BattleScene extends SceneBase { public gameSpeed: integer = 1; public damageNumbersMode: integer = 0; public reroll: boolean = false; + public shopCursorTarget: number = ShopCursorTarget.CHECK_TEAM; public showMovesetFlyout: boolean = true; public showArenaFlyout: boolean = true; public showTimeOfDayWidget: boolean = true; @@ -1100,7 +1102,7 @@ export default class BattleScene extends SceneBase { } else if (trainerConfigs[trainerType].hasDouble) { const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); - playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, doubleChance)); + playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance)); doubleTrainer = !Utils.randSeedInt(doubleChance.value); // Add a check that special trainers can't be double except for tate and liza - they should use the normal double chance if (trainerConfigs[trainerType].trainerTypeDouble && ![ TrainerType.TATE, TrainerType.LIZA ].includes(trainerType)) { @@ -1116,7 +1118,7 @@ export default class BattleScene extends SceneBase { if (newBattleType === BattleType.WILD && !this.gameMode.isWaveFinal(newWaveIndex)) { const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); - playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, doubleChance)); + playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance)); newDouble = !Utils.randSeedInt(doubleChance.value); } else if (newBattleType === BattleType.TRAINER) { newDouble = newTrainer?.variant === TrainerVariant.DOUBLE; @@ -1518,7 +1520,7 @@ export default class BattleScene extends SceneBase { return; } const formattedMoney = Utils.formatMoney(this.moneyFormat, this.money); - this.moneyText.setText(`₽${formattedMoney}`); + this.moneyText.setText(i18next.t("battleScene:moneyOwned", { formattedMoney })); this.fieldUI.moveAbove(this.moneyText, this.luckText); if (forceVisible) { this.moneyText.setVisible(true); @@ -2136,7 +2138,7 @@ export default class BattleScene extends SceneBase { pushMovePhase(movePhase: MovePhase, priorityOverride?: integer): void { const movePriority = new Utils.IntegerHolder(priorityOverride !== undefined ? priorityOverride : movePhase.move.getMove().priority); - applyAbAttrs(ChangeMovePriorityAbAttr, movePhase.pokemon, null, movePhase.move.getMove(), movePriority); + applyAbAttrs(ChangeMovePriorityAbAttr, movePhase.pokemon, null, false, movePhase.move.getMove(), movePriority); const lowerPriorityPhase = this.phaseQueue.find(p => p instanceof MovePhase && p.move.getMove().priority < movePriority.value); if (lowerPriorityPhase) { this.phaseQueue.splice(this.phaseQueue.indexOf(lowerPriorityPhase), 0, movePhase); diff --git a/src/data/ability.ts b/src/data/ability.ts index 5891d20e50c..cb668e63a1c 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -135,7 +135,7 @@ export abstract class AbAttr { this.showAbility = showAbility; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise { return false; } @@ -154,7 +154,7 @@ export abstract class AbAttr { } export class BlockRecoilDamageAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; @@ -170,7 +170,7 @@ export class DoubleBattleChanceAbAttr extends AbAttr { super(false); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const doubleChance = (args[0] as Utils.IntegerHolder); doubleChance.value = Math.max(doubleChance.value / 2, 1); return true; @@ -178,7 +178,7 @@ export class DoubleBattleChanceAbAttr extends AbAttr { } export class PostBattleInitAbAttr extends AbAttr { - applyPostBattleInit(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostBattleInit(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { return false; } } @@ -192,9 +192,9 @@ export class PostBattleInitFormChangeAbAttr extends PostBattleInitAbAttr { this.formFunc = formFunc; } - applyPostBattleInit(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostBattleInit(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const formIndex = this.formFunc(pokemon); - if (formIndex !== pokemon.formIndex) { + if (formIndex !== pokemon.formIndex && !simulated) { return pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); } @@ -217,22 +217,24 @@ export class PostBattleInitStatChangeAbAttr extends PostBattleInitAbAttr { this.selfTarget = !!selfTarget; } - applyPostBattleInit(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostBattleInit(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const statChangePhases: StatChangePhase[] = []; - if (this.selfTarget) { - statChangePhases.push(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); - } else { - for (const opponent of pokemon.getOpponents()) { - statChangePhases.push(new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels)); + if (!simulated) { + if (this.selfTarget) { + statChangePhases.push(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); + } else { + for (const opponent of pokemon.getOpponents()) { + statChangePhases.push(new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels)); + } } - } - for (const statChangePhase of statChangePhases) { - if (!this.selfTarget && !statChangePhase.getPokemon()?.summonData) { - pokemon.scene.pushPhase(statChangePhase); - } else { // TODO: This causes the ability bar to be shown at the wrong time - pokemon.scene.unshiftPhase(statChangePhase); + for (const statChangePhase of statChangePhases) { + if (!this.selfTarget && !statChangePhase.getPokemon()?.summonData) { + pokemon.scene.pushPhase(statChangePhase); + } else { // TODO: This causes the ability bar to be shown at the wrong time + pokemon.scene.unshiftPhase(statChangePhase); + } } } @@ -243,17 +245,17 @@ export class PostBattleInitStatChangeAbAttr extends PostBattleInitAbAttr { type PreDefendAbAttrCondition = (pokemon: Pokemon, attacker: Pokemon, move: Move) => boolean; export class PreDefendAbAttr extends AbAttr { - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise { return false; } } export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr { - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { - if (pokemon.isFullHp() && - pokemon.getMaxHp() > 1 && //Checks if pokemon has wonder_guard (which forces 1hp) - (args[0] as Utils.NumberHolder).value >= pokemon.hp) { //Damage >= hp - return pokemon.addTag(BattlerTagType.STURDY, 1); + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (pokemon.isFullHp() + && pokemon.getMaxHp() > 1 //Checks if pokemon has wonder_guard (which forces 1hp) + && (args[0] as Utils.NumberHolder).value >= pokemon.hp) { //Damage >= hp + return simulated || pokemon.addTag(BattlerTagType.STURDY, 1); } return false; @@ -261,7 +263,7 @@ export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr { } export class BlockItemTheftAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; @@ -276,7 +278,7 @@ export class BlockItemTheftAbAttr extends AbAttr { } export class StabBoostAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if ((args[0] as Utils.NumberHolder).value > 1) { (args[0] as Utils.NumberHolder).value += 0.5; return true; @@ -297,9 +299,9 @@ export class ReceivedMoveDamageMultiplierAbAttr extends PreDefendAbAttr { this.damageMultiplier = damageMultiplier; } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.condition(pokemon, attacker, move)) { - (args[0] as Utils.NumberHolder).value = Math.floor((args[0] as Utils.NumberHolder).value * this.damageMultiplier); + (args[0] as Utils.NumberHolder).value = Utils.toDmgValue((args[0] as Utils.NumberHolder).value * this.damageMultiplier); return true; } @@ -341,7 +343,7 @@ export class TypeImmunityAbAttr extends PreDefendAbAttr { * @param args [0] {@linkcode Utils.NumberHolder} gets set to 0 if move is immuned by an ability. * @param args [1] - Whether the move is simulated. */ - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { // Field moves should ignore immunity if ([ MoveTarget.BOTH_SIDES, MoveTarget.ENEMY_SIDE, MoveTarget.USER_SIDE ].includes(move.moveTarget)) { return false; @@ -368,9 +370,9 @@ export class AttackTypeImmunityAbAttr extends TypeImmunityAbAttr { * Type immunity abilities that do not give additional benefits (HP recovery, stat boosts, etc) are not immune to status moves of the type * Example: Levitate */ - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (move.category !== MoveCategory.STATUS) { - return super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args); + return super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); } return false; } @@ -381,17 +383,14 @@ export class TypeImmunityHealAbAttr extends TypeImmunityAbAttr { super(immuneType); } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { - const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args); + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); if (ret) { - if (!pokemon.isFullHp()) { - const simulated = args.length > 1 && args[1]; - if (!simulated) { - const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; - pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / 4), 1), i18next.t("abilityTriggers:typeImmunityHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true)); - } + if (!pokemon.isFullHp() && !simulated) { + const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; + pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(), + Utils.toDmgValue(pokemon.getMaxHp() / 4), i18next.t("abilityTriggers:typeImmunityHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true)); } return true; } @@ -411,12 +410,11 @@ class TypeImmunityStatChangeAbAttr extends TypeImmunityAbAttr { this.levels = levels; } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { - const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args); + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); if (ret) { cancelled.value = true; - const simulated = args.length > 1 && args[1]; if (!simulated) { pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); } @@ -437,12 +435,11 @@ class TypeImmunityAddBattlerTagAbAttr extends TypeImmunityAbAttr { this.turnCount = turnCount; } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { - const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args); + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); if (ret) { cancelled.value = true; - const simulated = args.length > 1 && args[1]; if (!simulated) { pokemon.addTag(this.tagType, this.turnCount, undefined, pokemon.id); } @@ -457,7 +454,7 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr { super(null, condition); } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (move instanceof AttackMove && pokemon.getAttackTypeEffectiveness(move.type, attacker) < 2) { cancelled.value = true; (args[0] as Utils.NumberHolder).value = 0; @@ -476,7 +473,7 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr { } export class PostDefendAbAttr extends AbAttr { - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult | null, args: any[]): boolean | Promise { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult | null, args: any[]): boolean | Promise { return false; } } @@ -500,12 +497,16 @@ export class PostDefendGulpMissileAbAttr extends PostDefendAbAttr { * @param {any[]} args - n/a * @returns Whether the effects of the ability are applied. */ - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean | Promise { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean | Promise { const battlerTag = pokemon.getTag(GulpMissileTag); if (!battlerTag || move.category === MoveCategory.STATUS || pokemon.getTag(SemiInvulnerableTag)) { return false; } + if (simulated) { + return true; + } + const cancelled = new Utils.BooleanHolder(false); applyAbAttrs(BlockNonDirectDamageAbAttr, attacker, cancelled); @@ -525,12 +526,12 @@ export class PostDefendGulpMissileAbAttr extends PostDefendAbAttr { } export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr { - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { const attackPriority = new Utils.IntegerHolder(move.priority); - applyMoveAttrs(IncrementMovePriorityAttr,attacker,null,move,attackPriority); - applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, move, attackPriority); + applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, attackPriority); + applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, simulated, move, attackPriority); - if (move.moveTarget===MoveTarget.USER || move.moveTarget===MoveTarget.NEAR_ALLY) { + if (move.moveTarget === MoveTarget.USER || move.moveTarget === MoveTarget.NEAR_ALLY) { return false; } @@ -544,7 +545,7 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr { } export class PostStatChangeAbAttr extends AbAttr { - applyPostStatChange(pokemon: Pokemon, statsChanged: BattleStat[], levelChanged: integer, selfTarget: boolean, args: any[]): boolean | Promise { + applyPostStatChange(pokemon: Pokemon, simulated: boolean, statsChanged: BattleStat[], levelChanged: integer, selfTarget: boolean, args: any[]): boolean | Promise { return false; } } @@ -558,7 +559,7 @@ export class MoveImmunityAbAttr extends PreDefendAbAttr { this.immuneCondition = immuneCondition; } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.immuneCondition(pokemon, attacker, move)) { cancelled.value = true; return true; @@ -579,7 +580,7 @@ export class MoveImmunityAbAttr extends PreDefendAbAttr { * @extends PreDefendAbAttr */ export class WonderSkinAbAttr extends PreDefendAbAttr { - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { const moveAccuracy = args[0] as Utils.NumberHolder; if (move.category === MoveCategory.STATUS && moveAccuracy.value >= 50) { moveAccuracy.value = 50; @@ -600,13 +601,10 @@ export class MoveImmunityStatChangeAbAttr extends MoveImmunityAbAttr { this.levels = levels; } - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { - const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args); - if (ret) { - const simulated = args.length > 1 && args[1]; - if (!simulated) { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); - } + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); + if (ret && !simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); } return ret; @@ -630,9 +628,11 @@ export class ReverseDrainAbAttr extends PostDefendAbAttr { * @args N/A * @returns true if healing should be reversed on a healing move, false otherwise. */ - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.hasAttr(HitHealAttr)) { - pokemon.scene.queueMessage(i18next.t("abilityTriggers:reverseDrain", { pokemonNameWithAffix: getPokemonNameWithAffix(attacker) })); + if (!simulated) { + pokemon.scene.queueMessage(i18next.t("abilityTriggers:reverseDrain", { pokemonNameWithAffix: getPokemonNameWithAffix(attacker) })); + } return true; } return false; @@ -656,8 +656,12 @@ export class PostDefendStatChangeAbAttr extends PostDefendAbAttr { this.allOthers = allOthers; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (this.condition(pokemon, attacker, move)) { + if (simulated) { + return true; + } + if (this.allOthers) { const otherPokemon = pokemon.getAlly() ? pokemon.getOpponents().concat([ pokemon.getAlly() ]) : pokemon.getOpponents(); for (const other of otherPokemon) { @@ -690,13 +694,15 @@ export class PostDefendHpGatedStatChangeAbAttr extends PostDefendAbAttr { this.selfTarget = selfTarget; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { const hpGateFlat: integer = Math.ceil(pokemon.getMaxHp() * this.hpGate); const lastAttackReceived = pokemon.turnData.attacksReceived[pokemon.turnData.attacksReceived.length - 1]; const damageReceived = lastAttackReceived?.damage || 0; if (this.condition(pokemon, attacker, move) && (pokemon.hp <= hpGateFlat && (pokemon.hp + damageReceived) > hpGateFlat)) { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (this.selfTarget ? pokemon : attacker).getBattlerIndex(), true, this.stats, this.levels)); + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (this.selfTarget ? pokemon : attacker).getBattlerIndex(), true, this.stats, this.levels)); + } return true; } @@ -715,11 +721,13 @@ export class PostDefendApplyArenaTrapTagAbAttr extends PostDefendAbAttr { this.tagType = tagType; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (this.condition(pokemon, attacker, move)) { const tag = pokemon.scene.arena.getTag(this.tagType) as ArenaTrapTag; if (!pokemon.scene.arena.getTag(this.tagType) || tag.layers < tag.maxLayers) { - pokemon.scene.arena.addTag(this.tagType, 0, undefined, pokemon.id, pokemon.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER); + if (!simulated) { + pokemon.scene.arena.addTag(this.tagType, 0, undefined, pokemon.id, pokemon.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER); + } return true; } } @@ -737,9 +745,9 @@ export class PostDefendApplyBattlerTagAbAttr extends PostDefendAbAttr { this.tagType = tagType; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (this.condition(pokemon, attacker, move)) { - if (!pokemon.getTag(this.tagType)) { + if (!pokemon.getTag(this.tagType) && !simulated) { pokemon.addTag(this.tagType, undefined, undefined, pokemon.id); pokemon.scene.queueMessage(i18next.t("abilityTriggers:windPowerCharged", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name })); } @@ -750,8 +758,11 @@ export class PostDefendApplyBattlerTagAbAttr extends PostDefendAbAttr { } export class PostDefendTypeChangeAbAttr extends PostDefendAbAttr { - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (hitResult < HitResult.NO_EFFECT) { + if (simulated) { + return true; + } const type = move.type; const pokemonTypes = pokemon.getTypes(true); if (pokemonTypes.length !== 1 || pokemonTypes[0] !== type) { @@ -781,9 +792,13 @@ export class PostDefendTerrainChangeAbAttr extends PostDefendAbAttr { this.terrainType = terrainType; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (hitResult < HitResult.NO_EFFECT) { - return pokemon.scene.arena.trySetTerrain(this.terrainType, true); + if (simulated) { + return pokemon.scene.arena.terrain?.terrainType !== (this.terrainType || undefined); + } else { + return pokemon.scene.arena.trySetTerrain(this.terrainType, true); + } } return false; @@ -801,10 +816,14 @@ export class PostDefendContactApplyStatusEffectAbAttr extends PostDefendAbAttr { this.effects = effects; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && !attacker.status && (this.chance === -1 || pokemon.randSeedInt(100) < this.chance)) { const effect = this.effects.length === 1 ? this.effects[0] : this.effects[pokemon.randSeedInt(this.effects.length)]; - return attacker.trySetStatus(effect, true, pokemon); + if (simulated) { + return attacker.canSetStatus(effect, true, false, pokemon); + } else { + return attacker.trySetStatus(effect, true, pokemon); + } } return false; @@ -816,11 +835,11 @@ export class EffectSporeAbAttr extends PostDefendContactApplyStatusEffectAbAttr super(10, StatusEffect.POISON, StatusEffect.PARALYSIS, StatusEffect.SLEEP); } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (attacker.hasAbility(Abilities.OVERCOAT) || attacker.isOfType(Type.GRASS)) { return false; } - return super.applyPostDefend(pokemon, passive, attacker, move, hitResult, args); + return super.applyPostDefend(pokemon, passive, simulated, attacker, move, hitResult, args); } } @@ -837,9 +856,13 @@ export class PostDefendContactApplyTagChanceAbAttr extends PostDefendAbAttr { this.turnCount = turnCount; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && pokemon.randSeedInt(100) < this.chance) { - return attacker.addTag(this.tagType, this.turnCount, move.id, attacker.id); + if (simulated) { + return attacker.canAddTag(this.tagType); + } else { + return attacker.addTag(this.tagType, this.turnCount, move.id, attacker.id); + } } return false; @@ -857,8 +880,10 @@ export class PostDefendCritStatChangeAbAttr extends PostDefendAbAttr { this.levels = levels; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); + } return true; } @@ -877,10 +902,10 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr { this.damageRatio = damageRatio; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { - if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && !attacker.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { - attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); - attacker.turnData.damageTaken += Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)); + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + if (!simulated && move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && !attacker.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { + attacker.damageAndUpdate(Utils.toDmgValue(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); + attacker.turnData.damageTaken += Utils.toDmgValue(attacker.getMaxHp() * (1 / this.damageRatio)); return true; } @@ -910,13 +935,15 @@ export class PostDefendPerishSongAbAttr extends PostDefendAbAttr { this.turns = turns; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { if (pokemon.getTag(BattlerTagType.PERISH_SONG) || attacker.getTag(BattlerTagType.PERISH_SONG)) { return false; } else { - attacker.addTag(BattlerTagType.PERISH_SONG, this.turns); - pokemon.addTag(BattlerTagType.PERISH_SONG, this.turns); + if (!simulated) { + attacker.addTag(BattlerTagType.PERISH_SONG, this.turns); + pokemon.addTag(BattlerTagType.PERISH_SONG, this.turns); + } return true; } } @@ -939,11 +966,14 @@ export class PostDefendWeatherChangeAbAttr extends PostDefendAbAttr { this.condition = condition ?? null; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (this.condition !== null && !this.condition(pokemon, attacker, move)) { return false; } if (!pokemon.scene.arena.weather?.isImmutable()) { + if (simulated) { + return pokemon.scene.arena.weather?.weatherType !== this.weatherType; + } return pokemon.scene.arena.trySetWeather(this.weatherType, true); } @@ -956,11 +986,13 @@ export class PostDefendAbilitySwapAbAttr extends PostDefendAbAttr { super(); } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && !attacker.getAbility().hasAttr(UnswappableAbilityAbAttr)) { - const tempAbilityId = attacker.getAbility().id; - attacker.summonData.ability = pokemon.getAbility().id; - pokemon.summonData.ability = tempAbilityId; + if (!simulated) { + const tempAbilityId = attacker.getAbility().id; + attacker.summonData.ability = pokemon.getAbility().id; + pokemon.summonData.ability = tempAbilityId; + } return true; } @@ -980,9 +1012,11 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr { this.ability = ability; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && !attacker.getAbility().hasAttr(UnsuppressableAbilityAbAttr) && !attacker.getAbility().hasAttr(PostDefendAbilityGiveAbAttr)) { - attacker.summonData.ability = this.ability; + if (!simulated) { + attacker.summonData.ability = this.ability; + } return true; } @@ -1009,9 +1043,13 @@ export class PostDefendMoveDisableAbAttr extends PostDefendAbAttr { this.chance = chance; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (!attacker.summonData.disabledMove) { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && (this.chance === -1 || pokemon.randSeedInt(100) < this.chance) && !attacker.isMax()) { + if (simulated) { + return true; + } + this.attacker = attacker; this.move = move; @@ -1044,9 +1082,11 @@ export class PostStatChangeStatChangeAbAttr extends PostStatChangeAbAttr { this.levels = levels; } - applyPostStatChange(pokemon: Pokemon, statsChanged: BattleStat[], levelsChanged: integer, selfTarget: boolean, args: any[]): boolean { + applyPostStatChange(pokemon: Pokemon, simulated: boolean, statsChanged: BattleStat[], levelsChanged: integer, selfTarget: boolean, args: any[]): boolean { if (this.condition(pokemon, statsChanged, levelsChanged) && !selfTarget) { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (pokemon).getBattlerIndex(), true, this.statsToChange, this.levels)); + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (pokemon).getBattlerIndex(), true, this.statsToChange, this.levels)); + } return true; } @@ -1055,7 +1095,7 @@ export class PostStatChangeStatChangeAbAttr extends PostStatChangeAbAttr { } export class PreAttackAbAttr extends AbAttr { - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon | null, move: Move, args: any[]): boolean | Promise { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon | null, move: Move, args: any[]): boolean | Promise { return false; } } @@ -1076,7 +1116,7 @@ export class MoveEffectChanceMultiplierAbAttr extends AbAttr { * @param args [0]: {@linkcode Utils.NumberHolder} Move additional effect chance. Has to be higher than or equal to 0. * [1]: {@linkcode Moves } Move used by the ability user. */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { // Disable showAbility during getTargetBenefitScore this.showAbility = args[4]; if ((args[0] as Utils.NumberHolder).value <= 0 || (args[1] as Move).id === Moves.ORDER_UP) { @@ -1099,7 +1139,7 @@ export class IgnoreMoveEffectsAbAttr extends PreDefendAbAttr { /** * @param args [0]: {@linkcode Utils.NumberHolder} Move additional effect chance. */ - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if ((args[0] as Utils.NumberHolder).value <= 0) { return false; @@ -1112,14 +1152,14 @@ export class IgnoreMoveEffectsAbAttr extends PreDefendAbAttr { } export class VariableMovePowerAbAttr extends PreAttackAbAttr { - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { //const power = args[0] as Utils.NumberHolder; return false; } } export class FieldPreventExplosiveMovesAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { cancelled.value = true; return true; } @@ -1156,7 +1196,7 @@ export class FieldMultiplyBattleStatAbAttr extends AbAttr { * @param args {any[]} unused * @returns true if this changed the checked stat, false otherwise. */ - applyFieldBattleStat(pokemon: Pokemon, passive: boolean, stat: Stat, statValue: Utils.NumberHolder, checkedPokemon: Pokemon, hasApplied: Utils.BooleanHolder, args: any[]): boolean { + applyFieldBattleStat(pokemon: Pokemon, passive: boolean, simulated: boolean, stat: Stat, statValue: Utils.NumberHolder, checkedPokemon: Pokemon, hasApplied: Utils.BooleanHolder, args: any[]): boolean { if (!this.canStack && hasApplied.value) { return false; } @@ -1180,7 +1220,7 @@ export class MoveTypeChangeAttr extends PreAttackAbAttr { super(true); } - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { if (this.condition && this.condition(pokemon, defender, move)) { move.type = this.newType; if (args[0] && args[0] instanceof Utils.NumberHolder) { @@ -1201,7 +1241,7 @@ export class PokemonTypeChangeAbAttr extends PreAttackAbAttr { super(true); } - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { if ( !pokemon.isTerastallized() && move.id !== Moves.STRUGGLE && @@ -1229,9 +1269,11 @@ export class PokemonTypeChangeAbAttr extends PreAttackAbAttr { } if (pokemon.getTypes().some((t) => t !== moveCopy.type)) { - this.moveType = moveCopy.type; - pokemon.summonData.types = [moveCopy.type]; - pokemon.updateInfo(); + if (!simulated) { + this.moveType = moveCopy.type; + pokemon.summonData.types = [moveCopy.type]; + pokemon.updateInfo(); + } return true; } @@ -1307,7 +1349,7 @@ export class AddSecondStrikeAbAttr extends PreAttackAbAttr { * @param {Utils.NumberHolder} args\[2\] the damage multiplier for the current strike * @returns */ - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { const numTargets = args[0] as integer; const hitCount = args[1] as Utils.IntegerHolder; const multiplier = args[2] as Utils.NumberHolder; @@ -1352,7 +1394,7 @@ export class DamageBoostAbAttr extends PreAttackAbAttr { * @param args Utils.NumberHolder as damage * @returns true if the function succeeds */ - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { if (this.condition(pokemon, defender, move)) { const power = args[0] as Utils.NumberHolder; power.value = Math.floor(power.value * this.damageMultiplier); @@ -1373,7 +1415,7 @@ export class MovePowerBoostAbAttr extends VariableMovePowerAbAttr { this.powerMultiplier = powerMultiplier; } - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { if (this.condition(pokemon, defender, move)) { (args[0] as Utils.NumberHolder).value *= this.powerMultiplier; @@ -1420,7 +1462,7 @@ export class VariableMovePowerBoostAbAttr extends VariableMovePowerAbAttr { /** * @override */ - applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move, args: any[]): boolean { const multiplier = this.mult(pokemon, defender, move); if (multiplier !== 1) { (args[0] as Utils.NumberHolder).value *= multiplier; @@ -1449,7 +1491,7 @@ export class FieldMovePowerBoostAbAttr extends AbAttr { this.powerMultiplier = powerMultiplier; } - applyPreAttack(pokemon: Pokemon | null, passive: boolean | null, defender: Pokemon | null, move: Move, args: any[]): boolean { + applyPreAttack(pokemon: Pokemon | null, passive: boolean | null, simulated: boolean, defender: Pokemon | null, move: Move, args: any[]): boolean { if (this.condition(pokemon, defender, move)) { (args[0] as Utils.NumberHolder).value *= this.powerMultiplier; @@ -1513,7 +1555,7 @@ export class BattleStatMultiplierAbAttr extends AbAttr { this.condition = condition ?? null; } - applyBattleStat(pokemon: Pokemon, passive: boolean, battleStat: BattleStat, statValue: Utils.NumberHolder, args: any[]): boolean | Promise { + applyBattleStat(pokemon: Pokemon, passive: boolean, simulated: boolean, battleStat: BattleStat, statValue: Utils.NumberHolder, args: any[]): boolean | Promise { const move = (args[0] as Move); if (battleStat === this.battleStat && (!this.condition || this.condition(pokemon, null, move))) { statValue.value *= this.multiplier; @@ -1539,11 +1581,11 @@ export class PostAttackAbAttr extends AbAttr { * applying the effect of any inherited class. This can be changed by providing a different {@link attackCondition} to the constructor. See {@link ConfusionOnStatusEffectAbAttr} * for an example of an effect that does not require a damaging move. */ - applyPostAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, hitResult: HitResult | null, args: any[]): boolean | Promise { + applyPostAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, hitResult: HitResult | null, args: any[]): boolean | Promise { // When attackRequired is true, we require the move to be an attack move and to deal damage before checking secondary requirements. // If attackRequired is false, we always defer to the secondary requirements. if (this.attackCondition(pokemon, defender, move)) { - return this.applyPostAttackAfterMoveTypeCheck(pokemon, passive, defender, move, hitResult, args); + return this.applyPostAttackAfterMoveTypeCheck(pokemon, passive, simulated, defender, move, hitResult, args); } else { return false; } @@ -1552,7 +1594,7 @@ export class PostAttackAbAttr extends AbAttr { /** * This method is only called after {@link applyPostAttack} has already been applied. Use this for handling checks specific to the ability in question. */ - applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, hitResult: HitResult | null, args: any[]): boolean | Promise { + applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, hitResult: HitResult | null, args: any[]): boolean | Promise { return false; } } @@ -1566,9 +1608,9 @@ export class PostAttackStealHeldItemAbAttr extends PostAttackAbAttr { this.stealCondition = stealCondition ?? null; } - applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise { + applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise { return new Promise(resolve => { - if (hitResult < HitResult.NO_EFFECT && (!this.stealCondition || this.stealCondition(pokemon, defender, move))) { + if (!simulated && hitResult < HitResult.NO_EFFECT && (!this.stealCondition || this.stealCondition(pokemon, defender, move))) { const heldItems = this.getTargetHeldItems(defender).filter(i => i.isTransferrable); if (heldItems.length) { const stolenItem = heldItems[pokemon.randSeedInt(heldItems.length)]; @@ -1581,7 +1623,7 @@ export class PostAttackStealHeldItemAbAttr extends PostAttackAbAttr { return; } } - resolve(false); + resolve(simulated); }); } @@ -1604,14 +1646,14 @@ export class PostAttackApplyStatusEffectAbAttr extends PostAttackAbAttr { this.effects = effects; } - applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { /**Status inflicted by abilities post attacking are also considered additional effects.*/ - if (!attacker.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && pokemon !== attacker && (!this.contactRequired || move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance && !pokemon.status) { + if (!attacker.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && !simulated && pokemon !== attacker && (!this.contactRequired || move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance && !pokemon.status) { const effect = this.effects.length === 1 ? this.effects[0] : this.effects[pokemon.randSeedInt(this.effects.length)]; return attacker.trySetStatus(effect, true, pokemon); } - return false; + return simulated; } } @@ -1635,11 +1677,11 @@ export class PostAttackApplyBattlerTagAbAttr extends PostAttackAbAttr { this.effects = effects; } - applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { /**Battler tags inflicted by abilities post attacking are also considered additional effects.*/ if (!attacker.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && pokemon !== attacker && (!this.contactRequired || move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance(attacker, pokemon, move) && !pokemon.status) { const effect = this.effects.length === 1 ? this.effects[0] : this.effects[pokemon.randSeedInt(this.effects.length)]; - return attacker.addTag(effect); + return simulated || attacker.addTag(effect); } return false; @@ -1655,9 +1697,9 @@ export class PostDefendStealHeldItemAbAttr extends PostDefendAbAttr { this.condition = condition ?? null; } - applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise { + applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise { return new Promise(resolve => { - if (hitResult < HitResult.NO_EFFECT && (!this.condition || this.condition(pokemon, attacker, move))) { + if (!simulated && hitResult < HitResult.NO_EFFECT && (!this.condition || this.condition(pokemon, attacker, move))) { const heldItems = this.getTargetHeldItems(attacker).filter(i => i.isTransferrable); if (heldItems.length) { const stolenItem = heldItems[pokemon.randSeedInt(heldItems.length)]; @@ -1670,7 +1712,7 @@ export class PostDefendStealHeldItemAbAttr extends PostDefendAbAttr { return; } } - resolve(false); + resolve(simulated); }); } @@ -1681,7 +1723,7 @@ export class PostDefendStealHeldItemAbAttr extends PostDefendAbAttr { } export class PostVictoryAbAttr extends AbAttr { - applyPostVictory(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostVictory(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { return false; } } @@ -1697,12 +1739,13 @@ class PostVictoryStatChangeAbAttr extends PostVictoryAbAttr { this.levels = levels; } - applyPostVictory(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostVictory(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { const stat = typeof this.stat === "function" ? this.stat(pokemon) : this.stat; - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], this.levels)); - + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], this.levels)); + } return true; } } @@ -1716,10 +1759,12 @@ export class PostVictoryFormChangeAbAttr extends PostVictoryAbAttr { this.formFunc = formFunc; } - applyPostVictory(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostVictory(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { const formIndex = this.formFunc(pokemon); if (formIndex !== pokemon.formIndex) { - pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + if (!simulated) { + pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + } return true; } @@ -1728,7 +1773,7 @@ export class PostVictoryFormChangeAbAttr extends PostVictoryAbAttr { } export class PostKnockOutAbAttr extends AbAttr { - applyPostKnockOut(pokemon: Pokemon, passive: boolean, knockedOut: Pokemon, args: any[]): boolean | Promise { + applyPostKnockOut(pokemon: Pokemon, passive: boolean, simulated: boolean, knockedOut: Pokemon, args: any[]): boolean | Promise { return false; } } @@ -1744,12 +1789,13 @@ export class PostKnockOutStatChangeAbAttr extends PostKnockOutAbAttr { this.levels = levels; } - applyPostKnockOut(pokemon: Pokemon, passive: boolean, knockedOut: Pokemon, args: any[]): boolean | Promise { + applyPostKnockOut(pokemon: Pokemon, passive: boolean, simulated: boolean, knockedOut: Pokemon, args: any[]): boolean | Promise { const stat = typeof this.stat === "function" ? this.stat(pokemon) : this.stat; - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], this.levels)); - + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], this.levels)); + } return true; } } @@ -1759,10 +1805,12 @@ export class CopyFaintedAllyAbilityAbAttr extends PostKnockOutAbAttr { super(); } - applyPostKnockOut(pokemon: Pokemon, passive: boolean, knockedOut: Pokemon, args: any[]): boolean | Promise { + applyPostKnockOut(pokemon: Pokemon, passive: boolean, simulated: boolean, knockedOut: Pokemon, args: any[]): boolean | Promise { if (pokemon.isPlayer() === knockedOut.isPlayer() && !knockedOut.getAbility().hasAttr(UncopiableAbilityAbAttr)) { - pokemon.summonData.ability = knockedOut.getAbility().id; - pokemon.scene.queueMessage(i18next.t("abilityTriggers:copyFaintedAllyAbility", { pokemonNameWithAffix: getPokemonNameWithAffix(knockedOut), abilityName: allAbilities[knockedOut.getAbility().id].name })); + if (!simulated) { + pokemon.summonData.ability = knockedOut.getAbility().id; + pokemon.scene.queueMessage(i18next.t("abilityTriggers:copyFaintedAllyAbility", { pokemonNameWithAffix: getPokemonNameWithAffix(knockedOut), abilityName: allAbilities[knockedOut.getAbility().id].name })); + } return true; } @@ -1775,7 +1823,7 @@ export class IgnoreOpponentStatChangesAbAttr extends AbAttr { super(false); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]) { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]) { (args[0] as Utils.IntegerHolder).value = 0; return true; @@ -1798,7 +1846,7 @@ export class IgnoreOpponentEvasionAbAttr extends AbAttr { * @param args [0] {@linkcode Utils.IntegerHolder} of BattleStat.EVA * @returns if evasion level was successfully considered as 0 */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]) { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]) { (args[0] as Utils.IntegerHolder).value = 0; return true; } @@ -1809,7 +1857,7 @@ export class IntimidateImmunityAbAttr extends AbAttr { super(false); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; } @@ -1834,8 +1882,10 @@ export class PostIntimidateStatChangeAbAttr extends AbAttr { this.overwrites = !!overwrites; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, this.levels)); + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (!simulated) { + pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, this.levels)); + } cancelled.value = this.overwrites; return true; } @@ -1853,7 +1903,7 @@ export class PostSummonAbAttr extends AbAttr { * @param args Set of unique arguments needed by this attribute * @returns true if application of the ability succeeds */ - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { return false; } } @@ -1872,9 +1922,11 @@ export class PostSummonRemoveArenaTagAbAttr extends PostSummonAbAttr { this.arenaTags = arenaTags; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { - for (const arenaTag of this.arenaTags) { - pokemon.scene.arena.removeTag(arenaTag); + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { + if (!simulated) { + for (const arenaTag of this.arenaTags) { + pokemon.scene.arena.removeTag(arenaTag); + } } return true; } @@ -1889,8 +1941,10 @@ export class PostSummonMessageAbAttr extends PostSummonAbAttr { this.messageFunc = messageFunc; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - pokemon.scene.queueMessage(this.messageFunc(pokemon)); + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (!simulated) { + pokemon.scene.queueMessage(this.messageFunc(pokemon)); + } return true; } @@ -1906,8 +1960,10 @@ export class PostSummonUnnamedMessageAbAttr extends PostSummonAbAttr { this.message = message; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - pokemon.scene.queueMessage(this.message); + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (!simulated) { + pokemon.scene.queueMessage(this.message); + } return true; } @@ -1924,8 +1980,12 @@ export class PostSummonAddBattlerTagAbAttr extends PostSummonAbAttr { this.turnCount = turnCount; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - return pokemon.addTag(this.tagType, this.turnCount); + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (simulated) { + return pokemon.canAddTag(this.tagType); + } else { + return pokemon.addTag(this.tagType, this.turnCount); + } } } @@ -1946,7 +2006,11 @@ export class PostSummonStatChangeAbAttr extends PostSummonAbAttr { this.intimidate = !!intimidate; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (simulated) { + return true; + } + queueShowAbility(pokemon, passive); // TODO: Better solution than manually showing the ability here if (this.selfTarget) { // we unshift the StatChangePhase to put it right after the showAbility and not at the end of the @@ -1957,8 +2021,8 @@ export class PostSummonStatChangeAbAttr extends PostSummonAbAttr { for (const opponent of pokemon.getOpponents()) { const cancelled = new Utils.BooleanHolder(false); if (this.intimidate) { - applyAbAttrs(IntimidateImmunityAbAttr, opponent, cancelled); - applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled); + applyAbAttrs(IntimidateImmunityAbAttr, opponent, cancelled, simulated); + applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled, simulated); } if (!cancelled.value) { const statChangePhase = new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels); @@ -1980,11 +2044,14 @@ export class PostSummonAllyHealAbAttr extends PostSummonAbAttr { this.showAnim = showAnim; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const target = pokemon.getAlly(); if (target?.isActive(true)) { - target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / this.healRatio), 1), i18next.t("abilityTriggers:postSummonAllyHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(target), pokemonName: pokemon.name }), true, !this.showAnim)); + if (!simulated) { + target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), + Utils.toDmgValue(pokemon.getMaxHp() / this.healRatio), i18next.t("abilityTriggers:postSummonAllyHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(target), pokemonName: pokemon.name }), true, !this.showAnim)); + } + return true; } @@ -2005,14 +2072,16 @@ export class PostSummonClearAllyStatsAbAttr extends PostSummonAbAttr { super(); } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const target = pokemon.getAlly(); if (target?.isActive(true)) { - for (let s = 0; s < target.summonData.battleStats.length; s++) { - target.summonData.battleStats[s] = 0; - } + if (!simulated) { + for (let s = 0; s < target.summonData.battleStats.length; s++) { + target.summonData.battleStats[s] = 0; + } - target.scene.queueMessage(i18next.t("abilityTriggers:postSummonClearAllyStats", { pokemonNameWithAffix: getPokemonNameWithAffix(target) })); + target.scene.queueMessage(i18next.t("abilityTriggers:postSummonClearAllyStats", { pokemonNameWithAffix: getPokemonNameWithAffix(target) })); + } return true; } @@ -2043,7 +2112,7 @@ export class DownloadAbAttr extends PostSummonAbAttr { * @param {any[]} args N/A * @returns Returns true if ability is used successful, false if not. */ - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { this.enemyDef = 0; this.enemySpDef = 0; this.enemyCountTally = 0; @@ -2063,7 +2132,9 @@ export class DownloadAbAttr extends PostSummonAbAttr { } if (this.enemyDef > 0 && this.enemySpDef > 0) { // only activate if there's actually an enemy to download from - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, 1)); + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, 1)); + } return true; } @@ -2080,11 +2151,15 @@ export class PostSummonWeatherChangeAbAttr extends PostSummonAbAttr { this.weatherType = weatherType; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { if ((this.weatherType === WeatherType.HEAVY_RAIN || this.weatherType === WeatherType.HARSH_SUN || this.weatherType === WeatherType.STRONG_WINDS) || !pokemon.scene.arena.weather?.isImmutable()) { - return pokemon.scene.arena.trySetWeather(this.weatherType, true); + if (simulated) { + return pokemon.scene.arena.weather?.weatherType !== this.weatherType; + } else { + return pokemon.scene.arena.trySetWeather(this.weatherType, true); + } } return false; @@ -2100,8 +2175,12 @@ export class PostSummonTerrainChangeAbAttr extends PostSummonAbAttr { this.terrainType = terrainType; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - return pokemon.scene.arena.trySetTerrain(this.terrainType, true); + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (simulated) { + return pokemon.scene.arena.terrain?.terrainType !== this.terrainType; + } else { + return pokemon.scene.arena.trySetTerrain(this.terrainType, true); + } } } @@ -2114,10 +2193,10 @@ export class PostSummonFormChangeAbAttr extends PostSummonAbAttr { this.formFunc = formFunc; } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const formIndex = this.formFunc(pokemon); if (formIndex !== pokemon.formIndex) { - return pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + return simulated || pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); } return false; @@ -2129,7 +2208,7 @@ export class PostSummonCopyAbilityAbAttr extends PostSummonAbAttr { private target: Pokemon; private targetAbilityName: string; - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const targets = pokemon.getOpponents(); if (!targets.length) { return false; @@ -2150,11 +2229,13 @@ export class PostSummonCopyAbilityAbAttr extends PostSummonAbAttr { return false; } - this.target = target!; - this.targetAbilityName = allAbilities[target!.getAbility().id].name; - pokemon.summonData.ability = target!.getAbility().id; - setAbilityRevealed(target!); - pokemon.updateInfo(); + if (!simulated) { + this.target = target!; + this.targetAbilityName = allAbilities[target!.getAbility().id].name; + pokemon.summonData.ability = target!.getAbility().id; + setAbilityRevealed(target!); + pokemon.updateInfo(); + } return true; } @@ -2191,7 +2272,7 @@ export class PostSummonUserFieldRemoveStatusEffectAbAttr extends PostSummonAbAtt * @param args - n/a * @returns A boolean or a promise that resolves to a boolean indicating the result of the ability application. */ - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { const party = pokemon instanceof PlayerPokemon ? pokemon.scene.getPlayerField() : pokemon.scene.getEnemyField(); const allowedParty = party.filter(p => p.isAllowedInBattle()); @@ -2199,14 +2280,15 @@ export class PostSummonUserFieldRemoveStatusEffectAbAttr extends PostSummonAbAtt return false; } - for (const pokemon of allowedParty) { - if (pokemon.status && this.statusEffect.includes(pokemon.status.effect)) { - pokemon.scene.queueMessage(getStatusEffectHealText(pokemon.status.effect, getPokemonNameWithAffix(pokemon))); - pokemon.resetStatus(false); - pokemon.updateInfo(); + if (!simulated) { + for (const pokemon of allowedParty) { + if (pokemon.status && this.statusEffect.includes(pokemon.status.effect)) { + pokemon.scene.queueMessage(getStatusEffectHealText(pokemon.status.effect, getPokemonNameWithAffix(pokemon))); + pokemon.resetStatus(false); + pokemon.updateInfo(); + } } } - return true; } } @@ -2214,7 +2296,7 @@ export class PostSummonUserFieldRemoveStatusEffectAbAttr extends PostSummonAbAtt /** Attempt to copy the stat changes on an ally pokemon */ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr { - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { if (!pokemon.scene.currentBattle.double) { return false; } @@ -2224,8 +2306,10 @@ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr { return false; } - pokemon.summonData.battleStats = ally.summonData.battleStats; - pokemon.updateInfo(); + if (!simulated) { + pokemon.summonData.battleStats = ally.summonData.battleStats; + pokemon.updateInfo(); + } return true; } @@ -2243,10 +2327,10 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { super(true); } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const targets = pokemon.getOpponents(); - if (!targets.length) { - return false; + if (simulated || !targets.length) { + return simulated; } let target: Pokemon; @@ -2282,16 +2366,19 @@ export class PreSwitchOutAbAttr extends AbAttr { super(true); } - applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { return false; } } export class PreSwitchOutResetStatusAbAttr extends PreSwitchOutAbAttr { - applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { if (pokemon.status) { - pokemon.resetStatus(); - pokemon.updateInfo(); + if (!simulated) { + pokemon.resetStatus(); + pokemon.updateInfo(); + } + return true; } @@ -2310,7 +2397,7 @@ export class PreSwitchOutClearWeatherAbAttr extends PreSwitchOutAbAttr { * @param args N/A * @returns {boolean} Returns true if the weather clears, otherwise false. */ - applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { const weatherType = pokemon.scene.arena.weather?.weatherType; let turnOffWeather = false; @@ -2336,6 +2423,10 @@ export class PreSwitchOutClearWeatherAbAttr extends PreSwitchOutAbAttr { break; } + if (simulated) { + return turnOffWeather; + } + if (turnOffWeather) { pokemon.scene.arena.trySetWeather(WeatherType.NONE, false); return true; @@ -2346,11 +2437,14 @@ export class PreSwitchOutClearWeatherAbAttr extends PreSwitchOutAbAttr { } export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr { - applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { if (!pokemon.isFullHp()) { - const healAmount = Math.floor(pokemon.getMaxHp() * 0.33); - pokemon.heal(healAmount); - pokemon.updateInfo(); + if (!simulated) { + const healAmount = Utils.toDmgValue(pokemon.getMaxHp() * 0.33); + pokemon.heal(healAmount); + pokemon.updateInfo(); + } + return true; } @@ -2379,10 +2473,12 @@ export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr { * @param args N/A * @returns true if the form change was successful */ - applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { const formIndex = this.formFunc(pokemon); if (formIndex !== pokemon.formIndex) { - pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + if (!simulated) { + pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + } return true; } @@ -2392,7 +2488,7 @@ export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr { } export class PreStatChangeAbAttr extends AbAttr { - applyPreStatChange(pokemon: Pokemon | null, passive: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { + applyPreStatChange(pokemon: Pokemon | null, passive: boolean, simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; } } @@ -2406,7 +2502,7 @@ export class ProtectStatAbAttr extends PreStatChangeAbAttr { this.protectedStat = protectedStat; } - applyPreStatChange(pokemon: Pokemon, passive: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreStatChange(pokemon: Pokemon, passive: boolean, simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (Utils.isNullOrUndefined(this.protectedStat) || stat === this.protectedStat) { cancelled.value = true; return true; @@ -2450,16 +2546,20 @@ export class ConfusionOnStatusEffectAbAttr extends PostAttackAbAttr { * @param args [0] {@linkcode StatusEffect} applied by move * @returns true if defender is confused */ - applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostAttackAfterMoveTypeCheck(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (this.effects.indexOf(args[0]) > -1 && !defender.isFainted()) { - return defender.addTag(BattlerTagType.CONFUSED, pokemon.randSeedInt(3,2), move.id, defender.id); + if (simulated) { + return defender.canAddTag(BattlerTagType.CONFUSED); + } else { + return defender.addTag(BattlerTagType.CONFUSED, pokemon.randSeedInt(3,2), move.id, defender.id); + } } return false; } } export class PreSetStatusAbAttr extends AbAttr { - applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect | undefined, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { + applyPreSetStatus(pokemon: Pokemon, passive: boolean, simulated: boolean, effect: StatusEffect | undefined, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; } } @@ -2489,7 +2589,7 @@ export class PreSetStatusEffectImmunityAbAttr extends PreSetStatusAbAttr { * @param args - n/a * @returns A boolean indicating the result of the status application. */ - applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreSetStatus(pokemon: Pokemon, passive: boolean, simulated: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.immuneEffects.length < 1 || this.immuneEffects.includes(effect)) { cancelled.value = true; return true; @@ -2525,7 +2625,7 @@ export class StatusEffectImmunityAbAttr extends PreSetStatusEffectImmunityAbAttr export class UserFieldStatusEffectImmunityAbAttr extends PreSetStatusEffectImmunityAbAttr { } export class PreApplyBattlerTagAbAttr extends AbAttr { - applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { + applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, simulated: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; } } @@ -2543,10 +2643,12 @@ export class PreApplyBattlerTagImmunityAbAttr extends PreApplyBattlerTagAbAttr { this.immuneTagType = immuneTagType; } - applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, simulated: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (tag.tagType === this.immuneTagType) { cancelled.value = true; - this.battlerTag = tag; + if (!simulated) { + this.battlerTag = tag; + } return true; } @@ -2575,14 +2677,14 @@ export class BattlerTagImmunityAbAttr extends PreApplyBattlerTagImmunityAbAttr { export class UserFieldBattlerTagImmunityAbAttr extends PreApplyBattlerTagImmunityAbAttr { } export class BlockCritAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.BooleanHolder).value = true; return true; } } export class BonusCritAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.BooleanHolder).value = true; return true; } @@ -2597,7 +2699,7 @@ export class MultCritAbAttr extends AbAttr { this.multAmount = multAmount; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const critMult = args[0] as Utils.NumberHolder; if (critMult.value > 1) { critMult.value *= this.multAmount; @@ -2628,7 +2730,7 @@ export class ConditionalCritAbAttr extends AbAttr { * [1] {@linkcode Pokemon} Target. * [2] {@linkcode Move} used by ability user. */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const target = (args[1] as Pokemon); const move = (args[2] as Move); if (!this.condition(pokemon,target,move)) { @@ -2641,7 +2743,7 @@ export class ConditionalCritAbAttr extends AbAttr { } export class BlockNonDirectDamageAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; } @@ -2669,7 +2771,7 @@ export class BlockStatusDamageAbAttr extends AbAttr { * @param {any[]} args N/A * @returns Returns true if status damage is blocked */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (pokemon.status && this.effects.includes(pokemon.status.effect)) { cancelled.value = true; return true; @@ -2679,7 +2781,7 @@ export class BlockStatusDamageAbAttr extends AbAttr { } export class BlockOneHitKOAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; } @@ -2705,7 +2807,7 @@ export class ChangeMovePriorityAbAttr extends AbAttr { this.changeAmount = changeAmount; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (!this.moveFunc(pokemon, args[0] as Move)) { return false; } @@ -2718,7 +2820,7 @@ export class ChangeMovePriorityAbAttr extends AbAttr { export class IgnoreContactAbAttr extends AbAttr { } export class PreWeatherEffectAbAttr extends AbAttr { - applyPreWeatherEffect(pokemon: Pokemon, passive: boolean, weather: Weather | null, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { + applyPreWeatherEffect(pokemon: Pokemon, passive: Boolean, simulated: boolean, weather: Weather | null, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; } } @@ -2734,7 +2836,7 @@ export class BlockWeatherDamageAttr extends PreWeatherDamageAbAttr { this.weatherTypes = weatherTypes; } - applyPreWeatherEffect(pokemon: Pokemon, passive: boolean, weather: Weather, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreWeatherEffect(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: Weather, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (!this.weatherTypes.length || this.weatherTypes.indexOf(weather?.weatherType) > -1) { cancelled.value = true; } @@ -2752,7 +2854,7 @@ export class SuppressWeatherEffectAbAttr extends PreWeatherEffectAbAttr { this.affectsImmutable = !!affectsImmutable; } - applyPreWeatherEffect(pokemon: Pokemon, passive: boolean, weather: Weather, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreWeatherEffect(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: Weather, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.affectsImmutable || weather.isImmutable()) { cancelled.value = true; return true; @@ -2859,7 +2961,7 @@ export class ForewarnAbAttr extends PostSummonAbAttr { super(true); } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { let maxPowerSeen = 0; let maxMove = ""; let movePower = 0; @@ -2883,7 +2985,9 @@ export class ForewarnAbAttr extends PostSummonAbAttr { } } } - pokemon.scene.queueMessage(i18next.t("abilityTriggers:forewarn", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: maxMove })); + if (!simulated) { + pokemon.scene.queueMessage(i18next.t("abilityTriggers:forewarn", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: maxMove })); + } return true; } } @@ -2893,17 +2997,19 @@ export class FriskAbAttr extends PostSummonAbAttr { super(true); } - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - for (const opponent of pokemon.getOpponents()) { - pokemon.scene.queueMessage(i18next.t("abilityTriggers:frisk", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), opponentName: opponent.name, opponentAbilityName: opponent.getAbility().name })); - setAbilityRevealed(opponent); + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (!simulated) { + for (const opponent of pokemon.getOpponents()) { + pokemon.scene.queueMessage(i18next.t("abilityTriggers:frisk", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), opponentName: opponent.name, opponentAbilityName: opponent.getAbility().name })); + setAbilityRevealed(opponent); + } } return true; } } export class PostWeatherChangeAbAttr extends AbAttr { - applyPostWeatherChange(pokemon: Pokemon, passive: boolean, weather: WeatherType, args: any[]): boolean { + applyPostWeatherChange(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: WeatherType, args: any[]): boolean { return false; } } @@ -2921,13 +3027,17 @@ export class PostWeatherChangeAddBattlerTagAttr extends PostWeatherChangeAbAttr this.weatherTypes = weatherTypes; } - applyPostWeatherChange(pokemon: Pokemon, passive: boolean, weather: WeatherType, args: any[]): boolean { + applyPostWeatherChange(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: WeatherType, args: any[]): boolean { console.log(this.weatherTypes.find(w => weather === w), WeatherType[weather]); if (!this.weatherTypes.find(w => weather === w)) { return false; } - return pokemon.addTag(this.tagType, this.turnCount); + if (simulated) { + return pokemon.canAddTag(this.tagType); + } else { + return pokemon.addTag(this.tagType, this.turnCount); + } } } @@ -2940,7 +3050,7 @@ export class PostWeatherLapseAbAttr extends AbAttr { this.weatherTypes = weatherTypes; } - applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, weather: Weather | null, args: any[]): boolean | Promise { + applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: Weather | null, args: any[]): boolean | Promise { return false; } @@ -2958,12 +3068,14 @@ export class PostWeatherLapseHealAbAttr extends PostWeatherLapseAbAttr { this.healFactor = healFactor; } - applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, weather: Weather, args: any[]): boolean { + applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: Weather, args: any[]): boolean { if (!pokemon.isFullHp()) { const scene = pokemon.scene; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; - scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / (16 / this.healFactor)), 1), i18next.t("abilityTriggers:postWeatherLapseHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true)); + if (!simulated) { + scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), + Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.healFactor)), i18next.t("abilityTriggers:postWeatherLapseHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true)); + } return true; } @@ -2980,20 +3092,24 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr { this.damageFactor = damageFactor; } - applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, weather: Weather, args: any[]): boolean { + applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, simulated: boolean, weather: Weather, args: any[]): boolean { const scene = pokemon.scene; if (pokemon.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { return false; } - const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; - scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName })); - pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER); + + if (!simulated) { + const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; + scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName })); + pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER); + } + return true; } } export class PostTerrainChangeAbAttr extends AbAttr { - applyPostTerrainChange(pokemon: Pokemon, passive: boolean, terrain: TerrainType, args: any[]): boolean { + applyPostTerrainChange(pokemon: Pokemon, passive: boolean, simulated: boolean, terrain: TerrainType, args: any[]): boolean { return false; } } @@ -3011,12 +3127,16 @@ export class PostTerrainChangeAddBattlerTagAttr extends PostTerrainChangeAbAttr this.terrainTypes = terrainTypes; } - applyPostTerrainChange(pokemon: Pokemon, passive: boolean, terrain: TerrainType, args: any[]): boolean { + applyPostTerrainChange(pokemon: Pokemon, passive: boolean, simulated: boolean, terrain: TerrainType, args: any[]): boolean { if (!this.terrainTypes.find(t => t === terrain)) { return false; } - return pokemon.addTag(this.tagType, this.turnCount); + if (simulated) { + return pokemon.canAddTag(this.tagType); + } else { + return pokemon.addTag(this.tagType, this.turnCount); + } } } @@ -3028,7 +3148,7 @@ function getTerrainCondition(...terrainTypes: TerrainType[]): AbAttrCondition { } export class PostTurnAbAttr extends AbAttr { - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { return false; } } @@ -3054,13 +3174,15 @@ export class PostTurnStatusHealAbAttr extends PostTurnAbAttr { * @param {any[]} args N/A * @returns Returns true if healed from status, false if not */ - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { if (pokemon.status && this.effects.includes(pokemon.status.effect)) { if (!pokemon.isFullHp()) { - const scene = pokemon.scene; - const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; - scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / 8), 1), i18next.t("abilityTriggers:poisonHeal", { pokemonName: getPokemonNameWithAffix(pokemon), abilityName }), true)); + if (!simulated) { + const scene = pokemon.scene; + const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; + scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), + Utils.toDmgValue(pokemon.getMaxHp() / 8), i18next.t("abilityTriggers:poisonHeal", { pokemonName: getPokemonNameWithAffix(pokemon), abilityName }), true)); + } return true; } } @@ -3081,17 +3203,19 @@ export class PostTurnResetStatusAbAttr extends PostTurnAbAttr { this.allyTarget = allyTarget; } - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { if (this.allyTarget) { this.target = pokemon.getAlly(); } else { this.target = pokemon; } if (this.target?.status) { + if (!simulated) { + this.target.scene.queueMessage(getStatusEffectHealText(this.target.status?.effect, getPokemonNameWithAffix(this.target))); + this.target.resetStatus(false); + this.target.updateInfo(); + } - this.target.scene.queueMessage(getStatusEffectHealText(this.target.status?.effect, getPokemonNameWithAffix(this.target))); - this.target.resetStatus(false); - this.target.updateInfo(); return true; } @@ -3116,7 +3240,7 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr { super(); } - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const pass = Phaser.Math.RND.realInRange(0, 1); // Clamp procChance to [0, 1]. Skip if didn't proc (less than pass) if (Math.max(Math.min(this.procChance(pokemon), 1), 0) < pass) { @@ -3124,7 +3248,7 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr { } if (this.itemType === "EATEN_BERRIES") { - return this.createEatenBerry(pokemon); + return this.createEatenBerry(pokemon, simulated); } else { return false; } @@ -3133,15 +3257,20 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr { /** * Create a new berry chosen randomly from the berries the pokemon ate this battle * @param pokemon The pokemon with this ability + * @param simulated whether the associated ability call is simulated * @returns whether a new berry was created */ - createEatenBerry(pokemon: Pokemon): boolean { + createEatenBerry(pokemon: Pokemon, simulated: boolean): boolean { const berriesEaten = pokemon.battleData.berriesEaten; if (!berriesEaten.length) { return false; } + if (simulated) { + return true; + } + const randomIdx = Utils.randSeedInt(berriesEaten.length); const chosenBerryType = berriesEaten[randomIdx]; const chosenBerry = new BerryModifierType(chosenBerryType); @@ -3175,17 +3304,17 @@ export class MoodyAbAttr extends PostTurnAbAttr { super(true); } - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const selectableStats = [BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD]; const increaseStatArray = selectableStats.filter(s => pokemon.summonData.battleStats[s] < 6); let decreaseStatArray = selectableStats.filter(s => pokemon.summonData.battleStats[s] > -6); - if (increaseStatArray.length > 0) { + if (!simulated && increaseStatArray.length > 0) { const increaseStat = increaseStatArray[Utils.randInt(increaseStatArray.length)]; decreaseStatArray = decreaseStatArray.filter(s => s !== increaseStat); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [increaseStat], 2)); } - if (decreaseStatArray.length > 0) { + if (!simulated && decreaseStatArray.length > 0) { const decreaseStat = selectableStats[Utils.randInt(selectableStats.length)]; pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [decreaseStat], -1)); } @@ -3206,19 +3335,24 @@ export class PostTurnStatChangeAbAttr extends PostTurnAbAttr { this.levels = levels; } - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); + } return true; } } export class PostTurnHealAbAttr extends PostTurnAbAttr { - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { if (!pokemon.isFullHp()) { - const scene = pokemon.scene; - const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; - scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / 16), 1), i18next.t("abilityTriggers:postTurnHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true)); + if (!simulated) { + const scene = pokemon.scene; + const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; + scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), + Utils.toDmgValue(pokemon.getMaxHp() / 16), i18next.t("abilityTriggers:postTurnHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true)); + } + return true; } @@ -3235,10 +3369,13 @@ export class PostTurnFormChangeAbAttr extends PostTurnAbAttr { this.formFunc = formFunc; } - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const formIndex = this.formFunc(pokemon); if (formIndex !== pokemon.formIndex) { - pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + if (!simulated) { + pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + } + return true; } @@ -3256,15 +3393,18 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr { * Deals damage to all sleeping opponents equal to 1/8 of their max hp (min 1) * @param {Pokemon} pokemon Pokemon that has this ability * @param {boolean} passive N/A + * @param {boolean} simulated true if applying in a simulated call. * @param {any[]} args N/A * @returns {boolean} true if any opponents are sleeping */ - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise { let hadEffect: boolean = false; for (const opp of pokemon.getOpponents()) { if ((opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) && !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { - opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER); - pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: getPokemonNameWithAffix(opp)})); + if (!simulated) { + opp.damageAndUpdate(Utils.toDmgValue(opp.getMaxHp() / 8), HitResult.OTHER); + pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: getPokemonNameWithAffix(opp)})); + } hadEffect = true; } @@ -3289,7 +3429,10 @@ export class FetchBallAbAttr extends PostTurnAbAttr { * @param args N/A * @returns true if player has used a pokeball and this pokemon is owned by the player */ - applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (simulated) { + return false; + } const lastUsed = pokemon.scene.currentBattle.lastUsedPokeball; if (lastUsed !== null && !!pokemon.isPlayer) { pokemon.scene.pokeballCounts[lastUsed]++; @@ -3312,9 +3455,13 @@ export class PostBiomeChangeWeatherChangeAbAttr extends PostBiomeChangeAbAttr { this.weatherType = weatherType; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (!pokemon.scene.arena.weather?.isImmutable()) { - return pokemon.scene.arena.trySetWeather(this.weatherType, true); + if (simulated) { + return pokemon.scene.arena.weather?.weatherType !== this.weatherType; + } else { + return pokemon.scene.arena.trySetWeather(this.weatherType, true); + } } return false; @@ -3330,8 +3477,12 @@ export class PostBiomeChangeTerrainChangeAbAttr extends PostBiomeChangeAbAttr { this.terrainType = terrainType; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - return pokemon.scene.arena.trySetTerrain(this.terrainType, true); + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (simulated) { + return pokemon.scene.arena.terrain?.terrainType !== this.terrainType; + } else { + return pokemon.scene.arena.trySetTerrain(this.terrainType, true); + } } } @@ -3340,7 +3491,7 @@ export class PostBiomeChangeTerrainChangeAbAttr extends PostBiomeChangeAbAttr { * @extends AbAttr */ export class PostMoveUsedAbAttr extends AbAttr { - applyPostMoveUsed(pokemon: Pokemon, move: PokemonMove, source: Pokemon, targets: BattlerIndex[], args: any[]): boolean | Promise { + applyPostMoveUsed(pokemon: Pokemon, move: PokemonMove, source: Pokemon, targets: BattlerIndex[], simulated: boolean, args: any[]): boolean | Promise { return false; } } @@ -3361,20 +3512,22 @@ export class PostDancingMoveAbAttr extends PostMoveUsedAbAttr { * * @return true if the Dancer ability was resolved */ - applyPostMoveUsed(dancer: Pokemon, move: PokemonMove, source: Pokemon, targets: BattlerIndex[], args: any[]): boolean | Promise { + applyPostMoveUsed(dancer: Pokemon, move: PokemonMove, source: Pokemon, targets: BattlerIndex[], simulated: boolean, args: any[]): boolean | Promise { // List of tags that prevent the Dancer from replicating the move const forbiddenTags = [BattlerTagType.FLYING, BattlerTagType.UNDERWATER, BattlerTagType.UNDERGROUND, BattlerTagType.HIDDEN]; // The move to replicate cannot come from the Dancer if (source.getBattlerIndex() !== dancer.getBattlerIndex() && !dancer.summonData.tags.some(tag => forbiddenTags.includes(tag.tagType))) { - // If the move is an AttackMove or a StatusMove the Dancer must replicate the move on the source of the Dance - if (move.getMove() instanceof AttackMove || move.getMove() instanceof StatusMove) { - const target = this.getTarget(dancer, source, targets); - dancer.scene.unshiftPhase(new MovePhase(dancer.scene, dancer, target, move, true)); - } else if (move.getMove() instanceof SelfStatusMove) { - // If the move is a SelfStatusMove (ie. Swords Dance) the Dancer should replicate it on itself - dancer.scene.unshiftPhase(new MovePhase(dancer.scene, dancer, [dancer.getBattlerIndex()], move, true)); + if (!simulated) { + // If the move is an AttackMove or a StatusMove the Dancer must replicate the move on the source of the Dance + if (move.getMove() instanceof AttackMove || move.getMove() instanceof StatusMove) { + const target = this.getTarget(dancer, source, targets); + dancer.scene.unshiftPhase(new MovePhase(dancer.scene, dancer, target, move, true)); + } else if (move.getMove() instanceof SelfStatusMove) { + // If the move is a SelfStatusMove (ie. Swords Dance) the Dancer should replicate it on itself + dancer.scene.unshiftPhase(new MovePhase(dancer.scene, dancer, [dancer.getBattlerIndex()], move, true)); + } } return true; } @@ -3405,7 +3558,7 @@ export class StatChangeMultiplierAbAttr extends AbAttr { this.multiplier = multiplier; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.IntegerHolder).value *= this.multiplier; return true; @@ -3413,8 +3566,10 @@ export class StatChangeMultiplierAbAttr extends AbAttr { } export class StatChangeCopyAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, (args[0] as BattleStat[]), (args[1] as integer), true, false, false)); + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, (args[0] as BattleStat[]), (args[1] as integer), true, false, false)); + } return true; } } @@ -3424,7 +3579,7 @@ export class BypassBurnDamageReductionAbAttr extends AbAttr { super(false); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; @@ -3448,15 +3603,15 @@ export class ReduceBurnDamageAbAttr extends AbAttr { * @param args `[0]` {@linkcode Utils.NumberHolder} The damage value being modified * @returns `true` */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - (args[0] as Utils.NumberHolder).value = Math.max(Math.floor((args[0] as Utils.NumberHolder).value * this.multiplier), 1); + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + (args[0] as Utils.NumberHolder).value = Utils.toDmgValue((args[0] as Utils.NumberHolder).value * this.multiplier); return true; } } export class DoubleBerryEffectAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.NumberHolder).value *= 2; return true; @@ -3464,7 +3619,7 @@ export class DoubleBerryEffectAbAttr extends AbAttr { } export class PreventBerryUseAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; @@ -3487,24 +3642,25 @@ export class HealFromBerryUseAbAttr extends AbAttr { this.healPercent = Math.max(Math.min(healPercent, 1), 0); } - apply(pokemon: Pokemon, passive: boolean, ...args: [Utils.BooleanHolder, any[]]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, ...args: [Utils.BooleanHolder, any[]]): boolean { const { name: abilityName } = passive ? pokemon.getPassiveAbility() : pokemon.getAbility(); - pokemon.scene.unshiftPhase( - new PokemonHealPhase( - pokemon.scene, - pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() * this.healPercent), 1), - i18next.t("abilityTriggers:healFromBerryUse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), - true - ) - ); - + if (!simulated) { + pokemon.scene.unshiftPhase( + new PokemonHealPhase( + pokemon.scene, + pokemon.getBattlerIndex(), + Utils.toDmgValue(pokemon.getMaxHp() * this.healPercent), + i18next.t("abilityTriggers:healFromBerryUse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), + true + ) + ); + } return true; } } export class RunSuccessAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.IntegerHolder).value = 256; return true; @@ -3527,7 +3683,7 @@ export class CheckTrappedAbAttr extends AbAttr { this.arenaTrapCondition = condition; } - applyCheckTrapped(pokemon: Pokemon, passive: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean | Promise { + applyCheckTrapped(pokemon: Pokemon, passive: boolean, simulated: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean | Promise { return false; } } @@ -3552,7 +3708,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr { * @param args N/A * @returns if enemy Pokemon is trapped or not */ - applyCheckTrapped(pokemon: Pokemon, passive: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean { + applyCheckTrapped(pokemon: Pokemon, passive: boolean, simulated: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean { if (this.arenaTrapCondition(pokemon, otherPokemon)) { if (otherPokemon.getTypes(true).includes(Type.GHOST) || (otherPokemon.getTypes(true).includes(Type.STELLAR) && otherPokemon.getTypes().includes(Type.GHOST))) { trapped.value = false; @@ -3574,7 +3730,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr { } export class MaxMultiHitAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.IntegerHolder).value = 0; return true; @@ -3586,15 +3742,15 @@ export class PostBattleAbAttr extends AbAttr { super(true); } - applyPostBattle(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { return false; } } export class PostBattleLootAbAttr extends PostBattleAbAttr { - applyPostBattle(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const postBattleLoot = pokemon.scene.currentBattle.postBattleLoot; - if (postBattleLoot.length) { + if (!simulated && postBattleLoot.length) { const randItem = Utils.randSeedItem(postBattleLoot); //@ts-ignore - TODO see below if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true)) { // TODO: fix. This is a promise!? @@ -3609,7 +3765,7 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr { } export class PostFaintAbAttr extends AbAttr { - applyPostFaint(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostFaint(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { return false; } } @@ -3628,7 +3784,7 @@ export class PostFaintClearWeatherAbAttr extends PostFaintAbAttr { * @param args N/A * @returns {boolean} Returns true if the weather clears, otherwise false. */ - applyPostFaint(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostFaint(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { const weatherType = pokemon.scene.arena.weather?.weatherType; let turnOffWeather = false; @@ -3654,6 +3810,10 @@ export class PostFaintClearWeatherAbAttr extends PostFaintAbAttr { break; } + if (simulated) { + return turnOffWeather; + } + if (turnOffWeather) { pokemon.scene.arena.trySetWeather(WeatherType.NONE, false); return true; @@ -3672,15 +3832,17 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr { this.damageRatio = damageRatio; } - applyPostFaint(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + applyPostFaint(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { if (move.checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { const cancelled = new Utils.BooleanHolder(false); - pokemon.scene.getField(true).map(p=>applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled)); + pokemon.scene.getField(true).map(p => applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled, simulated)); if (cancelled.value || attacker.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { return false; } - attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); - attacker.turnData.damageTaken += Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)); + if (!simulated) { + attacker.damageAndUpdate(Utils.toDmgValue(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); + attacker.turnData.damageTaken += Utils.toDmgValue(attacker.getMaxHp() * (1 / this.damageRatio)); + } return true; } @@ -3700,10 +3862,12 @@ export class PostFaintHPDamageAbAttr extends PostFaintAbAttr { super (); } - applyPostFaint(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { - const damage = pokemon.turnData.attacksReceived[0].damage; - attacker.damageAndUpdate((damage), HitResult.OTHER); - attacker.turnData.damageTaken += damage; + applyPostFaint(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { + if (!simulated) { + const damage = pokemon.turnData.attacksReceived[0].damage; + attacker.damageAndUpdate((damage), HitResult.OTHER); + attacker.turnData.damageTaken += damage; + } return true; } @@ -3713,7 +3877,7 @@ export class PostFaintHPDamageAbAttr extends PostFaintAbAttr { } export class RedirectMoveAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.canRedirect(args[0] as Moves)) { const target = args[1] as Utils.IntegerHolder; const newTarget = pokemon.getBattlerIndex(); @@ -3756,9 +3920,9 @@ export class ReduceStatusEffectDurationAbAttr extends AbAttr { this.statusEffect = statusEffect; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (args[0] === this.statusEffect) { - (args[1] as Utils.IntegerHolder).value = Math.floor((args[1] as Utils.IntegerHolder).value / 2); + (args[1] as Utils.IntegerHolder).value = Utils.toDmgValue((args[1] as Utils.IntegerHolder).value / 2); return true; } @@ -3785,8 +3949,10 @@ export class FlinchStatChangeAbAttr extends FlinchEffectAbAttr { this.levels = levels; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (!simulated) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); + } return true; } } @@ -3794,7 +3960,7 @@ export class FlinchStatChangeAbAttr extends FlinchEffectAbAttr { export class IncreasePpAbAttr extends AbAttr { } export class ForceSwitchOutImmunityAbAttr extends AbAttr { - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { cancelled.value = true; return true; } @@ -3805,7 +3971,7 @@ export class ReduceBerryUseThresholdAbAttr extends AbAttr { super(); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const hpRatio = pokemon.getHpRatio(); if (args[0].value < hpRatio) { @@ -3826,7 +3992,7 @@ export class WeightMultiplierAbAttr extends AbAttr { this.multiplier = multiplier; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Utils.NumberHolder).value *= this.multiplier; return true; @@ -3838,7 +4004,7 @@ export class SyncEncounterNatureAbAttr extends AbAttr { super(false); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { (args[0] as Pokemon).setNature(pokemon.getNature()); return true; @@ -3854,7 +4020,7 @@ export class MoveAbilityBypassAbAttr extends AbAttr { this.moveIgnoreFunc = moveIgnoreFunc || ((pokemon, move) => true); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.moveIgnoreFunc(pokemon, (args[0] as Move))) { cancelled.value = true; return true; @@ -3868,7 +4034,7 @@ export class SuppressFieldAbilitiesAbAttr extends AbAttr { super(false); } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const ability = (args[0] as Ability); if (!ability.hasAttr(UnsuppressableAbilityAbAttr) && !ability.hasAttr(SuppressFieldAbilitiesAbAttr)) { cancelled.value = true; @@ -3923,7 +4089,7 @@ export class IgnoreTypeImmunityAbAttr extends AbAttr { this.allowedMoveTypes = allowedMoveTypes; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.defenderType === (args[1] as Type) && this.allowedMoveTypes.includes(args[0] as Type)) { cancelled.value = true; return true; @@ -3946,7 +4112,7 @@ export class IgnoreTypeStatusEffectImmunityAbAttr extends AbAttr { this.defenderType = defenderType; } - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.statusEffect.includes(args[0] as StatusEffect) && this.defenderType.includes(args[1] as Type)) { cancelled.value = true; return true; @@ -3973,8 +4139,10 @@ export class MoneyAbAttr extends PostBattleAbAttr { * @param args N/A * @returns true */ - applyPostBattle(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - pokemon.scene.currentBattle.moneyScattered += pokemon.scene.getWaveMoneyAmount(0.2); + applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + if (!simulated) { + pokemon.scene.currentBattle.moneyScattered += pokemon.scene.getWaveMoneyAmount(0.2); + } return true; } } @@ -4013,11 +4181,11 @@ export class PostSummonStatChangeOnArenaAbAttr extends PostSummonStatChangeAbAtt * @param {any[]} args - Additional arguments. * @returns {boolean} - Returns true if the stat change was applied, otherwise false. */ - applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const side = pokemon.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; if (pokemon.scene.arena.getTagOnSide(this.tagType, side)) { - return super.applyPostSummon(pokemon, passive, args); + return super.applyPostSummon(pokemon, passive, simulated, args); } return false; } @@ -4055,12 +4223,14 @@ export class FormBlockDamageAbAttr extends ReceivedMoveDamageMultiplierAbAttr { * @param {any[]} args Additional arguments. * @returns {boolean} Whether the immunity was applied. */ - applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { + applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.condition(pokemon, attacker, move)) { - (args[0] as Utils.NumberHolder).value = this.multiplier; - pokemon.removeTag(this.tagType); - if (this.recoilDamageFunc) { - pokemon.damageAndUpdate(this.recoilDamageFunc(pokemon), HitResult.OTHER); + if (!simulated) { + (args[0] as Utils.NumberHolder).value = this.multiplier; + pokemon.removeTag(this.tagType); + if (this.recoilDamageFunc) { + pokemon.damageAndUpdate(this.recoilDamageFunc(pokemon), HitResult.OTHER); + } } return true; } @@ -4104,7 +4274,10 @@ export class BypassSpeedChanceAbAttr extends AbAttr { * @param {any[]} args [0] {@linkcode Utils.BooleanHolder} set to true when the ability activated * @returns {boolean} - whether the ability was activated. */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (simulated) { + return false; + } const bypassSpeed = args[0] as Utils.BooleanHolder; if (!bypassSpeed.value && pokemon.randSeedInt(100) < this.chance) { @@ -4147,7 +4320,7 @@ export class PreventBypassSpeedChanceAbAttr extends AbAttr { * @argument {boolean} bypassSpeed - determines if a Pokemon is able to bypass speed at the moment * @argument {boolean} canCheckHeldItems - determines if a Pokemon has access to Quick Claw's effects or not */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const bypassSpeed = args[0] as Utils.BooleanHolder; const canCheckHeldItems = args[1] as Utils.BooleanHolder; @@ -4169,7 +4342,7 @@ async function applyAbAttrsInternal( applyFunc: AbAttrApplyFunc, args: any[], showAbilityInstant: boolean = false, - isQuiet: boolean = false, + quiet: boolean = false, messages: string[] = [], ) { for (const passive of [false, true]) { @@ -4196,11 +4369,11 @@ async function applyAbAttrsInternal( if (pokemon.summonData && !pokemon.summonData.abilitiesApplied.includes(ability.id)) { pokemon.summonData.abilitiesApplied.push(ability.id); } - if (pokemon.battleData && !pokemon.battleData.abilitiesApplied.includes(ability.id)) { + if (pokemon.battleData && !quiet && !pokemon.battleData.abilitiesApplied.includes(ability.id)) { pokemon.battleData.abilitiesApplied.push(ability.id); } - if (attr.showAbility && !isQuiet) { + if (attr.showAbility && !quiet) { if (showAbilityInstant) { pokemon.scene.abilityBar.showAbility(pokemon, passive); } else { @@ -4208,12 +4381,12 @@ async function applyAbAttrsInternal( } } - const message = attr.getTriggerMessage(pokemon, ability.name, args); - if (message) { - if (!isQuiet) { + if (!quiet) { + const message = attr.getTriggerMessage(pokemon, ability.name, args); + if (message) { pokemon.scene.queueMessage(message); + messages.push(message); } - messages.push(message); } } } @@ -4222,34 +4395,33 @@ async function applyAbAttrsInternal( } } -export function applyAbAttrs(attrType: Constructor, pokemon: Pokemon, cancelled: Utils.BooleanHolder | null, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.apply(pokemon, passive, cancelled, args), args); +export function applyAbAttrs(attrType: Constructor, pokemon: Pokemon, cancelled: Utils.BooleanHolder | null, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.apply(pokemon, passive, simulated, cancelled, args), args, false, simulated); } export function applyPostBattleInitAbAttrs(attrType: Constructor, - pokemon: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostBattleInit(pokemon, passive, args), args); + pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostBattleInit(pokemon, passive, simulated, args), args, false, simulated); } export function applyPreDefendAbAttrs(attrType: Constructor, - pokemon: Pokemon, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, ...args: any[]): Promise { - const simulated = args.length > 1 && args[1]; - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreDefend(pokemon, passive, attacker, move, cancelled, args), args, false, simulated); + pokemon: Pokemon, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), args, false, simulated); } export function applyPostDefendAbAttrs(attrType: Constructor, - pokemon: Pokemon, attacker: Pokemon, move: Move, hitResult: HitResult | null, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostDefend(pokemon, passive, attacker, move, hitResult, args), args); + pokemon: Pokemon, attacker: Pokemon, move: Move, hitResult: HitResult | null, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostDefend(pokemon, passive, simulated, attacker, move, hitResult, args), args, false, simulated); } export function applyPostMoveUsedAbAttrs(attrType: Constructor, - pokemon: Pokemon, move: PokemonMove, source: Pokemon, targets: BattlerIndex[], ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostMoveUsed(pokemon, move, source, targets, args), args); + pokemon: Pokemon, move: PokemonMove, source: Pokemon, targets: BattlerIndex[], simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostMoveUsed(pokemon, move, source, targets, simulated, args), args, false, simulated); } export function applyBattleStatMultiplierAbAttrs(attrType: Constructor, - pokemon: Pokemon, battleStat: BattleStat, statValue: Utils.NumberHolder, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyBattleStat(pokemon, passive, battleStat, statValue, args), args); + pokemon: Pokemon, battleStat: BattleStat, statValue: Utils.NumberHolder, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyBattleStat(pokemon, passive, simulated, battleStat, statValue, args), args, false, simulated); } /** @@ -4263,99 +4435,98 @@ export function applyBattleStatMultiplierAbAttrs(attrType: Constructor, - pokemon: Pokemon, stat: Stat, statValue: Utils.NumberHolder, checkedPokemon: Pokemon, hasApplied: Utils.BooleanHolder, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyFieldBattleStat(pokemon, passive, stat, statValue, checkedPokemon, hasApplied, args), args); + pokemon: Pokemon, stat: Stat, statValue: Utils.NumberHolder, checkedPokemon: Pokemon, hasApplied: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyFieldBattleStat(pokemon, passive, simulated, stat, statValue, checkedPokemon, hasApplied, args), args, false, simulated); } export function applyPreAttackAbAttrs(attrType: Constructor, - pokemon: Pokemon, defender: Pokemon | null, move: Move, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreAttack(pokemon, passive, defender, move, args), args); + pokemon: Pokemon, defender: Pokemon | null, move: Move, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreAttack(pokemon, passive, simulated, defender, move, args), args, false, simulated); } export function applyPostAttackAbAttrs(attrType: Constructor, - pokemon: Pokemon, defender: Pokemon, move: Move, hitResult: HitResult | null, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostAttack(pokemon, passive, defender, move, hitResult, args), args); + pokemon: Pokemon, defender: Pokemon, move: Move, hitResult: HitResult | null, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostAttack(pokemon, passive, simulated, defender, move, hitResult, args), args, false, simulated); } export function applyPostKnockOutAbAttrs(attrType: Constructor, - pokemon: Pokemon, knockedOut: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostKnockOut(pokemon, passive, knockedOut, args), args); + pokemon: Pokemon, knockedOut: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostKnockOut(pokemon, passive, simulated, knockedOut, args), args, false, simulated); } export function applyPostVictoryAbAttrs(attrType: Constructor, - pokemon: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostVictory(pokemon, passive, args), args); + pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostVictory(pokemon, passive, simulated, args), args, false, simulated); } export function applyPostSummonAbAttrs(attrType: Constructor, - pokemon: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostSummon(pokemon, passive, args), args); + pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args), args, false, simulated); } export function applyPreSwitchOutAbAttrs(attrType: Constructor, - pokemon: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreSwitchOut(pokemon, passive, args), args, true); + pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreSwitchOut(pokemon, passive, simulated, args), args, true, simulated); } export function applyPreStatChangeAbAttrs(attrType: Constructor, - pokemon: Pokemon | null, stat: BattleStat, cancelled: Utils.BooleanHolder, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreStatChange(pokemon, passive, stat, cancelled, args), args); + pokemon: Pokemon | null, stat: BattleStat, cancelled: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreStatChange(pokemon, passive, simulated, stat, cancelled, args), args, false, simulated); } export function applyPostStatChangeAbAttrs(attrType: Constructor, - pokemon: Pokemon, stats: BattleStat[], levels: integer, selfTarget: boolean, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostStatChange(pokemon, stats, levels, selfTarget, args), args); + pokemon: Pokemon, stats: BattleStat[], levels: integer, selfTarget: boolean, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostStatChange(pokemon, simulated, stats, levels, selfTarget, args), args, false, simulated); } export function applyPreSetStatusAbAttrs(attrType: Constructor, - pokemon: Pokemon, effect: StatusEffect | undefined, cancelled: Utils.BooleanHolder, ...args: any[]): Promise { - const simulated = args.length > 1 && args[1]; - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreSetStatus(pokemon, passive, effect, cancelled, args), args, false, !simulated); + pokemon: Pokemon, effect: StatusEffect | undefined, cancelled: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreSetStatus(pokemon, passive, simulated, effect, cancelled, args), args, false, simulated); } export function applyPreApplyBattlerTagAbAttrs(attrType: Constructor, - pokemon: Pokemon, tag: BattlerTag, cancelled: Utils.BooleanHolder, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreApplyBattlerTag(pokemon, passive, tag, cancelled, args), args); + pokemon: Pokemon, tag: BattlerTag, cancelled: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreApplyBattlerTag(pokemon, passive, simulated, tag, cancelled, args), args, false, simulated); } export function applyPreWeatherEffectAbAttrs(attrType: Constructor, - pokemon: Pokemon, weather: Weather | null, cancelled: Utils.BooleanHolder, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreWeatherEffect(pokemon, passive, weather, cancelled, args), args, true); + pokemon: Pokemon, weather: Weather | null, cancelled: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreWeatherEffect(pokemon, passive, simulated, weather, cancelled, args), args, true, simulated); } export function applyPostTurnAbAttrs(attrType: Constructor, - pokemon: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostTurn(pokemon, passive, args), args); + pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostTurn(pokemon, passive, simulated, args), args, false, simulated); } export function applyPostWeatherChangeAbAttrs(attrType: Constructor, - pokemon: Pokemon, weather: WeatherType, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostWeatherChange(pokemon, passive, weather, args), args); + pokemon: Pokemon, weather: WeatherType, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostWeatherChange(pokemon, passive, simulated, weather, args), args, false, simulated); } export function applyPostWeatherLapseAbAttrs(attrType: Constructor, - pokemon: Pokemon, weather: Weather | null, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostWeatherLapse(pokemon, passive, weather, args), args); + pokemon: Pokemon, weather: Weather | null, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostWeatherLapse(pokemon, passive, simulated, weather, args), args, false, simulated); } export function applyPostTerrainChangeAbAttrs(attrType: Constructor, - pokemon: Pokemon, terrain: TerrainType, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostTerrainChange(pokemon, passive, terrain, args), args); + pokemon: Pokemon, terrain: TerrainType, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostTerrainChange(pokemon, passive, simulated, terrain, args), args, false, simulated); } export function applyCheckTrappedAbAttrs(attrType: Constructor, - pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, isQuiet: boolean, messages: string[], ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, trapped, otherPokemon, args), args, false, isQuiet, messages); + pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, messages: string[], simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), args, false, simulated, messages); } export function applyPostBattleAbAttrs(attrType: Constructor, - pokemon: Pokemon, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostBattle(pokemon, passive, args), args); + pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostBattle(pokemon, passive, simulated, args), args, false, simulated); } export function applyPostFaintAbAttrs(attrType: Constructor, - pokemon: Pokemon, attacker: Pokemon, move: Move, hitResult: HitResult, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostFaint(pokemon, passive, attacker, move, hitResult, args), args); + pokemon: Pokemon, attacker: Pokemon, move: Move, hitResult: HitResult, simulated: boolean = false, ...args: any[]): Promise { + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostFaint(pokemon, passive, simulated, attacker, move, hitResult, args), args, false, simulated); } function queueShowAbility(pokemon: Pokemon, passive: boolean): void { @@ -4420,7 +4591,7 @@ export function initAbilities() { .ignorable(), new Ability(Abilities.CLOUD_NINE, 3) .attr(SuppressWeatherEffectAbAttr, true) - .attr(PostSummonUnnamedMessageAbAttr, "The effects of the weather disappeared."), + .attr(PostSummonUnnamedMessageAbAttr, i18next.t("abilityTriggers:weatherEffectDisappeared")), new Ability(Abilities.COMPOUND_EYES, 3) .attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 1.3), new Ability(Abilities.INSOMNIA, 3) @@ -4615,7 +4786,7 @@ export function initAbilities() { .ignorable(), new Ability(Abilities.AIR_LOCK, 3) .attr(SuppressWeatherEffectAbAttr, true) - .attr(PostSummonUnnamedMessageAbAttr, "The effects of the weather disappeared."), + .attr(PostSummonUnnamedMessageAbAttr, i18next.t("abilityTriggers:weatherEffectDisappeared")), new Ability(Abilities.TANGLED_FEET, 4) .conditionalAttr(pokemon => !!pokemon.getTag(BattlerTagType.CONFUSED), BattleStatMultiplierAbAttr, BattleStat.EVA, 2) .ignorable(), @@ -5040,7 +5211,7 @@ export function initAbilities() { .conditionalAttr(pokemon => pokemon.formIndex === 0, PostSummonAddBattlerTagAbAttr, BattlerTagType.DISGUISE, 0, false) .attr(FormBlockDamageAbAttr, (target, user, move) => !!target.getTag(BattlerTagType.DISGUISE) && target.getAttackTypeEffectiveness(move.type, user) > 0, 0, BattlerTagType.DISGUISE, (pokemon, abilityName) => i18next.t("abilityTriggers:disguiseAvoidedDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }), - (pokemon) => Math.floor(pokemon.getMaxHp() / 8)) + (pokemon) => Utils.toDmgValue(pokemon.getMaxHp() / 8)) .attr(PostBattleInitFormChangeAbAttr, () => 0) .bypassFaint() .ignorable(), diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 3394df827fb..a60ea5c2981 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -269,7 +269,7 @@ const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => { if (effectPhase instanceof MoveEffectPhase) { const attacker = effectPhase.getUserPokemon()!; applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, priority); - applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, move, priority); + applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority); } return priority.value > 0; }; @@ -427,7 +427,7 @@ class WishTag extends ArenaTag { if (user) { this.battlerIndex = user.getBattlerIndex(); this.triggerMessage = i18next.t("arenaTag:wishTagOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(user) }); - this.healHp = Math.max(Math.floor(user.getMaxHp() / 2), 1); + this.healHp = Utils.toDmgValue(user.getMaxHp() / 2); } else { console.warn("Failed to get source for WishTag onAdd"); } @@ -585,7 +585,7 @@ class SpikesTag extends ArenaTrapTag { if (!cancelled.value) { const damageHpRatio = 1 / (10 - 2 * this.layers); - const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio); + const damage = Utils.toDmgValue(pokemon.getMaxHp() * damageHpRatio); pokemon.scene.queueMessage(i18next.t("arenaTag:spikesActivateTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); pokemon.damageAndUpdate(damage, HitResult.OTHER); @@ -745,7 +745,7 @@ class StealthRockTag extends ArenaTrapTag { const damageHpRatio = this.getDamageHpRatio(pokemon); if (damageHpRatio) { - const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio); + const damage = Utils.toDmgValue(pokemon.getMaxHp() * damageHpRatio); pokemon.scene.queueMessage(i18next.t("arenaTag:stealthRockActivateTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); pokemon.damageAndUpdate(damage, HitResult.OTHER); if (pokemon.turnData) { diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ede8d029327..8c05d296e76 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -347,7 +347,7 @@ export class ConfusedTag extends BattlerTag { if (pokemon.randSeedInt(3) === 0) { const atk = pokemon.getBattleStat(Stat.ATK); const def = pokemon.getBattleStat(Stat.DEF); - const damage = Math.ceil(((((2 * pokemon.level / 5 + 2) * 40 * atk / def) / 50) + 2) * (pokemon.randSeedInt(15, 85) / 100)); + const damage = Utils.toDmgValue(((((2 * pokemon.level / 5 + 2) * 40 * atk / def) / 50) + 2) * (pokemon.randSeedInt(15, 85) / 100)); pokemon.scene.queueMessage(i18next.t("battlerTags:confusedLapseHurtItself")); pokemon.damageAndUpdate(damage); pokemon.battleData.hitCount++; @@ -524,7 +524,7 @@ export class SeedTag extends BattlerTag { if (!cancelled.value) { pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, source.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.LEECH_SEED)); - const damage = pokemon.damageAndUpdate(Math.max(Math.floor(pokemon.getMaxHp() / 8), 1)); + const damage = pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / 8)); const reverseDrain = pokemon.hasAbilityWithAttr(ReverseDrainAbAttr, false); pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, source.getBattlerIndex(), !reverseDrain ? damage : damage * -1, @@ -570,7 +570,7 @@ export class NightmareTag extends BattlerTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / 4)); + pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / 4)); } } @@ -714,7 +714,7 @@ export class IngrainTag extends TrappedTag { new PokemonHealPhase( pokemon.scene, pokemon.getBattlerIndex(), - Math.floor(pokemon.getMaxHp() / 16), + Utils.toDmgValue(pokemon.getMaxHp() / 16), i18next.t("battlerTags:ingrainLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), true ) @@ -777,7 +777,7 @@ export class AquaRingTag extends BattlerTag { new PokemonHealPhase( pokemon.scene, pokemon.getBattlerIndex(), - Math.floor(pokemon.getMaxHp() / 16), + Utils.toDmgValue(pokemon.getMaxHp() / 16), i18next.t("battlerTags:aquaRingLapse", { moveName: this.getMoveName(), pokemonName: getPokemonNameWithAffix(pokemon) @@ -883,7 +883,7 @@ export abstract class DamagingTrapTag extends TrappedTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / 8)); + pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / 8)); } } @@ -1067,7 +1067,7 @@ export class ContactDamageProtectedTag extends ProtectedTag { if (effectPhase instanceof MoveEffectPhase && effectPhase.move.getMove().hasFlag(MoveFlags.MAKES_CONTACT)) { const attacker = effectPhase.getPokemon(); if (!attacker.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { - attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); + attacker.damageAndUpdate(Utils.toDmgValue(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); } } } @@ -1541,7 +1541,7 @@ export class SaltCuredTag extends BattlerTag { if (!cancelled.value) { const pokemonSteelOrWater = pokemon.isOfType(Type.STEEL) || pokemon.isOfType(Type.WATER); - pokemon.damageAndUpdate(Math.max(Math.floor(pokemonSteelOrWater ? pokemon.getMaxHp() / 4 : pokemon.getMaxHp() / 8), 1)); + pokemon.damageAndUpdate(Utils.toDmgValue(pokemonSteelOrWater ? pokemon.getMaxHp() / 4 : pokemon.getMaxHp() / 8)); pokemon.scene.queueMessage( i18next.t("battlerTags:saltCuredLapse", { @@ -1587,7 +1587,7 @@ export class CursedTag extends BattlerTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - pokemon.damageAndUpdate(Math.max(Math.floor(pokemon.getMaxHp() / 4), 1)); + pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / 4)); pokemon.scene.queueMessage(i18next.t("battlerTags:cursedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } } diff --git a/src/data/berry.ts b/src/data/berry.ts index e962219ca46..d0c9c311e16 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -36,25 +36,25 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate { return (pokemon: Pokemon) => { const threshold = new Utils.NumberHolder(0.25); const battleStat = (berryType - BerryType.LIECHI) as BattleStat; - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold); + applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); return pokemon.getHpRatio() < threshold.value && pokemon.summonData.battleStats[battleStat] < 6; }; case BerryType.LANSAT: return (pokemon: Pokemon) => { const threshold = new Utils.NumberHolder(0.25); - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold); + applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); return pokemon.getHpRatio() < 0.25 && !pokemon.getTag(BattlerTagType.CRIT_BOOST); }; case BerryType.STARF: return (pokemon: Pokemon) => { const threshold = new Utils.NumberHolder(0.25); - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold); + applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); return pokemon.getHpRatio() < 0.25; }; case BerryType.LEPPA: return (pokemon: Pokemon) => { const threshold = new Utils.NumberHolder(0.25); - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold); + applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); return !!pokemon.getMoveset().find(m => !m?.getPpRatio()); }; } @@ -70,8 +70,8 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { if (pokemon.battleData) { pokemon.battleData.berriesEaten.push(berryType); } - const hpHealed = new Utils.NumberHolder(Math.floor(pokemon.getMaxHp() / 4)); - applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, hpHealed); + const hpHealed = new Utils.NumberHolder(Utils.toDmgValue(pokemon.getMaxHp() / 4)); + applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed); pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(), hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true)); }; @@ -97,7 +97,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { } const battleStat = (berryType - BerryType.LIECHI) as BattleStat; const statLevels = new Utils.NumberHolder(1); - applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, statLevels); + applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statLevels); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ battleStat ], statLevels.value)); }; case BerryType.LANSAT: @@ -113,7 +113,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { pokemon.battleData.berriesEaten.push(berryType); } const statLevels = new Utils.NumberHolder(2); - applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, statLevels); + applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statLevels); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ BattleStat.RAND ], statLevels.value)); }; case BerryType.LEPPA: diff --git a/src/data/move.ts b/src/data/move.ts index af3f49bea0d..b1b82009f3e 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -590,7 +590,7 @@ export default class Move implements Localizable { case MoveFlags.IGNORE_ABILITIES: if (user.hasAbilityWithAttr(MoveAbilityBypassAbAttr)) { const abilityEffectsIgnored = new Utils.BooleanHolder(false); - applyAbAttrs(MoveAbilityBypassAbAttr, user, abilityEffectsIgnored, this); + applyAbAttrs(MoveAbilityBypassAbAttr, user, abilityEffectsIgnored, false, this); if (abilityEffectsIgnored.value) { return true; } @@ -686,11 +686,11 @@ export default class Move implements Localizable { * @param target {@linkcode Pokemon} The Pokémon being targeted by the move. * @returns The calculated accuracy of the move. */ - calculateBattleAccuracy(user: Pokemon, target: Pokemon) { + calculateBattleAccuracy(user: Pokemon, target: Pokemon, simulated: boolean = false) { const moveAccuracy = new Utils.NumberHolder(this.accuracy); applyMoveAttrs(VariableAccuracyAttr, user, target, this, moveAccuracy); - applyPreDefendAbAttrs(WonderSkinAbAttr, target, user, this, { value: false }, moveAccuracy); + applyPreDefendAbAttrs(WonderSkinAbAttr, target, user, this, { value: false }, simulated, moveAccuracy); if (moveAccuracy.value === -1) { return moveAccuracy.value; @@ -724,7 +724,7 @@ export default class Move implements Localizable { * @param target {@linkcode Pokemon} The Pokémon being targeted by the move. * @returns The calculated power of the move. */ - calculateBattlePower(source: Pokemon, target: Pokemon): number { + calculateBattlePower(source: Pokemon, target: Pokemon, simulated: boolean = false): number { if (this.category === MoveCategory.STATUS) { return -1; } @@ -732,17 +732,17 @@ export default class Move implements Localizable { const power = new Utils.NumberHolder(this.power); const typeChangeMovePowerMultiplier = new Utils.NumberHolder(1); - applyPreAttackAbAttrs(MoveTypeChangeAttr, source, target, this, typeChangeMovePowerMultiplier); + applyPreAttackAbAttrs(MoveTypeChangeAttr, source, target, this, simulated, typeChangeMovePowerMultiplier); const sourceTeraType = source.getTeraType(); if (sourceTeraType !== Type.UNKNOWN && sourceTeraType === this.type && power.value < 60 && this.priority <= 0 && !this.hasAttr(MultiHitAttr) && !source.scene.findModifier(m => m instanceof PokemonMultiHitModifier && m.pokemonId === source.id)) { power.value = 60; } - applyPreAttackAbAttrs(VariableMovePowerAbAttr, source, target, this, power); + applyPreAttackAbAttrs(VariableMovePowerAbAttr, source, target, this, simulated, power); if (source.getAlly()) { - applyPreAttackAbAttrs(AllyMoveCategoryPowerBoostAbAttr, source.getAlly(), target, this, power); + applyPreAttackAbAttrs(AllyMoveCategoryPowerBoostAbAttr, source.getAlly(), target, this, simulated, power); } const fieldAuras = new Set( @@ -752,11 +752,11 @@ export default class Move implements Localizable { ); for (const aura of fieldAuras) { // The only relevant values are `move` and the `power` holder - aura.applyPreAttack(null, null, null, this, [power]); + aura.applyPreAttack(null, null, simulated, null, this, [power]); } const alliedField: Pokemon[] = source instanceof PlayerPokemon ? source.scene.getPlayerField() : source.scene.getEnemyField(); - alliedField.forEach(p => applyPreAttackAbAttrs(UserFieldMoveTypePowerBoostAbAttr, p, target, this, power)); + alliedField.forEach(p => applyPreAttackAbAttrs(UserFieldMoveTypePowerBoostAbAttr, p, target, this, simulated, power)); power.value *= typeChangeMovePowerMultiplier.value; @@ -984,9 +984,9 @@ export class MoveEffectAttr extends MoveAttr { */ getMoveChance(user: Pokemon, target: Pokemon, move: Move, selfEffect?: Boolean, showAbility?: Boolean): integer { const moveChance = new Utils.NumberHolder(move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, moveChance, move, target, selfEffect, showAbility); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, moveChance, move, target, selfEffect, showAbility); if (!selfEffect) { - applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, target, user, null, null, moveChance); + applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, target, user, null, null, false, moveChance); } return moveChance.value; } @@ -1162,7 +1162,7 @@ export class TargetHalfHpDamageAttr extends FixedDamageAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = Math.max(Math.floor(target.hp / 2), 1); + (args[0] as Utils.IntegerHolder).value = Utils.toDmgValue(target.hp / 2); return true; } @@ -1208,7 +1208,7 @@ export class CounterDamageAttr extends FixedDamageAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const damage = user.turnData.attacksReceived.filter(ar => this.moveFilter(allMoves[ar.move])).reduce((total: integer, ar: AttackMoveResult) => total + ar.damage, 0); - (args[0] as Utils.IntegerHolder).value = Math.floor(Math.max(damage * this.multiplier, 1)); + (args[0] as Utils.IntegerHolder).value = Utils.toDmgValue(damage * this.multiplier); return true; } @@ -1234,7 +1234,7 @@ export class RandomLevelDamageAttr extends FixedDamageAttr { } getDamage(user: Pokemon, target: Pokemon, move: Move): number { - return Math.max(Math.floor(user.level * (user.randSeedIntRange(50, 150) * 0.01)), 1); + return Utils.toDmgValue(user.level * (user.randSeedIntRange(50, 150) * 0.01)); } } @@ -1293,8 +1293,9 @@ export class RecoilAttr extends MoveEffectAttr { return false; } - const recoilDamage = Math.max(Math.floor((!this.useHp ? user.turnData.damageDealt : user.getMaxHp()) * this.damageRatio), - user.turnData.damageDealt ? 1 : 0); + const damageValue = (!this.useHp ? user.turnData.damageDealt : user.getMaxHp()) * this.damageRatio; + const minValue = user.turnData.damageDealt ? 1 : 0; + const recoilDamage = Utils.toDmgValue(damageValue, minValue); if (!recoilDamage) { return false; } @@ -1415,7 +1416,7 @@ export class HalfSacrificialAttr extends MoveEffectAttr { // Check to see if the Pokemon has an ability that blocks non-direct damage applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); if (!cancelled.value) { - user.damageAndUpdate(Math.ceil(user.getMaxHp()/2), HitResult.OTHER, false, true, true); + user.damageAndUpdate(Utils.toDmgValue(user.getMaxHp()/2), HitResult.OTHER, false, true, true); user.scene.queueMessage(i18next.t("moveTriggers:cutHpPowerUpMove", {pokemonName: getPokemonNameWithAffix(user)})); // Queue recoil message } return true; @@ -1466,7 +1467,7 @@ export class HealAttr extends MoveEffectAttr { */ addHealPhase(target: Pokemon, healRatio: number) { target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), - Math.max(Math.floor(target.getMaxHp() * healRatio), 1), i18next.t("moveTriggers:healHp", {pokemonName: getPokemonNameWithAffix(target)}), true, !this.showAnim)); + Utils.toDmgValue(target.getMaxHp() * healRatio), i18next.t("moveTriggers:healHp", {pokemonName: getPokemonNameWithAffix(target)}), true, !this.showAnim)); } getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { @@ -1750,7 +1751,7 @@ export class HitHealAttr extends MoveEffectAttr { message = i18next.t("battle:drainMessage", {pokemonName: getPokemonNameWithAffix(target)}); } else { // Default healing formula used by draining moves like Absorb, Draining Kiss, Bitter Blade, etc. - healAmount = Math.max(Math.floor(user.turnData.currDamageDealt * this.healRatio), 1); + healAmount = Utils.toDmgValue(user.turnData.currDamageDealt * this.healRatio); message = i18next.t("battle:regainHealth", {pokemonName: getPokemonNameWithAffix(user)}); } if (reverseDrain) { @@ -1883,7 +1884,7 @@ export class MultiHitAttr extends MoveAttr { { const rand = user.randSeedInt(16); const hitValue = new Utils.IntegerHolder(rand); - applyAbAttrs(MaxMultiHitAbAttr, user, null, hitValue); + applyAbAttrs(MaxMultiHitAbAttr, user, null, false, hitValue); if (hitValue.value >= 10) { return 2; } else if (hitValue.value >= 4) { @@ -1954,7 +1955,7 @@ export class StatusEffectAttr extends MoveEffectAttr { } if ((!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0)) && pokemon.trySetStatus(this.effect, true, user, this.cureTurn)) { - applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, this.effect); + applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, false, this.effect); return true; } } @@ -2710,7 +2711,7 @@ export class CutHpStatBoostAttr extends StatChangeAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { return new Promise(resolve => { - user.damageAndUpdate(Math.floor(user.getMaxHp() / this.cutRatio), HitResult.OTHER, false, true); + user.damageAndUpdate(Utils.toDmgValue(user.getMaxHp() / this.cutRatio), HitResult.OTHER, false, true); user.updateInfo().then(() => { const ret = super.apply(user, target, move, args); if (this.messageCallback) { @@ -3190,7 +3191,7 @@ export class CompareWeightPowerAttr extends VariablePowerAttr { export class HpPowerAttr extends VariablePowerAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.NumberHolder).value = Math.max(Math.floor(150 * user.getHpRatio()), 1); + (args[0] as Utils.NumberHolder).value = Utils.toDmgValue(150 * user.getHpRatio()); return true; } @@ -3218,7 +3219,7 @@ export class OpponentHighHpPowerAttr extends VariablePowerAttr { * @returns true */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.NumberHolder).value = Math.max(Math.floor(this.maxBasePower * target.getHpRatio()), 1); + (args[0] as Utils.NumberHolder).value = Utils.toDmgValue(this.maxBasePower * target.getHpRatio()); return true; } @@ -3412,7 +3413,7 @@ export class PresentPowerAttr extends VariablePowerAttr { // If this move is multi-hit, disable all other hits user.stopMultiHit(); target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), - Math.max(Math.floor(target.getMaxHp() / 4), 1), i18next.t("moveTriggers:regainedHealth", {pokemonName: getPokemonNameWithAffix(target)}), true)); + Utils.toDmgValue(target.getMaxHp() / 4), i18next.t("moveTriggers:regainedHealth", {pokemonName: getPokemonNameWithAffix(target)}), true)); } return true; @@ -3784,6 +3785,30 @@ export class TeraBlastCategoryAttr extends VariableMoveCategoryAttr { } } +/** + * Increases the power of Tera Blast if the user is Terastallized into Stellar type + * @extends VariablePowerAttr + */ +export class TeraBlastPowerAttr extends VariablePowerAttr { + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + /** + * @param user {@linkcode Pokemon} Pokemon using the move + * @param target {@linkcode Pokemon} N/A + * @param move {@linkcode Move} {@linkcode Move.TERA_BLAST} + * @param {any[]} args N/A + * @returns true or false + */ + const power = args[0] as Utils.NumberHolder; + if (user.isTerastallized() && move.type === Type.STELLAR) { + //200 instead of 100 to reflect lack of stellar being 2x dmg on any type + power.value = 200; + return true; + } + + return false; + } +} + /** * Change the move category to status when used on the ally * @extends VariableMoveCategoryAttr @@ -4037,6 +4062,28 @@ export class HiddenPowerTypeAttr extends VariableMoveTypeAttr { } } +/** + * Changes the type of Tera Blast to match the user's tera type + * @extends VariableMoveTypeAttr + */ +export class TeraBlastTypeAttr extends VariableMoveTypeAttr { + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + /** + * @param user {@linkcode Pokemon} the user's type is checked + * @param target {@linkcode Pokemon} N/A + * @param move {@linkcode Move} {@linkcode Move.TeraBlastTypeAttr} + * @param {any[]} args N/A + * @returns true or false + */ + if (user.isTerastallized()) { + move.type = user.getTeraType(); //changes move type to tera type + return true; + } + + return false; + } +} + export class MatchUserTypeAttr extends VariableMoveTypeAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const userTypes = user.getTypes(true); @@ -4186,9 +4233,9 @@ const crashDamageFunc = (user: Pokemon, move: Move) => { return false; } - user.damageAndUpdate(Math.floor(user.getMaxHp() / 2), HitResult.OTHER, false, true); + user.damageAndUpdate(Utils.toDmgValue(user.getMaxHp() / 2), HitResult.OTHER, false, true); user.scene.queueMessage(i18next.t("moveTriggers:keptGoingAndCrashed", {pokemonName: getPokemonNameWithAffix(user)})); - user.turnData.damageTaken += Math.floor(user.getMaxHp() / 2); + user.turnData.damageTaken += Utils.toDmgValue(user.getMaxHp() / 2); return true; }; @@ -4438,6 +4485,39 @@ export class GulpMissileTagAttr extends MoveEffectAttr { } } +/** + * Attribute to implement Jaw Lock's linked trapping effect between the user and target + * @extends AddBattlerTagAttr + */ +export class JawLockAttr extends AddBattlerTagAttr { + constructor() { + super(BattlerTagType.TRAPPED); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (!super.canApply(user, target, move, args)) { + return false; + } + + // If either the user or the target already has the tag, do not apply + if (user.getTag(TrappedTag) || target.getTag(TrappedTag)) { + return false; + } + + const moveChance = this.getMoveChance(user, target, move, this.selfTarget); + if (moveChance < 0 || moveChance === 100 || user.randSeedInt(100) < moveChance) { + /** + * Add the tag to both the user and the target. + * The target's tag source is considered to be the user and vice versa + */ + return target.addTag(BattlerTagType.TRAPPED, 1, move.id, user.id) + && user.addTag(BattlerTagType.TRAPPED, 1, move.id, target.id); + } + + return false; + } +} + export class CurseAttr extends MoveEffectAttr { apply(user: Pokemon, target: Pokemon, move:Move, args: any[]): boolean { @@ -4865,7 +4945,7 @@ export class RevivalBlessingAttr extends MoveEffectAttr { const pokemon = faintedPokemon[user.randSeedInt(faintedPokemon.length)]; const slotIndex = user.scene.getEnemyParty().findIndex(p => pokemon.id === p.id); pokemon.resetStatus(); - pokemon.heal(Math.min(Math.max(Math.ceil(Math.floor(0.5 * pokemon.getMaxHp())), 1), pokemon.getMaxHp())); + pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp())); user.scene.queueMessage(`${getPokemonNameWithAffix(pokemon)} was revived!`,0,true); if (user.scene.currentBattle.double && user.scene.getEnemyParty().length > 1) { @@ -7474,7 +7554,7 @@ export function initMoves() { .attr(OpponentHighHpPowerAttr, 120), new AttackMove(Moves.MAGMA_STORM, Type.FIRE, MoveCategory.SPECIAL, 100, 75, 5, -1, 0, 4) .attr(TrapAttr, BattlerTagType.MAGMA_STORM), - new StatusMove(Moves.DARK_VOID, Type.DARK, 50, 10, -1, 0, 4) + new StatusMove(Moves.DARK_VOID, Type.DARK, 80, 10, -1, 0, 4) //Accuracy from Generations 4-6 .attr(StatusEffectAttr, StatusEffect.SLEEP) .target(MoveTarget.ALL_NEAR_ENEMIES), new AttackMove(Moves.SEED_FLARE, Type.GRASS, MoveCategory.SPECIAL, 120, 85, 5, 40, 0, 4) @@ -8313,8 +8393,7 @@ export function initMoves() { .attr(HighCritAttr) .attr(BypassRedirectAttr), new AttackMove(Moves.JAW_LOCK, Type.DARK, MoveCategory.PHYSICAL, 80, 100, 10, -1, 0, 8) - .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, false, 1, 1, false, true) - .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, true, false, 1, 1, false, true) + .attr(JawLockAttr) .bitingMove(), new SelfStatusMove(Moves.STUFF_CHEEKS, Type.NORMAL, -1, 10, -1, 0, 8) // TODO: Stuff Cheeks should not be selectable when the user does not have a berry, see wiki .attr(EatBerryAttr) @@ -8759,7 +8838,10 @@ export function initMoves() { End Unused */ new AttackMove(Moves.TERA_BLAST, Type.NORMAL, MoveCategory.SPECIAL, 80, 100, 10, -1, 0, 9) .attr(TeraBlastCategoryAttr) - .unimplemented(), + .attr(TeraBlastTypeAttr) + .attr(TeraBlastPowerAttr) + .attr(StatChangeAttr, [ BattleStat.ATK, BattleStat.SPATK ], -1, true, (user, target, move) => user.isTerastallized() && user.isOfType(Type.STELLAR)) + .partial(), new SelfStatusMove(Moves.SILK_TRAP, Type.BUG, -1, 10, -1, 4, 9) .attr(ProtectAttr, BattlerTagType.SILK_TRAP), new AttackMove(Moves.AXE_KICK, Type.FIGHTING, MoveCategory.PHYSICAL, 120, 90, 10, 30, 0, 9) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index aa2c29a9725..da2892f8128 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -3317,6 +3317,28 @@ export function getStarterValueFriendshipCap(value: integer): integer { } } +/** +* Method to get the daily list of starters with Pokerus. +* @param scene {@linkcode BattleScene} used as part of RNG +* @returns A list of starters with Pokerus +*/ +export function getPokerusStarters(scene: BattleScene): PokemonSpecies[] { + const pokerusStarters: PokemonSpecies[] = []; + const date = new Date(); + const starterCount = 3; //for easy future adjustment! + date.setUTCHours(0, 0, 0, 0); + scene.executeWithSeedOffset(() => { + while (pokerusStarters.length < starterCount) { + const randomSpeciesId = parseInt(Utils.randSeedItem(Object.keys(speciesStarters)), 10); + const species = getPokemonSpecies(randomSpeciesId); + if (!pokerusStarters.includes(species)) { + pokerusStarters.push(species); + } + } + }, 0, date.getTime().toString()); + return pokerusStarters; +} + export const starterPassiveAbilities = { [Species.BULBASAUR]: Abilities.GRASSY_SURGE, [Species.CHARMANDER]: Abilities.BEAST_BOOST, diff --git a/src/data/terrain.ts b/src/data/terrain.ts index e29344ffea2..d4789078af7 100644 --- a/src/data/terrain.ts +++ b/src/data/terrain.ts @@ -59,7 +59,7 @@ export class Terrain { case TerrainType.PSYCHIC: if (!move.hasAttr(ProtectAttr)) { const priority = new Utils.IntegerHolder(move.priority); - applyAbAttrs(ChangeMovePriorityAbAttr, user, null, move, priority); + applyAbAttrs(ChangeMovePriorityAbAttr, user, null, false, move, priority); // Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain return priority.value > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded()); } diff --git a/src/enums/shop-cursor-target.ts b/src/enums/shop-cursor-target.ts new file mode 100644 index 00000000000..d2f72fed0d6 --- /dev/null +++ b/src/enums/shop-cursor-target.ts @@ -0,0 +1,13 @@ +/** + * Determines the cursor target when entering the shop phase. + */ +export enum ShopCursorTarget { + /** Cursor points to Reroll */ + REROLL, + /** Cursor points to Items */ + ITEMS, + /** Cursor points to Shop */ + SHOP, + /** Cursor points to Check Team */ + CHECK_TEAM +} diff --git a/src/field/arena.ts b/src/field/arena.ts index eb3770d61d5..2ef6ce7dab3 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -584,6 +584,10 @@ export class Arena { return this.getTagOnSide(tagType, ArenaTagSide.BOTH); } + hasTag(tagType: ArenaTagType) : boolean { + return !!this.getTag(tagType); + } + getTagOnSide(tagType: ArenaTagType | Constructor, side: ArenaTagSide): ArenaTag | undefined { return typeof(tagType) === "string" ? this.tags.find(t => t.tagType === tagType && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side)) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 6a445a83b4e..030297a2126 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -694,7 +694,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { break; } } - applyAbAttrs(IgnoreOpponentStatChangesAbAttr, opponent, null, statLevel); + applyAbAttrs(IgnoreOpponentStatChangesAbAttr, opponent, null, false, statLevel); if (move) { applyMoveAttrs(IgnoreOpponentStatChangesAttr, this, opponent, move, statLevel); } @@ -978,12 +978,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // this.scene potentially can be undefined for a fainted pokemon in doubles // use optional chaining to avoid runtime errors - if (forDefend && (this.getTag(GroundedTag) || this.scene?.arena.getTag(ArenaTagType.GRAVITY))) { - const flyingIndex = types.indexOf(Type.FLYING); - if (flyingIndex > -1) { - types.splice(flyingIndex, 1); - } - } if (!types.length) { // become UNKNOWN if no types are present types.push(Type.UNKNOWN); @@ -1128,10 +1122,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const suppressed = new Utils.BooleanHolder(false); this.scene.getField(true).filter(p => p !== this).map(p => { if (p.getAbility().hasAttr(SuppressFieldAbilitiesAbAttr) && p.canApplyAbility()) { - p.getAbility().getAttrs(SuppressFieldAbilitiesAbAttr).map(a => a.apply(this, false, suppressed, [ability])); + p.getAbility().getAttrs(SuppressFieldAbilitiesAbAttr).map(a => a.apply(this, false, false, suppressed, [ability])); } if (p.getPassiveAbility().hasAttr(SuppressFieldAbilitiesAbAttr) && p.canApplyAbility(true)) { - p.getPassiveAbility().getAttrs(SuppressFieldAbilitiesAbAttr).map(a => a.apply(this, true, suppressed, [ability])); + p.getPassiveAbility().getAttrs(SuppressFieldAbilitiesAbAttr).map(a => a.apply(this, true, false, suppressed, [ability])); } }); if (suppressed.value) { @@ -1183,7 +1177,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getWeight(): number { const weight = new Utils.NumberHolder(this.species.weight); // This will trigger the ability overlay so only call this function when necessary - applyAbAttrs(WeightMultiplierAbAttr, this, null, weight); + applyAbAttrs(WeightMultiplierAbAttr, this, null, false, weight); return weight.value; } @@ -1243,10 +1237,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const cancelled = new Utils.BooleanHolder(false); applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier); if (!typeless && !ignoreAbility) { - applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, typeMultiplier, true); + applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, true, typeMultiplier); } if (!cancelled.value && !ignoreAbility) { - applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, typeMultiplier, true); + applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, true, typeMultiplier); } return (!cancelled.value ? Number(typeMultiplier.value) : 0) as TypeDamageMultiplier; @@ -1272,12 +1266,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.isTerastallized() ? 2 : 1; } const types = this.getTypes(true, true); + const arena = this.scene.arena; + + // Handle flying v ground type immunity without removing flying type so effective types are still effective + // Related to https://github.com/pagefaultgames/pokerogue/issues/524 + if (moveType === Type.GROUND && (this.isGrounded() || arena.hasTag(ArenaTagType.GRAVITY))) { + const flyingIndex = types.indexOf(Type.FLYING); + if (flyingIndex > -1) { + types.splice(flyingIndex, 1); + } + } let multiplier = types.map(defType => { if (source) { const ignoreImmunity = new Utils.BooleanHolder(false); if (source.isActive(true) && source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr)) { - applyAbAttrs(IgnoreTypeImmunityAbAttr, source, ignoreImmunity, moveType, defType); + applyAbAttrs(IgnoreTypeImmunityAbAttr, source, ignoreImmunity, false, moveType, defType); } if (ignoreImmunity.value) { return 1; @@ -1293,7 +1297,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { }).reduce((acc, cur) => acc * cur, 1) as TypeDamageMultiplier; // Handle strong winds lowering effectiveness of types super effective against pure flying - if (!ignoreStrongWinds && this.scene.arena.weather?.weatherType === WeatherType.STRONG_WINDS && !this.scene.arena.weather.isEffectSuppressed(this.scene) && this.isOfType(Type.FLYING) && getTypeDamageMultiplier(moveType, Type.FLYING) === 2) { + if (!ignoreStrongWinds && arena.weather?.weatherType === WeatherType.STRONG_WINDS && !arena.weather.isEffectSuppressed(this.scene) && this.isOfType(Type.FLYING) && getTypeDamageMultiplier(moveType, Type.FLYING) === 2) { multiplier /= 2; if (!simulated) { this.scene.queueMessage(i18next.t("weather:strongWindsEffectMessage")); @@ -1918,9 +1922,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const userAccuracyLevel = new Utils.IntegerHolder(this.summonData.battleStats[BattleStat.ACC]); const targetEvasionLevel = new Utils.IntegerHolder(target.summonData.battleStats[BattleStat.EVA]); - applyAbAttrs(IgnoreOpponentStatChangesAbAttr, target, null, userAccuracyLevel); - applyAbAttrs(IgnoreOpponentStatChangesAbAttr, this, null, targetEvasionLevel); - applyAbAttrs(IgnoreOpponentEvasionAbAttr, this, null, targetEvasionLevel); + applyAbAttrs(IgnoreOpponentStatChangesAbAttr, target, null, false, userAccuracyLevel); + applyAbAttrs(IgnoreOpponentStatChangesAbAttr, this, null, false, targetEvasionLevel); + applyAbAttrs(IgnoreOpponentEvasionAbAttr, this, null, false, targetEvasionLevel); applyMoveAttrs(IgnoreOpponentStatChangesAttr, this, target, sourceMove, targetEvasionLevel); this.scene.applyModifiers(TempBattleStatBoosterModifier, this.isPlayer(), TempBattleStat.ACC, userAccuracyLevel); @@ -1935,7 +1939,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { : 3 / (3 + Math.min(targetEvasionLevel.value - userAccuracyLevel.value, 6)); } - applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, this, BattleStat.ACC, accuracyMultiplier, sourceMove); + applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, this, BattleStat.ACC, accuracyMultiplier, false, sourceMove); const evasionMultiplier = new Utils.NumberHolder(1); applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, target, BattleStat.EVA, evasionMultiplier); @@ -1945,6 +1949,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return accuracyMultiplier.value; } + /** + * Apply the results of a move to this pokemon + * @param {Pokemon} source The pokemon using the move + * @param {PokemonMove} battlerMove The move being used + * @returns {HitResult} The result of the attack + */ apply(source: Pokemon, move: Move): HitResult { let result: HitResult; const damage = new Utils.NumberHolder(0); @@ -1980,12 +1990,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const sourceTeraType = source.getTeraType(); if (!typeless) { - applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, typeMultiplier); + applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, false, typeMultiplier); applyMoveAttrs(NeutralDamageAgainstFlyingTypeMultiplierAttr, source, this, move, typeMultiplier); } if (!cancelled.value) { - applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, typeMultiplier); - defendingSidePlayField.forEach((p) => applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, move, cancelled, typeMultiplier)); + applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, false, typeMultiplier); + defendingSidePlayField.forEach((p) => applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, move, cancelled, false, typeMultiplier)); } if (cancelled.value) { @@ -2008,7 +2018,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const critOnly = new Utils.BooleanHolder(false); const critAlways = source.getTag(BattlerTagType.ALWAYS_CRIT); applyMoveAttrs(CritOnlyAttr, source, this, move, critOnly); - applyAbAttrs(ConditionalCritAbAttr, source, null, critOnly, this, move); + applyAbAttrs(ConditionalCritAbAttr, source, null, false, critOnly, this, move); if (critOnly.value || critAlways) { isCritical = true; } else { @@ -2018,7 +2028,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.scene.applyModifiers(TempBattleStatBoosterModifier, source.isPlayer(), TempBattleStat.CRIT, critLevel); const bonusCrit = new Utils.BooleanHolder(false); //@ts-ignore - if (applyAbAttrs(BonusCritAbAttr, source, null, bonusCrit)) { // TODO: resolve ts-ignore. This is a promise. Checking a promise is bogus. + if (applyAbAttrs(BonusCritAbAttr, source, null, false, bonusCrit)) { // TODO: resolve ts-ignore. This is a promise. Checking a promise is bogus. if (bonusCrit.value) { critLevel.value += 1; } @@ -2036,7 +2046,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (isCritical) { const noCritTag = this.scene.arena.getTagOnSide(NoCritTag, defendingSide); const blockCrit = new Utils.BooleanHolder(false); - applyAbAttrs(BlockCritAbAttr, this, null, blockCrit); + applyAbAttrs(BlockCritAbAttr, this, null, false, blockCrit); if (noCritTag || blockCrit.value) { isCritical = false; } @@ -2044,7 +2054,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const sourceAtk = new Utils.IntegerHolder(source.getBattleStat(isPhysical ? Stat.ATK : Stat.SPATK, this, undefined, isCritical)); const targetDef = new Utils.IntegerHolder(this.getBattleStat(isPhysical ? Stat.DEF : Stat.SPDEF, source, move, isCritical)); const criticalMultiplier = new Utils.NumberHolder(isCritical ? 1.5 : 1); - applyAbAttrs(MultCritAbAttr, source, null, criticalMultiplier); + applyAbAttrs(MultCritAbAttr, source, null, false, criticalMultiplier); const screenMultiplier = new Utils.NumberHolder(1); if (!isCritical) { this.scene.arena.applyTagsForSide(WeakenMoveScreenTag, defendingSide, move.category, this.scene.currentBattle.double, screenMultiplier); @@ -2059,7 +2069,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { stabMultiplier.value += 0.5; } - applyAbAttrs(StabBoostAbAttr, source, null, stabMultiplier); + applyAbAttrs(StabBoostAbAttr, source, null, false, stabMultiplier); if (sourceTeraType !== Type.UNKNOWN && matchesSourceType) { stabMultiplier.value = Math.min(stabMultiplier.value + 0.5, 2.25); @@ -2077,12 +2087,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { numTargets = effectPhase.getTargets().length; } const twoStrikeMultiplier = new Utils.NumberHolder(1); - applyPreAttackAbAttrs(AddSecondStrikeAbAttr, source, this, move, numTargets, new Utils.IntegerHolder(0), twoStrikeMultiplier); + applyPreAttackAbAttrs(AddSecondStrikeAbAttr, source, this, move, false, numTargets, new Utils.IntegerHolder(0), twoStrikeMultiplier); if (!isTypeImmune) { const levelMultiplier = (2 * source.level / 5 + 2); const randomMultiplier = ((this.scene.randBattleSeedInt(16) + 85) / 100); - damage.value = Math.ceil((((levelMultiplier * power * sourceAtk.value / targetDef.value) / 50) + 2) + damage.value = Utils.toDmgValue((((levelMultiplier * power * sourceAtk.value / targetDef.value) / 50) + 2) * stabMultiplier.value * typeMultiplier.value * arenaAttackTypeMultiplier.value @@ -2096,14 +2106,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) { if (!move.hasAttr(BypassBurnDamageReductionAttr)) { const burnDamageReductionCancelled = new Utils.BooleanHolder(false); - applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled); + applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled, false); if (!burnDamageReductionCancelled.value) { - damage.value = Math.floor(damage.value / 2); + damage.value = Utils.toDmgValue(damage.value / 2); } } } - applyPreAttackAbAttrs(DamageBoostAbAttr, source, this, move, damage); + applyPreAttackAbAttrs(DamageBoostAbAttr, source, this, move, false, damage); /** * For each {@link HitsTagAttr} the move has, doubles the damage of the move if: @@ -2119,7 +2129,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } if (this.scene.arena.terrain?.terrainType === TerrainType.MISTY && this.isGrounded() && move.type === Type.DRAGON) { - damage.value = Math.floor(damage.value / 2); + damage.value = Utils.toDmgValue(damage.value / 2); } const fixedDamage = new Utils.IntegerHolder(0); @@ -2161,7 +2171,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.scene.applyModifiers(EnemyDamageReducerModifier, false, damage); } - applyPreDefendAbAttrs(ReceivedMoveDamageMultiplierAbAttr, this, source, move, cancelled, damage); + applyPreDefendAbAttrs(ReceivedMoveDamageMultiplierAbAttr, this, source, move, cancelled, false, damage); } // This attribute may modify damage arbitrarily, so be careful about changing its order of application. @@ -2174,7 +2184,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (damage.value) { if (this.isFullHp()) { - applyPreDefendAbAttrs(PreDefendFullHpEndureAbAttr, this, source, move, cancelled, damage); + applyPreDefendAbAttrs(PreDefendFullHpEndureAbAttr, this, source, move, cancelled, false, damage); } else if (!this.isPlayer() && damage.value >= this.hp) { this.scene.applyModifiers(EnemyEndureChanceModifier, false, this); } @@ -2241,11 +2251,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { break; case MoveCategory.STATUS: if (!typeless) { - applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, typeMultiplier); + applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, false, typeMultiplier); } if (!cancelled.value) { - applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, typeMultiplier); - defendingSidePlayField.forEach((p) => applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, move, cancelled, typeMultiplier)); + applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, false, typeMultiplier); + defendingSidePlayField.forEach((p) => applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, move, cancelled, false, typeMultiplier)); } if (!typeMultiplier.value) { this.scene.queueMessage(i18next.t("battle:hitResultNoEffect", { pokemonName: getPokemonNameWithAffix(this) })); @@ -2337,6 +2347,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return maxForms.includes(this.getFormKey()) || (!!this.getFusionFormKey() && maxForms.includes(this.getFusionFormKey()!)); } + canAddTag(tagType: BattlerTagType): boolean { + if (this.getTag(tagType)) { + return false; + } + + const stubTag = new BattlerTag(tagType, 0, 0); + + const cancelled = new Utils.BooleanHolder(false); + applyPreApplyBattlerTagAbAttrs(BattlerTagImmunityAbAttr, this, stubTag, cancelled, true); + + const userField = this.getAlliedField(); + userField.forEach(pokemon => applyPreApplyBattlerTagAbAttrs(UserFieldBattlerTagImmunityAbAttr, pokemon, stubTag, cancelled, true)); + + return !cancelled.value; + } + addTag(tagType: BattlerTagType, turnCount: integer = 0, sourceMove?: Moves, sourceId?: integer): boolean { const existingTag = this.getTag(tagType); if (existingTag) { @@ -2723,7 +2749,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Check if the source Pokemon has an ability that cancels the Poison/Toxic immunity const cancelImmunity = new Utils.BooleanHolder(false); if (sourcePokemon) { - applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, cancelImmunity, effect, defType); + applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, cancelImmunity, false, effect, defType); if (cancelImmunity.value) { return false; } @@ -2795,7 +2821,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (effect === StatusEffect.SLEEP) { statusCureTurn = new Utils.IntegerHolder(this.randSeedIntRange(2, 4)); - applyAbAttrs(ReduceStatusEffectDurationAbAttr, this, null, effect, statusCureTurn); + applyAbAttrs(ReduceStatusEffectDurationAbAttr, this, null, false, effect, statusCureTurn); this.setFrameRate(4); @@ -3429,7 +3455,7 @@ export class PlayerPokemon extends Pokemon { pokemon.resetTurnData(); pokemon.resetStatus(); - pokemon.heal(Math.min(Math.max(Math.ceil(Math.floor(0.5 * pokemon.getMaxHp())), 1), pokemon.getMaxHp())); + pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp())); this.scene.queueMessage(`${pokemon.name} was revived!`,0,true); if (this.scene.currentBattle.double && this.scene.getParty().length > 1) { @@ -4356,7 +4382,7 @@ export class PokemonMove { } getMovePp(): integer { - return this.getMove().pp + this.ppUp * Math.max(Math.floor(this.getMove().pp / 5), 1); + return this.getMove().pp + this.ppUp * Utils.toDmgValue(this.getMove().pp / 5); } getPpRatio(): number { diff --git a/src/locales/ca_ES/ability-trigger.ts b/src/locales/ca_ES/ability-trigger.ts index 2bdd17baa56..0b7fe8bd0bc 100644 --- a/src/locales/ca_ES/ability-trigger.ts +++ b/src/locales/ca_ES/ability-trigger.ts @@ -47,6 +47,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postFaintHpDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postSummonPressure": "{{pokemonNameWithAffix}} is exerting its Pressure!", + "weatherEffectDisappeared": "The effects of the weather disappeared.", "postSummonMoldBreaker": "{{pokemonNameWithAffix}} breaks the mold!", "postSummonAnticipation": "{{pokemonNameWithAffix}} shuddered!", "postSummonTurboblaze": "{{pokemonNameWithAffix}} is radiating a blazing aura!", diff --git a/src/locales/ca_ES/battle-scene.ts b/src/locales/ca_ES/battle-scene.ts new file mode 100644 index 00000000000..573e1791724 --- /dev/null +++ b/src/locales/ca_ES/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "₽{{formattedMoney}}" +} as const; diff --git a/src/locales/ca_ES/config.ts b/src/locales/ca_ES/config.ts index 831ab5d99f5..36aee87fc75 100644 --- a/src/locales/ca_ES/config.ts +++ b/src/locales/ca_ES/config.ts @@ -6,6 +6,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const caESConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/ca_ES/settings.ts b/src/locales/ca_ES/settings.ts index 491bfa4a481..9c0b3f36365 100644 --- a/src/locales/ca_ES/settings.ts +++ b/src/locales/ca_ES/settings.ts @@ -96,5 +96,10 @@ export const settings: SimpleTranslationEntries = { "controller": "Controller", "gamepadSupport": "Gamepad Support", "showBgmBar": "Show Music Names", - "shopOverlayOpacity": "Shop Overlay Opacity" + "shopOverlayOpacity": "Shop Overlay Opacity", + "shopCursorTarget": "Shop Cursor Target", + "items": "Items", + "reroll": "Reroll", + "shop": "Shop", + "checkTeam": "Check Team" } as const; diff --git a/src/locales/de/ability-trigger.ts b/src/locales/de/ability-trigger.ts index 72023a842b3..9e4ef9df6ed 100644 --- a/src/locales/de/ability-trigger.ts +++ b/src/locales/de/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{abilityName}} von {{pokemonNameWithAffix}} schadet seinem Angreifer!", "postFaintHpDamage": "{{abilityName}} von {{pokemonNameWithAffix}} schadet seinem Angreifer!", "postSummonPressure": "{{pokemonNameWithAffix}} setzt Gegner mit Erzwinger unter Druck!", + "weatherEffectDisappeared": "Jegliche wetterbedingten Effekte wurden aufgehoben!", "postSummonMoldBreaker": "{{pokemonNameWithAffix}} gelingt es, gegnerische Fähigkeiten zu überbrücken!", "postSummonAnticipation": "{{pokemonNameWithAffix}} erschaudert!", "postSummonTurboblaze": "{{pokemonNameWithAffix}} strahlt eine lodernde Aura aus!", diff --git a/src/locales/de/battle-scene.ts b/src/locales/de/battle-scene.ts new file mode 100644 index 00000000000..bfa96445f6c --- /dev/null +++ b/src/locales/de/battle-scene.ts @@ -0,0 +1,6 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "{{formattedMoney}} ₽" + +} as const; diff --git a/src/locales/de/battler-tags.ts b/src/locales/de/battler-tags.ts index 27d5f14c597..da0150836b0 100644 --- a/src/locales/de/battler-tags.ts +++ b/src/locales/de/battler-tags.ts @@ -69,5 +69,5 @@ export const battlerTags: SimpleTranslationEntries = { "saltCuredLapse": "{{pokemonNameWithAffix}} wurde durch {{moveName}} verletzt!", "cursedOnAdd": "{{pokemonNameWithAffix}} nimmt einen Teil seiner KP und legt einen Fluch auf {{pokemonName}}!", "cursedLapse": "{{pokemonNameWithAffix}} wurde durch den Fluch verletzt!", - "stockpilingOnAdd": "{{pokemonNameWithAffix}} stockpiled {{stockpiledCount}}!", + "stockpilingOnAdd": "{{pokemonNameWithAffix}} hortet {{stockpiledCount}}!", } as const; diff --git a/src/locales/de/config.ts b/src/locales/de/config.ts index d0779c9eec4..080c9ecc598 100644 --- a/src/locales/de/config.ts +++ b/src/locales/de/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const deConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/de/settings.ts b/src/locales/de/settings.ts index 7d4523c8cbd..3942e470e3f 100644 --- a/src/locales/de/settings.ts +++ b/src/locales/de/settings.ts @@ -99,4 +99,9 @@ export const settings: SimpleTranslationEntries = { "showBgmBar": "Musiknamen anzeigen", "moveTouchControls": "Bewegung Touch Steuerung", "shopOverlayOpacity": "Shop Overlay Deckkraft", + "shopCursorTarget": "Shop Cursor Target", + "items": "Items", + "reroll": "Reroll", + "shop": "Shop", + "checkTeam": "Check Team" } as const; diff --git a/src/locales/de/starter-select-ui-handler.ts b/src/locales/de/starter-select-ui-handler.ts index 284152bbd33..c96af29a3c0 100644 --- a/src/locales/de/starter-select-ui-handler.ts +++ b/src/locales/de/starter-select-ui-handler.ts @@ -7,7 +7,7 @@ import { SimpleTranslationEntries } from "#app/interfaces/locales"; */ export const starterSelectUiHandler: SimpleTranslationEntries = { "confirmStartTeam": "Mit diesen Pokémon losziehen?", - "confirmExit": "Do you want to exit?", + "confirmExit": "Willst du zurück?", "invalidParty": "Das ist kein gültiges Team!", "gen1": "I", "gen2": "II", @@ -28,8 +28,8 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "toggleIVs": "DVs anzeigen/verbergen", "manageMoves": "Attacken ändern", "manageNature": "Wesen ändern", - "addToFavorites": "Add to Favorites", - "removeFromFavorites": "Remove from Favorites", + "addToFavorites": "Zu Favoriten hinzufügen", + "removeFromFavorites": "Von Favoriten entfernen", "useCandies": "Bonbons verwenden", "selectNature": "Wähle das neue Wesen.", "selectMoveSwapOut": "Wähle die zu ersetzende Attacke.", diff --git a/src/locales/en/ability-trigger.ts b/src/locales/en/ability-trigger.ts index 035fe8371be..2a0e0df255a 100644 --- a/src/locales/en/ability-trigger.ts +++ b/src/locales/en/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postFaintHpDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postSummonPressure": "{{pokemonNameWithAffix}} is exerting its Pressure!", + "weatherEffectDisappeared": "The effects of the weather disappeared.", "postSummonMoldBreaker": "{{pokemonNameWithAffix}} breaks the mold!", "postSummonAnticipation": "{{pokemonNameWithAffix}} shuddered!", "postSummonTurboblaze": "{{pokemonNameWithAffix}} is radiating a blazing aura!", diff --git a/src/locales/en/battle-scene.ts b/src/locales/en/battle-scene.ts new file mode 100644 index 00000000000..573e1791724 --- /dev/null +++ b/src/locales/en/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "₽{{formattedMoney}}" +} as const; diff --git a/src/locales/en/config.ts b/src/locales/en/config.ts index a98dd750fbe..d456b0540cc 100644 --- a/src/locales/en/config.ts +++ b/src/locales/en/config.ts @@ -6,6 +6,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const enConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/en/settings.ts b/src/locales/en/settings.ts index c63f9de6049..ad2ea914dc9 100644 --- a/src/locales/en/settings.ts +++ b/src/locales/en/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "Gamepad Support", "showBgmBar": "Show Music Names", "moveTouchControls": "Move Touch Controls", - "shopOverlayOpacity": "Shop Overlay Opacity" + "shopOverlayOpacity": "Shop Overlay Opacity", + "shopCursorTarget": "Shop Cursor Target", + "items": "Items", + "reroll": "Reroll", + "shop": "Shop", + "checkTeam": "Check Team" } as const; diff --git a/src/locales/es/ability-trigger.ts b/src/locales/es/ability-trigger.ts index 60bc186e99d..99ebfe3bd4c 100644 --- a/src/locales/es/ability-trigger.ts +++ b/src/locales/es/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postFaintHpDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postSummonPressure": "{{pokemonNameWithAffix}} is exerting its Pressure!", + "weatherEffectDisappeared": "El tiempo atmosférico ya no ejerce ninguna influencia.", "postSummonMoldBreaker": "{{pokemonNameWithAffix}} breaks the mold!", "postSummonAnticipation": "{{pokemonNameWithAffix}} shuddered!", "postSummonTurboblaze": "{{pokemonNameWithAffix}} is radiating a blazing aura!", diff --git a/src/locales/es/battle-scene.ts b/src/locales/es/battle-scene.ts new file mode 100644 index 00000000000..995ca744302 --- /dev/null +++ b/src/locales/es/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "{{formattedMoney}} ₽" +} as const; diff --git a/src/locales/es/config.ts b/src/locales/es/config.ts index ce9ad19aac3..6c038188da2 100644 --- a/src/locales/es/config.ts +++ b/src/locales/es/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const esConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/es/settings.ts b/src/locales/es/settings.ts index c7f723fe80c..fbc56d92fe5 100644 --- a/src/locales/es/settings.ts +++ b/src/locales/es/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "Gamepad Support", "showBgmBar": "Show Music Names", "moveTouchControls": "Move Touch Controls", - "shopOverlayOpacity": "Opacidad de la fase de compra" + "shopOverlayOpacity": "Opacidad de la fase de compra", + "shopCursorTarget": "Shop Cursor Target", + "items": "Items", + "reroll": "Reroll", + "shop": "Shop", + "checkTeam": "Check Team" } as const; diff --git a/src/locales/fr/ability-trigger.ts b/src/locales/fr/ability-trigger.ts index cd077993b4e..92e02b82414 100644 --- a/src/locales/fr/ability-trigger.ts +++ b/src/locales/fr/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}} est blessé\npar son talent {{abilityName}} !", "postFaintHpDamage": "{{pokemonNameWithAffix}} est blessé\npar son talent {{abilityName}} !", "postSummonPressure": "{{pokemonNameWithAffix}}\naugmente la pression !", + "weatherEffectDisappeared": "Les effets de la météo se dissipent !", "postSummonMoldBreaker": "{{pokemonNameWithAffix}}\nbrise le moule !", "postSummonAnticipation": "{{pokemonNameWithAffix}}\nest tout tremblant !", "postSummonTurboblaze": "{{pokemonNameWithAffix}} dégage\nune aura de flammes incandescentes !", diff --git a/src/locales/fr/battle-scene.ts b/src/locales/fr/battle-scene.ts new file mode 100644 index 00000000000..995ca744302 --- /dev/null +++ b/src/locales/fr/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "{{formattedMoney}} ₽" +} as const; diff --git a/src/locales/fr/config.ts b/src/locales/fr/config.ts index 246ae9a073f..a2ab67eefe0 100644 --- a/src/locales/fr/config.ts +++ b/src/locales/fr/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const frConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/fr/settings.ts b/src/locales/fr/settings.ts index 95246ccb7d0..d5e4047bb12 100644 --- a/src/locales/fr/settings.ts +++ b/src/locales/fr/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "Gamepad Support", "showBgmBar": "Titre de la musique", "moveTouchControls": "Déplacer les contrôles tactiles", - "shopOverlayOpacity": "Opacité boutique" + "shopOverlayOpacity": "Opacité boutique", + "shopCursorTarget": "Choix après relance", + "items": "Obj. gratuits", + "reroll": "Relance", + "shop": "Boutique", + "checkTeam": "Équipe" } as const; diff --git a/src/locales/it/ability-trigger.ts b/src/locales/it/ability-trigger.ts index 95db5cbf26c..6ac5e76ee3e 100644 --- a/src/locales/it/ability-trigger.ts +++ b/src/locales/it/ability-trigger.ts @@ -25,39 +25,40 @@ export const abilityTriggers: SimpleTranslationEntries = { "postAttackStealHeldItem": "{{pokemonNameWithAffix}} ruba\n{{stolenItemType}} di {{defenderName}}!", "postDefendStealHeldItem": "{{pokemonNameWithAffix}} ruba\n{{stolenItemType}} di {{attackerName}}!", "copyFaintedAllyAbility": "L'abilità {{abilityName}} di {{pokemonNameWithAffix}} è passata all'alleato!", - "intimidateImmunity": "{{pokemonNameWithAffix}}'s {{abilityName}} prevented it from being Intimidated!", - "postSummonAllyHeal": "{{pokemonNameWithAffix}} drank down all the\nmatcha that {{pokemonName}} made!", - "postSummonClearAllyStats": "{{pokemonNameWithAffix}}'s stat changes\nwere removed!", - "postSummonTransform": "{{pokemonNameWithAffix}} transformed\ninto {{targetName}}!", - "protectStat": "{{pokemonNameWithAffix}}'s {{abilityName}}\nprevents lowering its {{statName}}!", - "statusEffectImmunityWithName": "{{pokemonNameWithAffix}}'s {{abilityName}}\nprevents {{statusEffectName}}!", - "statusEffectImmunity": "{{pokemonNameWithAffix}}'s {{abilityName}}\nprevents status problems!", - "battlerTagImmunity": "{{pokemonNameWithAffix}}'s {{abilityName}}\nprevents {{battlerTagName}}!", - "forewarn": "{{pokemonNameWithAffix}} was forewarned about {{moveName}}!", - "frisk": "{{pokemonNameWithAffix}} frisked {{opponentName}}'s {{opponentAbilityName}}!", - "postWeatherLapseHeal": "{{pokemonNameWithAffix}}'s {{abilityName}}\nrestored its HP a little!", - "postWeatherLapseDamage": "{{pokemonNameWithAffix}} is hurt\nby its {{abilityName}}!", - "postTurnLootCreateEatenBerry": "{{pokemonNameWithAffix}} harvested one {{berryName}}!", - "postTurnHeal": "{{pokemonNameWithAffix}}'s {{abilityName}}\nrestored its HP a little!", - "fetchBall": "{{pokemonNameWithAffix}} found a\n{{pokeballName}}!", - "healFromBerryUse": "{{pokemonNameWithAffix}}'s {{abilityName}}\nrestored its HP!", - "arenaTrap": "{{pokemonNameWithAffix}}'s {{abilityName}}\nprevents switching!", - "postBattleLoot": "{{pokemonNameWithAffix}} picked up\n{{itemName}}!", - "postFaintContactDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", - "postFaintHpDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", - "postSummonPressure": "{{pokemonNameWithAffix}} is exerting its Pressure!", - "postSummonMoldBreaker": "{{pokemonNameWithAffix}} breaks the mold!", - "postSummonAnticipation": "{{pokemonNameWithAffix}} shuddered!", - "postSummonTurboblaze": "{{pokemonNameWithAffix}} is radiating a blazing aura!", - "postSummonTeravolt": "{{pokemonNameWithAffix}} is radiating a bursting aura!", - "postSummonDarkAura": "{{pokemonNameWithAffix}} is radiating a Dark Aura!", - "postSummonFairyAura": "{{pokemonNameWithAffix}} is radiating a Fairy Aura!", - "postSummonNeutralizingGas": "{{pokemonNameWithAffix}}'s Neutralizing Gas filled the area!", - "postSummonAsOneGlastrier": "{{pokemonNameWithAffix}} has two Abilities!", - "postSummonAsOneSpectrier": "{{pokemonNameWithAffix}} has two Abilities!", - "postSummonVesselOfRuin": "{{pokemonNameWithAffix}}'s Vessel of Ruin lowered the {{statName}}\nof all surrounding Pokémon!", - "postSummonSwordOfRuin": "{{pokemonNameWithAffix}}'s Sword of Ruin lowered the {{statName}}\nof all surrounding Pokémon!", - "postSummonTabletsOfRuin": "{{pokemonNameWithAffix}}'s Tablets of Ruin lowered the {{statName}}\nof all surrounding Pokémon!", - "postSummonBeadsOfRuin": "{{pokemonNameWithAffix}}'s Beads of Ruin lowered the {{statName}}\nof all surrounding Pokémon!", + "intimidateImmunity": "{{abilityName}} impedisce a {{pokemonNameWithAffix}} di\nessere intimidito!", + "postSummonAllyHeal": "{{pokemonNameWithAffix}} beve il\ntè che {{pokemonName}} gli ha preparato!", + "postSummonClearAllyStats": "Le statistiche di {{pokemonNameWithAffix}}\ntornano alla normalità!", + "postSummonTransform": "{{pokemonNameWithAffix}} assume le sembianze\ndi {{targetName}}!", + "protectStat": "{{abilityName}} di {{pokemonNameWithAffix}}\npreviene la riduzione del/della suo/a {{statName}}!", + "statusEffectImmunityWithName": "{{abilityName}} di {{pokemonNameWithAffix}}\nnon gli fa subire il/lo/la {{statusEffectName}}!", + "statusEffectImmunity": "{{abilityName}} di {{pokemonNameWithAffix}}\npreviene i problemi di stato!", + "battlerTagImmunity": "{{abilityName}} di {{pokemonNameWithAffix}}\npreviene {{battlerTagName}}!", + "forewarn": "{{pokemonNameWithAffix}} è stato messo in guardia da {{moveName}}!", + "frisk": "{{pokemonNameWithAffix}} perquisice {{opponentName}}\ne trova la sua abilità, {{opponentAbilityName}}!", + "postWeatherLapseHeal": "{{pokemonNameWithAffix}} recupera alcuni PS\ncon {{abilityName}}!", + "postWeatherLapseDamage": "{{pokemonNameWithAffix}} subisce danni\na causa della sua abilità, {{abilityName}}!", + "postTurnLootCreateEatenBerry": "{{pokemonNameWithAffix}} raccoglie una {{berryName}}!", + "postTurnHeal": "{{pokemonNameWithAffix}} recupera alcuni PS\ncon {{abilityName}}!", + "fetchBall": "{{pokemonNameWithAffix}} ha trovato una\n{{pokeballName}}!", + "healFromBerryUse": "{{abilityName}} di {{pokemonNameWithAffix}}\nristabilisce parte dei PS!", + "arenaTrap": "L’abilità {{abilityName}} di {{pokemonNameWithAffix}}\nimpedisce la sostituzione!", + "postBattleLoot": "{{pokemonNameWithAffix}} ha raccolto\nil/l'/lo/la {{itemName}}!", + "postFaintContactDamage": "{{abilityName}} di {{pokemonNameWithAffix}}\nferisce il Pokémon che lo ha attaccato!", + "postFaintHpDamage": "{{abilityName}} di {{pokemonNameWithAffix}}\nferisce il Pokémon che lo ha attaccato!", + "postSummonPressure": "{{pokemonNameWithAffix}} fa pressione!", + "weatherEffectDisappeared": "Le condizioni atmosferiche non hanno alcun effetto.", + "postSummonMoldBreaker": "{{pokemonNameWithAffix}} ha l’abilità Rompiforma!", + "postSummonAnticipation": "{{pokemonNameWithAffix}} rabbrividisce!", + "postSummonTurboblaze": "{{pokemonNameWithAffix}} emana un’aura infuocata!", + "postSummonTeravolt": "{{pokemonNameWithAffix}} emana un’aura repulsiva!", + "postSummonDarkAura": "L’abilità Auratetra di {{pokemonNameWithAffix}} è attiva.", + "postSummonFairyAura": "L’abilità Aurafolletto di {{pokemonNameWithAffix}} è attiva.", + "postSummonNeutralizingGas": "Il Gas Reagente di {{pokemonNameWithAffix}}\nsi diffonde tutt’intorno!", + "postSummonAsOneGlastrier": "{{pokemonNameWithAffix}} ha due abilità!", + "postSummonAsOneSpectrier": "{{pokemonNameWithAffix}} ha due abilità!", + "postSummonVesselOfRuin": "La/l'{{statName}} dei Pokémon intorno si indebolisce a causa\ndell'abilità Vaso Nefasto di {{pokemonNameWithAffix}}!", + "postSummonSwordOfRuin": "La/l'{{statName}} dei Pokémon intorno si indebolisce a causa\ndell'abilità Spada Nefasta di {{pokemonNameWithAffix}}!", + "postSummonTabletsOfRuin": "La/l'{{statName}} dei Pokémon intorno si indebolisce a causa\ndell'abilità Amuleto Nefasto di {{pokemonNameWithAffix}}!", + "postSummonBeadsOfRuin": "La/l'{{statName}} dei Pokémon intorno si indebolisce a causa\ndell'abilità Monile Nefasto di {{pokemonNameWithAffix}}!", "preventBerryUse": "{{pokemonNameWithAffix}} non riesce a\nmangiare le bacche per l'agitazione!", } as const; diff --git a/src/locales/it/achv.ts b/src/locales/it/achv.ts index 91222b81579..756d95e6431 100644 --- a/src/locales/it/achv.ts +++ b/src/locales/it/achv.ts @@ -170,8 +170,8 @@ export const PGMachv: AchievementTranslationEntries = { description: "Vinci in modalità classica", }, "UNEVOLVED_CLASSIC_VICTORY": { - name: "Bring Your Child To Work Day", - description: "Beat the game in Classic Mode with at least one unevolved party member." + name: "Alternanza scuola-lavoro", + description: "Completa la modalità classica con almeno un membro della squadra non evoluto completamente." }, "MONO_GEN_ONE": { @@ -269,8 +269,8 @@ export const PGMachv: AchievementTranslationEntries = { name: "Follettini e follettine", }, "FRESH_START": { - name: "First Try!", - description: "Complete the Fresh Start challenge." + name: "Buona la prima!", + description: "Completa la modalità sfida 'Un nuovo inizio'." } } as const; diff --git a/src/locales/it/battle-scene.ts b/src/locales/it/battle-scene.ts new file mode 100644 index 00000000000..995ca744302 --- /dev/null +++ b/src/locales/it/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "{{formattedMoney}} ₽" +} as const; diff --git a/src/locales/it/battle.ts b/src/locales/it/battle.ts index bd7227eacb6..347a9968e96 100644 --- a/src/locales/it/battle.ts +++ b/src/locales/it/battle.ts @@ -74,22 +74,22 @@ export const battle: SimpleTranslationEntries = { "fainted": "{{pokemonNameWithAffix}} non è più in\ngrado di combattere!", "statsAnd": "e", "stats": "statistiche", - "statRose_one": "{{pokemonNameWithAffix}}'s {{stats}} è aumentato/a!", - "statRose_other": "{{pokemonNameWithAffix}}'s {{stats}} rose!", - "statSharplyRose_one": "{{pokemonNameWithAffix}}'s {{stats}} è aumentato/a molto!", - "statSharplyRose_other": "{{pokemonNameWithAffix}}'s {{stats}} sharply rose!", - "statRoseDrastically_one": "{{pokemonNameWithAffix}}'s {{stats}} è aumentato/a drasticamente!", - "statRoseDrastically_other": "{{pokemonNameWithAffix}}'s {{stats}} rose drastically!", - "statWontGoAnyHigher_one": "{{pokemonNameWithAffix}}'s {{stats}} non può aumentare più di così!", - "statWontGoAnyHigher_other": "{{pokemonNameWithAffix}}'s {{stats}} won't go any higher!", - "statFell_one": "{{pokemonNameWithAffix}}'s {{stats}} è diminuito/a!", - "statFell_other": "{{pokemonNameWithAffix}}'s {{stats}} fell!", - "statHarshlyFell_one": "{{pokemonNameWithAffix}}'s {{stats}} è diminuito/a molto!", - "statHarshlyFell_other": "{{pokemonNameWithAffix}}'s {{stats}} harshly fell!", - "statSeverelyFell_one": "{{pokemonNameWithAffix}}'s {{stats}} è diminuito/a drasticamente!", - "statSeverelyFell_other": "{{pokemonNameWithAffix}}'s {{stats}} severely fell!", - "statWontGoAnyLower_one": "{{pokemonNameWithAffix}}'s {{stats}} non può diminuire più di così!", - "statWontGoAnyLower_other": "{{pokemonNameWithAffix}}'s {{stats}} won't go any lower!", + "statRose_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} è aumentata!", + "statRose_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} sono aumentate!", + "statSharplyRose_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} è aumentata molto!", + "statSharplyRose_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} sono aumentate molto!", + "statRoseDrastically_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} è aumentata drasticamente!", + "statRoseDrastically_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} sono aumentate drasticamente!", + "statWontGoAnyHigher_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} non può aumentare di più!", + "statWontGoAnyHigher_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} non possono aumentare di più!", + "statFell_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} è diminuita!", + "statFell_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} sono diminuite!", + "statHarshlyFell_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} è diminuita molto!", + "statHarshlyFell_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} sono diminuite molto!", + "statSeverelyFell_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} è diminuita drasticamente!", + "statSeverelyFell_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} sono diminuite drasticamente!", + "statWontGoAnyLower_one": "La statistica {{stats}} di {{pokemonNameWithAffix}} non può diminuire di più!", + "statWontGoAnyLower_other": "Le statistiche {{stats}} di {{pokemonNameWithAffix}} non possono diminuire di più!", "transformedIntoType": "{{pokemonName}} diventa\ndi tipo {{type}} type!", "retryBattle": "Vuoi riprovare dall'inizio della lotta?", "unlockedSomething": "{{unlockedThing}}\nè stato/a sbloccato/a.", diff --git a/src/locales/it/battler-tags.ts b/src/locales/it/battler-tags.ts index 7dd3ebc6fb1..518e9194521 100644 --- a/src/locales/it/battler-tags.ts +++ b/src/locales/it/battler-tags.ts @@ -1,14 +1,14 @@ import { SimpleTranslationEntries } from "#app/interfaces/locales"; export const battlerTags: SimpleTranslationEntries = { - "trappedDesc": "trapping", - "flinchedDesc": "flinching", - "confusedDesc": "confusion", - "infatuatedDesc": "infatuation", - "seedDesc": "seeding", - "nightmareDesc": "nightmares", - "ingrainDesc": "roots", - "drowsyDesc": "drowsiness", + "trappedDesc": "intrappolando", + "flinchedDesc": "tentennando", + "confusedDesc": "confuso", + "infatuatedDesc": "infatuato", + "seedDesc": "pieno di semi", + "nightmareDesc": "incubi", + "ingrainDesc": "radici", + "drowsyDesc": "assonnato", "rechargingLapse": "{{pokemonNameWithAffix}} deve\nricaricarsi!", "trappedOnAdd": "{{pokemonNameWithAffix}} non può\npiù fuggire!", "trappedOnRemove": "{{pokemonNameWithAffix}} è stato liberato\nda {{moveName}}", diff --git a/src/locales/it/challenges.ts b/src/locales/it/challenges.ts index 784791f5425..dde5bd0d4e7 100644 --- a/src/locales/it/challenges.ts +++ b/src/locales/it/challenges.ts @@ -2,7 +2,7 @@ import { TranslationEntries } from "#app/interfaces/locales"; export const challenges: TranslationEntries = { "title": "Modificatori delle sfide", - "illegalEvolution": "{{pokemon}} changed into an ineligble pokémon\nfor this challenge!", + "illegalEvolution": "{{pokemon}} non è più utilizzabile\nsecondo le regole della sfida!", "singleGeneration": { "name": "Mono gen", "desc": "Puoi usare solo Pokémon di {{gen}} generazione.", @@ -23,8 +23,8 @@ export const challenges: TranslationEntries = { "desc_default": "Puoi usare solo Pokémon del tipo selezionato." }, "freshStart": { - "name": "Fresh Start", - "desc": "You can only use the original starters, and only as if you had just started PokéRogue.", + "name": "Un nuovo inizio", + "desc": "Puoi usare solo gli starter originali, e come se avessi appena cominciato Pokérogue.", "value.0": "Off", "value.1": "On", } diff --git a/src/locales/it/config.ts b/src/locales/it/config.ts index ceb52665796..d6265061a9f 100644 --- a/src/locales/it/config.ts +++ b/src/locales/it/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const itConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/it/menu-ui-handler.ts b/src/locales/it/menu-ui-handler.ts index 0cfea8d67b7..3454de24f87 100644 --- a/src/locales/it/menu-ui-handler.ts +++ b/src/locales/it/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Scollega Google", "cancel": "Annulla", "losingProgressionWarning": "Perderai tutti i progressi dall'inizio della battaglia. Confermi?", - "noEggs": "You are not hatching\nany eggs at the moment!" + "noEggs": "Non stai schiudendo\nuova al momento!" } as const; diff --git a/src/locales/it/menu.ts b/src/locales/it/menu.ts index 9766708f7ae..3787ceb0e70 100644 --- a/src/locales/it/menu.ts +++ b/src/locales/it/menu.ts @@ -17,7 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "Nome utente", "password": "Password", "login": "Accedi", - "orUse": "Or use", + "orUse": "O usa", "register": "Registrati", "emptyUsername": "Nome utente mancante!", "invalidLoginUsername": "Nome utente non valido!", @@ -39,9 +39,9 @@ export const menu: SimpleTranslationEntries = { "weeklyRankings": "Classifica settimanale", "noRankings": "Nessuna classifica", "positionIcon": "#", - "usernameScoreboard": "Username", - "score": "Score", - "wave": "Wave", + "usernameScoreboard": "Nome utente", + "score": "Punteggio", + "wave": "Onda", "loading": "Caricamento…", "loadingAsset": "Caricamento asset: {{assetName}}", "playersOnline": "Giocatori online", diff --git a/src/locales/it/modifier-type.ts b/src/locales/it/modifier-type.ts index 6f054e4e566..0b166d268a5 100644 --- a/src/locales/it/modifier-type.ts +++ b/src/locales/it/modifier-type.ts @@ -101,7 +101,7 @@ export const modifierType: ModifierTypeTranslationEntries = { }, "TmModifierTypeWithInfo": { name: "MT{{moveId}} - {{moveName}}", - description: "Insegna {{moveName}} a un Pokémon\n(Hold C or Shift for more info).", + description: "Insegna {{moveName}} a un Pokémon\n(Tieni premuto C o Shift per maggiori informazioni).", }, "EvolutionItemModifierType": { description: "Fa evolvere determinate specie di Pokémon.", @@ -153,7 +153,7 @@ export const modifierType: ModifierTypeTranslationEntries = { "REVIVER_SEED": { name: "Revitalseme", description: "Il possessore recupera 1/2 di PS in caso di KO causato da un colpo diretto." }, - "WHITE_HERB": { name: "Erbachiara", description: "An item to be held by a Pokémon. It will restore any lowered stat in battle." }, + "WHITE_HERB": { name: "Erbachiara", description: "Strumento da dare a un Pokémon. Ripristina le statistiche ridotte in lotta." }, "ETHER": { name: "Etere" }, "MAX_ETHER": { name: "Etere max" }, diff --git a/src/locales/it/modifier.ts b/src/locales/it/modifier.ts index 810524a9e5e..94512efef0d 100644 --- a/src/locales/it/modifier.ts +++ b/src/locales/it/modifier.ts @@ -1,14 +1,14 @@ import { SimpleTranslationEntries } from "#app/interfaces/locales"; export const modifier: SimpleTranslationEntries = { - "surviveDamageApply": "{{pokemonNameWithAffix}} hung on\nusing its {{typeName}}!", - "turnHealApply": "{{pokemonNameWithAffix}} restored a little HP using\nits {{typeName}}!", - "hitHealApply": "{{pokemonNameWithAffix}} restored a little HP using\nits {{typeName}}!", - "pokemonInstantReviveApply": "{{pokemonNameWithAffix}} was revived\nby its {{typeName}}!", - "pokemonResetNegativeStatStageApply": "{{pokemonNameWithAffix}}'s lowered stats were restored\nby its {{typeName}}!", - "moneyInterestApply": "You received interest of ₽{{moneyAmount}}\nfrom the {{typeName}}!", - "turnHeldItemTransferApply": "{{pokemonNameWithAffix}}'s {{itemName}} was absorbed\nby {{pokemonName}}'s {{typeName}}!", - "contactHeldItemTransferApply": "{{pokemonNameWithAffix}}'s {{itemName}} was snatched\nby {{pokemonName}}'s {{typeName}}!", - "enemyTurnHealApply": "{{pokemonNameWithAffix}}\nrestored some HP!", + "surviveDamageApply": "{{pokemonNameWithAffix}} resiste\ngrazie al/alla suo/a {{typeName}}!", + "turnHealApply": "{{pokemonNameWithAffix}} recupera alcuni PS con\nil/la suo/a {{typeName}}!", + "hitHealApply": "{{pokemonNameWithAffix}} recupera alcuni PS con\nil/la suo/a {{typeName}}!", + "pokemonInstantReviveApply": "{{pokemonNameWithAffix}} torna in forze\ngrazie al/alla suo/a {{typeName}}!", + "pokemonResetNegativeStatStageApply": "La riduzione alle statistiche di {{pokemonNameWithAffix}}\nviene annullata grazie al/alla suo/a {{typeName}}!", + "moneyInterestApply": "Ricevi un interesse pari a {{moneyAmount}}₽\ngrazie al/allo/a {{typeName}}!", + "turnHeldItemTransferApply": "Il/l'/lo/la {{itemName}} di {{pokemonNameWithAffix}} è stato assorbito\ndal {{typeName}} di {{pokemonName}}!", + "contactHeldItemTransferApply": "Il/l'/lo/la {{itemName}} di {{pokemonNameWithAffix}} è stato rubato\nda {{pokemonName}} con {{typeName}}!", + "enemyTurnHealApply": "{{pokemonNameWithAffix}}\nristabilisce parte dei PS!", "bypassSpeedChanceApply": "{{pokemonName}} agisce più rapidamente del normale grazie al suo {{itemName}}!", } as const; diff --git a/src/locales/it/move-trigger.ts b/src/locales/it/move-trigger.ts index 198fc269785..92ce6a76a74 100644 --- a/src/locales/it/move-trigger.ts +++ b/src/locales/it/move-trigger.ts @@ -57,10 +57,10 @@ export const moveTriggers: SimpleTranslationEntries = { "sacrificialFullRestore": "{{pokemonName}} riceve i benefici\neffetti di Curardore!", "invertStats": "Le modifiche alle statistiche di {{pokemonName}}\nvengono invertite!", "resetStats": "Tutte le modifiche alle statistiche sono state annullate!", - "statEliminated": "All stat changes were eliminated!", + "statEliminated": "Tutte le modifiche alle statistiche sono state annullate!", "faintCountdown": "{{pokemonName}}\nandrà KO dopo {{turnCount}} turni.", "copyType": "{{pokemonName}} assume il tipo\ndi {{targetPokemonName}}!", "suppressAbilities": "L’abilità di {{pokemonName}}\nperde ogni efficacia!", "swapArenaTags": "{{pokemonName}} ha invertito gli effetti attivi\nnelle due metà del campo!", - "exposedMove": "{{pokemonName}} identified\n{{targetPokemonName}}!", + "exposedMove": "{{pokemonName}} ha identificato\n{{targetPokemonName}}!", } as const; diff --git a/src/locales/it/move.ts b/src/locales/it/move.ts index a2c99218cec..1c510d4df6d 100644 --- a/src/locales/it/move.ts +++ b/src/locales/it/move.ts @@ -2915,7 +2915,7 @@ export const move: MoveTranslationEntries = { }, zippyZap: { name: "Sprintaboom", - effect: "The user attacks the target with bursts of electricity at high speed. This move always goes first and raises the user's evasiveness.", + effect: "Un attacco elettrico ad altissima velocità. Questa mossa ha priorità alta e aumenta l'elusione dell'utilizzatore.", }, splishySplash: { name: "Surfasplash", diff --git a/src/locales/it/settings.ts b/src/locales/it/settings.ts index 0d05d01ba1c..278a02bef52 100644 --- a/src/locales/it/settings.ts +++ b/src/locales/it/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "Supporto Gamepad", "showBgmBar": "Mostra Nomi Musica", "moveTouchControls": "Move Touch Controls", - "shopOverlayOpacity": "Opacità Finestra Negozio" + "shopOverlayOpacity": "Opacità Finestra Negozio", + "shopCursorTarget": "Target Cursore Negozio", + "items": "Oggetti", + "reroll": "Rerolla", + "shop": "Negozio", + "checkTeam": "Squadra" } as const; diff --git a/src/locales/ja/ability-trigger.ts b/src/locales/ja/ability-trigger.ts index 7c7d081f645..cf4c89ff5a4 100644 --- a/src/locales/ja/ability-trigger.ts +++ b/src/locales/ja/ability-trigger.ts @@ -47,6 +47,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}は {{abilityName}}で\n相手に ダメージを 与えた!", "postFaintHpDamage": "{{pokemonNameWithAffix}}は {{abilityName}}で\n相手に ダメージを 与えた!", "postSummonPressure": "{{pokemonNameWithAffix}}は\nプレッシャーを 放っている!", + "weatherEffectDisappeared": "天候の影響が なくなった!", "postSummonMoldBreaker": "{{pokemonNameWithAffix}}は\nかたやぶりだ!", "postSummonAnticipation": "{{pokemonNameWithAffix}}は\nみぶるいした!", "postSummonTurboblaze": "{{pokemonNameWithAffix}}は\n燃え盛(もえさか)る オーラを 放っている!", diff --git a/src/locales/ja/battle-scene.ts b/src/locales/ja/battle-scene.ts new file mode 100644 index 00000000000..d2f074416e1 --- /dev/null +++ b/src/locales/ja/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "{{formattedMoney}}円" +} as const; diff --git a/src/locales/ja/config.ts b/src/locales/ja/config.ts index 6af79547a04..61be36c08df 100644 --- a/src/locales/ja/config.ts +++ b/src/locales/ja/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -61,6 +62,7 @@ export const jaConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/ja/settings.ts b/src/locales/ja/settings.ts index ef20d071d2d..3be237e26ae 100644 --- a/src/locales/ja/settings.ts +++ b/src/locales/ja/settings.ts @@ -98,4 +98,9 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "コントローラーサポート", "showBgmBar": "Show Music Names", "shopOverlayOpacity": "Shop Overlay Opacity", + "shopCursorTarget": "Shop Cursor Target", + "items": "Items", + "reroll": "Reroll", + "shop": "Shop", + "checkTeam": "Check Team" } as const; diff --git a/src/locales/ko/ability-trigger.ts b/src/locales/ko/ability-trigger.ts index 974e6970569..9e330c176e7 100644 --- a/src/locales/ko/ability-trigger.ts +++ b/src/locales/ko/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}[[는]] {{abilityName}}[[로]]\n상대에게 데미지를 입혔다!", "postFaintHpDamage": "{{pokemonNameWithAffix}}[[는]] {{abilityName}}[[로]]\n상대에게 데미지를 입혔다!", "postSummonPressure": "{{pokemonNameWithAffix}}[[는]]\n프레셔를 발산하고 있다!", + "weatherEffectDisappeared": "날씨의 영향이 없어졌다!", "postSummonMoldBreaker": "{{pokemonNameWithAffix}}의\n틀깨기!", "postSummonAnticipation": "{{pokemonNameWithAffix}}[[는]]\n몸을 떨었다!", "postSummonTurboblaze": "{{pokemonNameWithAffix}}[[는]]\n활활 타오르는 오라를 발산하고 있다!", diff --git a/src/locales/ko/battle-scene.ts b/src/locales/ko/battle-scene.ts new file mode 100644 index 00000000000..573e1791724 --- /dev/null +++ b/src/locales/ko/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "₽{{formattedMoney}}" +} as const; diff --git a/src/locales/ko/config.ts b/src/locales/ko/config.ts index 114950a4d35..2bc60f04bef 100644 --- a/src/locales/ko/config.ts +++ b/src/locales/ko/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const koConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/ko/move-trigger.ts b/src/locales/ko/move-trigger.ts index cea60e25333..e93639689d8 100644 --- a/src/locales/ko/move-trigger.ts +++ b/src/locales/ko/move-trigger.ts @@ -8,7 +8,7 @@ export const moveTriggers: SimpleTranslationEntries = { "goingAllOutForAttack": "{{pokemonName}}[[는]]\n전력을 다하기 시작했다!", "regainedHealth": "{{pokemonName}}[[는]]\n기력을 회복했다!", "keptGoingAndCrashed": "{{pokemonName}}[[는]]\n의욕이 넘쳐서 땅에 부딪쳤다!", - "fled": "{{pokemonName}}[[는]]\N도망쳤다!", + "fled": "{{pokemonName}}[[는]]\n도망쳤다!", "cannotBeSwitchedOut": "{{pokemonName}}[[를]]\n돌아오게 할 수 없습니다!", "swappedAbilitiesWithTarget": "{{pokemonName}}[[는]]\n서로의 특성을 교체했다!", "coinsScatteredEverywhere": "돈이 주위에 흩어졌다!", diff --git a/src/locales/ko/settings.ts b/src/locales/ko/settings.ts index aa4adfc4e41..38b0679d911 100644 --- a/src/locales/ko/settings.ts +++ b/src/locales/ko/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "게임패드 지원", "showBgmBar": "BGM 제목 보여주기", "moveTouchControls": "터치 컨트롤 이동", - "shopOverlayOpacity": "상점 오버레이 투명도" + "shopOverlayOpacity": "상점 오버레이 투명도", + "shopCursorTarget": "상점 커서 위치", + "items": "아이템", + "reroll": "갱신", + "shop": "상점", + "checkTeam": "파티 확인" } as const; diff --git a/src/locales/pt_BR/ability-trigger.ts b/src/locales/pt_BR/ability-trigger.ts index da91fa3213f..9cfa42edce3 100644 --- a/src/locales/pt_BR/ability-trigger.ts +++ b/src/locales/pt_BR/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{abilityName}} de {{pokemonNameWithAffix}}\nferiu seu adversário!", "postFaintHpDamage": "{{abilityName}} de {{pokemonNameWithAffix}}\nferiu seu adversário!", "postSummonPressure": "{{pokemonNameWithAffix}} está exercendo sua pressão!", + "weatherEffectDisappeared": "Os efeitos do clima desapareceram.", "postSummonMoldBreaker": "{{pokemonNameWithAffix}} quebra o molde!", "postSummonAnticipation": "{{pokemonNameWithAffix}} se arrepiou!", "postSummonTurboblaze": "{{pokemonNameWithAffix}} está irradiando uma aura ardente!", diff --git a/src/locales/pt_BR/battle-scene.ts b/src/locales/pt_BR/battle-scene.ts new file mode 100644 index 00000000000..573e1791724 --- /dev/null +++ b/src/locales/pt_BR/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "₽{{formattedMoney}}" +} as const; diff --git a/src/locales/pt_BR/config.ts b/src/locales/pt_BR/config.ts index b48fcfdc8d8..9ebb4867ae4 100644 --- a/src/locales/pt_BR/config.ts +++ b/src/locales/pt_BR/config.ts @@ -4,6 +4,7 @@ import { PGFachv, PGMachv } from "./achv"; import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const ptBrConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/pt_BR/dialogue.ts b/src/locales/pt_BR/dialogue.ts index cb0c05fab45..969c6fc36a9 100644 --- a/src/locales/pt_BR/dialogue.ts +++ b/src/locales/pt_BR/dialogue.ts @@ -2779,6 +2779,90 @@ export const PGFdialogue: DialogueTranslationEntries = { 9: "Estou realmente cansando de batalhar… Deve haver algo novo para fazer…" } }, + "breeder": { + "encounter": { + 1: "Pokémon obedientes, Pokémon egoístas… Pokémon têm características únicas.", + 2: "Embora minha criação e comportamento sejam ruins, criei meus Pokémon bem.", + 3: "Hmm, você disciplina seus Pokémon? Mimar demais não é bom." + }, + "victory": { + 1: "É importante nutrir e treinar as características de cada Pokémon.", + 2: "Ao contrário do meu lado diabólico, esses são bons Pokémon.", + 3: "Muito elogio pode estragar tanto Pokémon quanto pessoas." + }, + "defeat": { + 1: "Você não deve ficar com raiva dos seus Pokémon, mesmo se perder uma batalha.", + 2: "Certo? Pokémon bons, né? Eu sou adequado para criar coisas.", + 3: "Não importa o quanto você ame seus Pokémon, ainda precisa discipliná-los quando se comportam mal." + } + }, + "breeder_female": { + "encounter": { + 1: "Pokémon nunca te traem. Eles retribuem todo o amor que você dá a eles.", + 2: "Quer uma dica para treinar bons Pokémon?", + 3: "Eu criei esses Pokémon muito especiais usando um método especial." + }, + "victory": { + 1: "Ugh… Não era para ser assim. Será que administrei a mistura errada?", + 2: "Como isso aconteceu com meus Pokémon… O que você está dando de comer aos seus Pokémon?", + 3: "Se eu perder, isso significa que eu estava só matando o tempo. Não machuca meu ego nem um pouco." + }, + "defeat": { + 1: "Isso prova que meus Pokémon aceitaram meu amor.", + 2: "O verdadeiro truque para treinar bons Pokémon é capturar bons Pokémon.", + 3: "Pokémon serão fortes ou fracos dependendo de como você os cria." + } + }, + "fisherman": { + "encounter": { + 1: "Anem! Você me fez perder uma fisgada!\nO que vai fazer sobre isso?", + 2: "Sai daqui! Você está assustando os Pokémon!", + 3: "Vamos ver se você consegue fisgar uma vitória!", + }, + "victory": { + 1: "Esqueça isso.", + 2: "Da próxima vez, eu vou pescar a vitória!", + 3: "Acho que subestimei a força das correntes dessa vez.", + }, + }, + "fisherman_female": { + "encounter": { + 1: "Uau! Peguei um grande!", + 2: "Linha lançada, pronta para pescar o sucesso!", + 3: "Pronta para fazer ondas!" + }, + "victory": { + 1: "Vou voltar com um anzol mais forte.", + 2: "Vou pescar a vitória na próxima vez.", + 3: "Estou só afiando meus anzóis para a revanche!" + }, + }, + "swimmer": { + "encounter": { + 1: "Hora de mergulhar!", + 2: "Vamos surfar nas ondas da vitória!", + 3: "Pronto para fazer um splash!", + }, + "victory": { + 1: "Molhado na derrota!", + 2: "Uma onda de derrota!", + 3: "De volta à praia, eu acho.", + }, + }, + "backpacker": { + "encounter": { + 1: "Prepare-se, vamos começar!", + 2: "Vamos ver se você consegue acompanhar!", + 3: "Prepare-se, desafiante!", + 4: "Passei 20 anos tentando me encontrar… Mas onde estou?" + }, + "victory": { + 1: "Dessa vez tropecei!", + 2: "Ah, acho que estou perdido.", + 3: "Caminho sem saída!", + 4: "Espere um segundo! Ei! Você não sabe quem eu sou?" + }, + }, "ace_trainer": { "encounter": { 1: "Você parece bastante confiante.", @@ -2799,6 +2883,14 @@ export const PGFdialogue: DialogueTranslationEntries = { 4: "Claro que sou forte e não perco. É importante ganhar com graça." } }, + "parasol_lady": { + "encounter": { + 1: "Hora de embelezar o campo de batalha com elegância e postura!", + }, + "victory": { + 1: "Minha elegância permanece inabalável!", + } + }, "twins": { "encounter": { 1: "Prepare-se, porque quando nos unimos, é o dobro do problema!", @@ -2816,6 +2908,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Dobro de sorrisos, dobro da dança da vitória!" } }, + "cyclist": { + "encounter": { + 1: "Prepare-se para comer poeira!", + 2: "Prepare-se, desafiante! Estou prestes a te deixar para trás!", + 3: "Pé no pedal, vamos ver se você consegue acompanhar!" + }, + "victory": { + 1: "As rodas podem estar paradas, mas a determinação continua a pedalar.", + 2: "Fui mais rápido!", + 3: "O caminho para a vitória tem muitas curvas e voltas para explorar." + }, + }, "black_belt": { "encounter": { 1: "Elogio sua coragem ao me desafiar! Pois eu sou o que tem o chute mais forte!", @@ -2826,6 +2930,100 @@ export const PGFdialogue: DialogueTranslationEntries = { 2: "Hmmm… Se eu ia perder de qualquer maneira, esperava ficar totalmente destruído no processo." }, }, + "battle_girl": { + "encounter": { + 1: "Você não precisa tentar me impressionar. Você pode perder contra mim.", + }, + "victory": { + 1: "É difícil dizer adeus, mas estamos ficando sem tempo…", + }, + }, + "hiker": { + "encounter": { + 1: "Minha barriga de meia-idade me deu tanta gravidade quanto as montanhas que eu escalo!", + 2: "Herdei esse corpo ossudo dos meus pais… Sou como uma cadeia de montanhas viva…", + }, + "victory": { + 1: "Pelo menos não posso perder quando se trata de IMC!", + 2: "Não é suficiente… Nunca é suficiente. Meu colesterol ruim não está alto o suficiente…" + }, + }, + "ranger": { + "encounter": { + 1: "Quando estou cercado pela natureza, a maioria das outras coisas deixa de importar.", + 2: "Quando estou vivendo sem natureza na minha vida, às vezes sinto uma crise de ansiedade se aproximando." + }, + "victory": { + 1: "Não importa para a vastidão da natureza se eu ganhar ou perder…", + 2: "Algo assim é bastante trivial comparado aos sentimentos sufocantes da vida na cidade." + }, + "defeat": { + 1: "Ganhei a batalha. Mas a vitória não é nada comparada à vastidão da natureza…", + 2: "Tenho certeza de que como você se sente não é tão ruim se comparar aos meus ataques de ansiedade…" + } + }, + "scientist": { + "encounter": { + 1: "Minha pesquisa levará este mundo à paz e alegria.", + }, + "victory": { + 1: "Sou um gênio… Não devo perder para alguém como você…", + }, + }, + "school_kid": { + "encounter": { + 1: "Heehee. Estou confiante nos meus cálculos e análises.", + 2: "Estou ganhando o máximo de experiência que posso porque quero ser um Líder de Ginásio um dia." + }, + "victory": { + 1: "Aff… Cálculo e análise talvez não sejam páreo para o acaso…", + 2: "Até experiências difíceis e desafiadoras têm seu propósito, eu acho." + } + }, + "artist": { + "encounter": { + 1: "Eu costumava ser popular, mas agora estou acabado.", + }, + "victory": { + 1: "À medida que os tempos mudam, os valores também mudam. Percebi isso tarde demais.", + }, + }, + "guitarist": { + "encounter": { + 1: "Prepare-se para sentir o ritmo da derrota enquanto eu toco minha vitória!", + }, + "victory": { + 1: "Silenciado por agora, mas minha melodia de resiliência continuará a tocar.", + }, + }, + "worker": { + "encounter": { + 1: "Me incomoda que as pessoas sempre me entendam mal. Sou muito mais puro do que todos pensam.", + }, + "victory": { + 1: "Eu realmente não quero que minha pele queime, então quero ficar na sombra enquanto trabalho.", + }, + }, + "worker_female": { + "encounter": { + 1: `Me incomoda que as pessoas sempre me entendam mal. + $Sou muito mais pura do que todos pensam.` + }, + "victory": { + 1: "Eu realmente não quero que minha pele queime, então quero ficar na sombra enquanto trabalho." + }, + "defeat": { + 1: "Meu corpo e mente nem sempre estão necessariamente em sincronia." + } + }, + "worker_double": { + "encounter": { + 1: "Vou te mostrar que podemos te quebrar. Estamos treinando no campo!", + }, + "victory": { + 1: "Que estranho… Como isso pode ser… Não deveria ter sido superado.", + }, + }, "hex_maniac": { "encounter": { 1: "Normalmente, só escuto música clássica, mas se eu perder, acho que vou tentar um pouco de new age!", @@ -2840,6 +3038,32 @@ export const PGFdialogue: DialogueTranslationEntries = { 2: "Não fique presa na tristeza ou frustração. Você pode usar seus rancores para se motivar." } }, + "psychic": { + "encounter": { + 1: "Oi! Concentre-se!", + }, + "victory": { + 1: "Perdi minha concentração!", + }, + }, + "officer": { + "encounter": { + 1: "Prepare-se, porque a justiça está prestes a ser servida!", + 2: "Pronto para defender a lei e servir a justiça no campo de batalha!" + }, + "victory": { + 1: "O peso da justiça parece mais pesado do que nunca…", + 2: "As sombras da derrota pairam no distrito." + } + }, + "beauty": { + "encounter": { + 1: "Minha última batalha… É assim que eu gostaria que víssemos esta partida…", + }, + "victory": { + 1: "Foi divertido… Vamos ter outra última batalha algum dia…", + }, + }, "baker": { "encounter": { 1: "Espero que esteja pronta para saborear a derrota!" @@ -2848,6 +3072,26 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Vou assar uma revanche." }, }, + "biker": { + "encounter": { + 1: "Hora de acelerar e te deixar na poeira!" + }, + "victory": { + 1: "Vou me ajustar para a próxima corrida." + }, + }, + "firebreather": { + "encounter": { + 1: "Minhas chamas irão te consumir!", + 2: "Minha alma está pegando fogo. Irei te mostrar como queima!", + 3: "Cola aqui e dá uma olhada!" + }, + "victory": { + 1: "Fui reduzido a cinzas…", + 2: "Uau! Isso foi quente!", + 3: "Ai! Queimei minha língua!" + }, + }, "sailor": { "encounter": { 1: "Mano, você vai andar na prancha se perder!", @@ -2860,6 +3104,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Estou achando que quem tá enjoado sou eu..." }, }, + "archer": { + "encounter": { + 1: "Antes de você ir mais longe, vamos ver como você se sai contra nós, Equipe Rocket!", + 2: "Eu tenho recebido relatórios de que suas habilidades não são insignificantes. Vamos ver se são verdadeiros.", + 3: "Eu sou Archer, um Admin da Equipe Rocket. E não tenho piedade dos inimigos da nossa organização." + }, + "victory": { + 1: "Que vexame!", + 2: "Com minhas habilidades atuais, eu não estava à altura da tarefa, afinal.", + 3: "M-me perdoe, Giovanni... Por ser derrotado por um mero treinador..." + }, + }, "ariana": { "encounter": { 1: "Pera aí! Não podemos deixar alguém solto por aí. Isso é prejudicial para o orgulho da Equipe Rocket, entende?", @@ -2872,6 +3128,30 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Aaaieeeee! Isso não pode estar acontecendo! Eu lutei muito, mas ainda perdi…" }, }, + "proton": { + "encounter": { + 1: "O que você quer? Se você interromper nosso trabalho, não espere misericórdia!", + 2: "O que temos aqui? Costumam me chamar de o cara mais assustador e cruel da Equipe Rocket… Eu recomendo fortemente que você não interfira nos nossos negócios!", + 3: "Eu sou Proton, um Admin da Equipe Rocket. Estou aqui para acabar com a sua intromissão!" + }, + "victory": { + 1: "A fortaleza caiu!", + 2: "Você pode ter vencido desta vez… Mas tudo o que fez foi aumentar a ira da Equipe Rocket…", + 3: "Fui derrotado… Mas não esquecerei disso!" + }, + }, + "petrel": { + "encounter": { + 1: "Muhahaha, estávamos esperando por você. Eu? Você não sabe quem eu sou? Sou eu, Giovanni. O majestoso Giovanni em pessoa! Wahahaha! ...Huh? Eu não pareço nada com Giovanni? Eu nem mesmo pareço com Giovanni? Como assim? Trabalhei tanto para imitá-lo!", + 2: "Eu sou Petrel, um Admin da Equipe Rocket. Não permitirei que você interfira em nossos planos!", + 3: "O Executivo da Rocket, Petrel, vai lidar com este intruso!" + }, + "victory": { + 1: "OK, OK. Vou te contar onde ele está.", + 2: "Eu... Eu não consegui fazer nada... Giovanni, por favor, me perdoe...", + 3: "Não, eu não posso deixar isso me afetar. Tenho que informar os outros…" + }, + }, "tabitha": { "encounter": { 1: "Hehehe! Então você veio até aqui! Mas você chegou tarde demais!", @@ -2884,6 +3164,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Ahya! Como isso pode ser? Para um Admin como eu perder para uma treinadora qualquer..." }, }, + "courtney": { + "encounter": { + 1: "A coisa... A coisa que você segura... É o que... É o que nós da Equipe Magma procuramos...", + 2: "... Bem então... Deletando...", + 3: "...Ha. ...Analisando... ...Hah♪" + }, + "victory": { + 1: "... ...Mudar...o mundo.", + 2: "Como antecipado. Não antecipado. Você. Bloqueio de alvo... concluído. Iniciando... experimento. Você. Para sempre. Aha... ♪", + 3: "... De novo? Isso não foi antecipado. ...Eu sabia. Você... é interessante! ...Haha. ♪" + }, + }, "shelly": { "encounter": { 1: "Ahahahaha! Você vai se meter nos assuntos da Equipe Aqua? Você é absolutamente destemida, simplesmente ignorante ou ambos! Você é tão fofa que chega a ser nojenta! Vou te derrubar", @@ -2920,6 +3212,30 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Derrotada... Este foi um erro caro." } }, + "jupiter": { + "encounter": { + 1: "Júpiter, Comandante da Equipe Galáctica, ao seu serviço.", + 2: "A resistência é inútil. A Equipe Galáctica prevalecerá!", + 3: "Você está tremendo... já está com medo?" + }, + "victory": { + 1: "De jeito nenhum... Eu perdi?!", + 2: "Impressionante, você tem coragem!", + 3: "Perder assim... Que embaraço." + } + }, + "saturn": { + "encounter": { + 1: "Eu sou Saturno, Comandante da Equipe Galáctica.", + 2: "Nossa missão é absoluta. Qualquer obstáculo será obliterado!", + 3: "É medo o que vejo em seus olhos?" + }, + "victory": { + 1: "Impossível... Derrotado por você?!", + 2: "Você provou ser um adversário digno.", + 3: "Derrotado... Isso é inaceitável." + } + }, "zinzolin": { "encounter": { 1: "Você poderia se tornar uma ameaça para a Equipe Plasma, então vamos eliminá-la aqui e agora!", @@ -2984,6 +3300,38 @@ export const PGFdialogue: DialogueTranslationEntries = { 5: "Você diz o que? Equipe Rocket tchau-tchau a vai-vai? Quebrado é diz você?" // Uso de gramática incorreta é proposital }, }, + "magma_grunt": { + "encounter": { + 1: "Se você se meter com a Equipe Magma, não teremos piedade!", + 2: "É melhor você não interferir em nossos planos! Estamos tornando o mundo um lugar melhor!", + 3: "Você está no caminho! A Equipe Magma não tem tempo para crianças como você!", + 4: "Espero que você tenha trazido marshmallows porque as coisas estão prestes a esquentar!", + 5: "Vamos usar o poder de um vulcão! Vai ser... explosivo! Entendeu? Heh heh!" + }, + "victory": { + 1: "Ahn? Eu perdi?!", + 2: "Não posso acreditar que perdi! Até pulei o almoço por isso.", + 3: "De jeito nenhum! Você é apenas uma criança!", + 4: "Urrrgh... Eu deveria ter me escondido em nosso esconderijo imediatamente...", + 5: "Você me venceu... Você acha que o chefe vai cortar meu salário por isso?" + }, + }, + "aqua_grunt": { + "encounter": { + 1: "Não pegamos leve com quem se mete com a Equipe Aqua, nem mesmo crianças!", + 2: "Grrr... Você tem coragem de se intrometer com a Equipe Aqua!", + 3: "Você está prestes a se molhar! E não apenas por causa dos meus Pokémon aquáticos!", + 4: "Nós, da Equipe Aqua, existimos para o bem de todos!", + 5: "Prepare-se para ser levado pelas ondas do meu... uh, Pokémon! Sim, meu Pokémon!" + }, + "victory": { + 1: "Tá de brincadeira!", + 2: "Arrgh, eu não contei que seria atrapalhado por uma criança intrometida!", + 3: "Eu perdi?! Acho que vou ter que nadar de volta para o esconderijo agora...", + 4: "Oh, cara, que desastre... O chefe vai ficar furioso...", + 5: "Você me venceu... Você acha que o chefe vai me fazer andar na prancha por isso?" + }, + }, "galactic_grunt": { "encounter": { 1: "Não mexa com a Equipe Galáctica!", @@ -3000,6 +3348,104 @@ export const PGFdialogue: DialogueTranslationEntries = { 5: "Nota para mim mesmo: praticar batalhas Pokémon, o mais rápido possível." }, }, + "plasma_grunt": { + "encounter": { + 1: "Não toleramos pessoas que pensam diferente de nós!", + 2: "Se eu ganhar de você, liberte seus Pokémon!", + 3: "Se você atrapalhar a Equipe Plasma, eu cuidarei de você!", + 4: "A Equipe Plasma vai libertar os Pokémon de humanos egoístas como você!", + 5: "Nossos penteados são de outro mundo... mas nossas habilidades de batalha? Você descobrirá em breve." + }, + "victory": { + 1: "Plasmaaaaaaaaa!", + 2: "Como eu pude perder...", + 3: "...Que Pokémon fraco, vou ter que roubar alguns melhores!", + 4: "Grandes planos são sempre interrompidos.", + 5: "Isso é ruim... Ruim ruim ruim ruim ruim ruim ruim! Ruim para a Equipe Plasma! Ou Plasruim, para abreviar!" + }, + }, + "flare_grunt": { + "encounter": { + 1: "Seus Pokémon não são páreo para a elegância da Equipe Flare.", + 2: "Espero que você tenha trazido seus óculos de sol, porque as coisas vão ficar brilhantes!", + 3: "A Equipe Flare vai purificar o mundo da imperfeição!", + 4: "Prepare-se para enfrentar o brilho da Equipe Flare!", + 5: "A moda é o mais importante para nós!" + }, + "victory": { + 1: "O futuro não parece brilhante para mim.", + 2: "Talvez haja mais na batalha do que eu pensei. De volta à prancheta.", + 3: "Gahh?! Eu perdi?!", + 4: "Mesmo na derrota, a elegância da Equipe Flare brilha.", + 5: "Você pode ter me vencido, mas quando eu perco, eu saio com estilo!" + }, + }, + "rocket_boss_giovanni_1": { + "encounter": { + 1: "Tenho que admitir, estou impressionado que tenha chegado até aqui!" + }, + "victory": { + 1: "QUÊ! Isso não é possível!" + }, + "defeat": { + 1: "Guarde minhas palavras.\nNão ser capaz de medir sua própria força mostra que você ainda é uma criança." + } + }, + "rocket_boss_giovanni_2": { + "encounter": { + 1: "Meus antigos associados precisam de mim... Você vai ficar no meu caminho?" + }, + "victory": { + 1: "Como isso é possível...?\nO precioso sonho da Equipe Rocket se tornou pouco mais que uma ilusão..." + }, + "defeat": { + 1: "A Equipe Rocket renascerá, e eu dominarei o mundo!" + } + }, + "magma_boss_maxie_1": { + "encounter": { + 1: "Eu vou te enterrar com minhas próprias mãos.\nEspero que você aprecie essa honra!" + }, + "victory": { + 1: "Ugh! Você é... bastante capaz...\nEu fiquei para trás, mas apenas por um triz..." + }, + "defeat": { + 1: "A Equipe Magma vai prevalecer!" + } + }, + "magma_boss_maxie_2": { + "encounter": { + 1: "Você é o último obstáculo entre mim e meus objetivos.\nPrepare-se para meu ataque final! Fuhahaha!" + }, + "victory": { + 1: "Isso... Isso não é... Ngh..." + }, + "defeat": { + 1: "E agora... Eu transformarei este planeta em uma terra ideal para a humanidade." + } + }, + "aqua_boss_archie_1": { + "encounter": { + 1: "Eu sou o líder da Equipe Aqua, então temo que esse seja o fim da linha para você." + }, + "victory": { + 1: "Vamos nos encontrar de novo em algum lugar. Eu vou ter certeza de lembrar desse rosto." + }, + "defeat": { + 1: "Brilhante! Nada vai parar minha equipe agora!" + } + }, + "aqua_boss_archie_2": { + "encounter": { + 1: "Estive esperando tanto tempo por este dia.\nEste é o verdadeiro poder da minha equipe!" + }, + "victory": { + 1: "Como eu suspeitava..." + }, + "defeat": { + 1: "Eu vou voltar tudo neste mundo ao seu estado puro e original!!" + } + }, "galactic_boss_cyrus_1": { "encounter": { 1: "Você foi compelida a vir aqui por tal sentimentalismo vazio\nEu farei você se arrepender de ter ouvido seu coração!" @@ -3011,6 +3457,78 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Eu criarei meu novo mundo..." } }, + "galactic_boss_cyrus_2": { + "encounter": { + 1: "Nos encontramos novamente. Parece que nossos destinos estão entrelaçados.\nMas aqui e agora, eu finalmente quebrarei esse vínculo!" + }, + "victory": { + 1: "Como? Como? COMO?!" + }, + "defeat": { + 1: "Até logo." + } + }, + "plasma_boss_ghetsis_1": { + "encounter": { + 1: "Ninguém pode me deter! Não importa quem seja ou o que faça!" + }, + "victory": { + 1: "Como isso é possível? Eu sou o criador da Equipe Plasma! Eu sou perfeito!" + }, + "defeat": { + 1: "Eu sou o governante perfeito de um novo mundo perfeito! Mwa ha ha!" + } + }, + "plasma_boss_ghetsis_2": { + "encounter": { + 1: "Vamos! Eu quero ver sua cara depois que você perder toda a esperança!" + }, + "victory": { + 1: "Meus cálculos... Não! Meus planos cuidadosos! O mundo deveria ser meu!" + }, + "defeat": { + 1: "Kyurem! Use Absofusion!" + } + }, + "flare_boss_lysandre_1": { + "encounter": { + 1: "Você está aqui para me deter? Mostre-me em batalha." + }, + "victory": { + 1: "Você está aqui para me deter. Mas eu peço que você espere." + }, + "defeat": { + 1: "Pokémon... não devem mais existir." + } + }, + "flare_boss_lysandre_2": { + "encounter": { + 1: "O futuro que você quer, ou o futuro que eu quero... Vamos ver qual é o mais merecedor, não é mesmo?" + }, + "victory": { + 1: "Uau!" + }, + "defeat": { + 1: "Tolos sem visão continuarão a poluir este belo mundo." + } + }, + "brock": { + "encounter": { + 1: "Minha especialidade em Pokémon do tipo Pedra vai te derrubar! Vamos lá!", + 2: "Minha vontade firme como pedra vai te sobrecarregar!", + 3: "Permita-me mostrar a verdadeira força dos meus Pokémon!" + }, + "victory": { + 1: "A força dos seus Pokémon superou minhas defesas de pedra!", + 2: "O mundo é enorme! Estou feliz por ter tido a chance de batalhar com você.", + 3: "Talvez eu deva voltar a perseguir meu sonho de ser Criador de Pokémon…" + }, + "defeat": { + 1: "A melhor defesa é um bom ataque!\nEssa é a minha maneira de fazer as coisas!", + 2: "Venha estudar rochas comigo da próxima vez para aprender melhor a combatê-las!", + 3: "Hah, todas as minhas viagens pelas regiões estão valendo a pena!" + } + }, "misty": { "encounter": { 1: "Minha política é um ataque total com Pokémon do tipo Água!", @@ -3045,6 +3563,77 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Uma batalha de Pokémon é guerra, e eu te mostrei combate em primeira mão!" } }, + "erika": { + "encounter": { + 1: "Ah, o tempo está adorável aqui…\nOh, uma batalha? Muito bem então.", + 2: "Minhas habilidades de batalha Pokémon rivalizam com minhas habilidades de arranjo de flores.", + 3: "Oh, espero que o aroma agradável dos meus Pokémon não me faça dormir de novo…", + 4: "Ver flores em um jardim é tão calmante." + }, + "victory": { + 1: "Oh! Eu concedo a derrota.", + 2: "Aquela partida foi muito agradável.", + 3: "Ah, parece que perdi…", + 4: "Oh, meu Deus." + }, + "defeat": { + 1: "Tinha medo de adormecer…", + 2: "Oh, meu Deus, parece que meus Pokémon de Grama te dominaram.", + 3: "Essa batalha foi uma experiência tão calmante.", + 4: "Oh… É só isso?" + } + }, + "janine": { + "encounter": { + 1: "Estou dominando a arte dos ataques venenosos.\nVou lutar com você hoje!", + 2: "Meu pai confia que posso me defender.\nVou provar que ele está certo!", + 3: "Minhas técnicas de ninja só perdem para as do meu pai!\nVocê consegue acompanhar?" + }, + "victory": { + 1: "Ainda preciso de treinamento… Entendi.", + 2: "Sua técnica de batalha superou a minha.", + 3: "Vou me aplicar de verdade e melhorar minhas habilidades." + }, + "defeat": { + 1: "Hehe… o veneno drenou todas as suas forças para lutar.", + 2: "Ha! Você não teve chance contra minhas habilidades superiores de ninja!", + 3: "A fé do meu pai em mim não foi mal colocada." + } + }, + "sabrina": { + "encounter": { + 1: "Através da minha habilidade psíquica, tive uma visão da sua chegada!", + 2: "Não gosto de lutar, mas se você quiser, vou mostrar meus poderes!", + 3: "Posso sentir grande ambição em você. Vou ver se não é infundada." + }, + "victory": { + 1: "Seu poder… Ele supera o que eu previa…", + 2: "Não consegui prever seu poder com precisão.", + 3: "Mesmo com meus imensos poderes psíquicos, não consigo sentir outro tão forte quanto você." + }, + "defeat": { + 1: "Essa vitória… É exatamente como previ nas minhas visões!", + 2: "Talvez fosse outra pessoa que eu sentisse um grande desejo…", + 3: "Aprimore suas habilidades antes de entrar em batalha precipitadamente.\nVocê nunca sabe o que o futuro pode reservar se fizer isso…" + } + }, + "blaine": { + "encounter": { + 1: "Hah! Espero que tenha trazido uma Cura de Queimadura!", + 2: "Meus Pokémon de Fogo vão incinerar todos os desafiantes!", + 3: "Prepare-se para brincar com fogo!" + }, + "victory": { + 1: "Queimei até não restar nada! Nem cinzas sobraram!", + 2: "Não acendi as chamas alto o suficiente?", + 3: "Estou completamente exausto… Mas isso faz minha motivação para melhorar queimar ainda mais!" + }, + "defeat": { + 1: "Meu inferno ardente não pode ser apagado!", + 2: "Meus Pokémon foram fortalecidos com o calor desta vitória!", + 3: "Hah! Minha paixão queima mais do que a sua!" + } + }, "giovanni": { "encounter": { 1: "Eu, o líder da Equipe Rocket, vou te fazer sentir um mundo de dor!", @@ -3062,6 +3651,23 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Espero que entenda o quão tolo foi me desafiar." } }, + "roxanne": { + "encounter": { + 1: "Você poderia gentilmente demonstrar como batalha?", + 2: "Você pode aprender muitas coisas batalhando com muitos treinadores.", + 3: "Oh, você me pegou estrategizando.\nGostaria de batalhar?" + }, + "victory": { + 1: "Oh, parece que perdi.\nEu entendo.", + 2: "Parece que ainda tenho muito mais a aprender quando se trata de batalhas.", + 3: "Vou levar o que aprendi aqui hoje a sério." + }, + "defeat": { + 1: "Aprendi muitas coisas com nossa batalha.\nEspero que você também tenha aprendido.", + 2: "Espero batalhar com você novamente.\nEspero que use o que aprendeu aqui.", + 3: "Venci devido a tudo o que aprendi." + } + }, "brawly": { "encounter": { 1: "Oh cara, uma desafiante!\nVamos ver o que você pode fazer!", @@ -3096,6 +3702,40 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Wahahahaha! Que batalha eletrizante!" } }, + "flannery": { + "encounter": { + 1: "Meus Pokémon de fogo estão prontos para queimar a concorrência!\nVamos nessa!", + 2: "Prepare-se para sentir o calor da minha determinação!\nNão vou segurar nada!", + 3: "Minhas habilidades vão incinerar você!\nPrepare-se para a batalha mais quente da sua vida!" + }, + "victory": { + 1: "Essa derrota só faz minha determinação queimar mais!", + 2: "Essa perda não apagará minhas chamas!\nEstarei de volta mais forte!", + 3: "Vou usar essa experiência para reacender meu espírito competitivo!" + }, + "defeat": { + 1: "Minhas chamas nunca se apagarão!\nSou muito apaixonada por isso!", + 2: "Você foi incrível!\nVamos fazer isso de novo algum dia!", + 3: "Que batalha ardente!\nMal posso esperar pela próxima!" + } + }, + "norman": { + "encounter": { + 1: "Você está pronto para enfrentar a força pura do meu time?\nVou te mostrar o poder do equilíbrio!", + 2: "Minha experiência em batalha vai fazer você suar!\nPrepare-se!", + 3: "Treinei meu time rigorosamente.\nVamos ver se você consegue igualar!" + }, + "victory": { + 1: "Parece que subestimei você.\nFoi uma batalha dura.", + 2: "Você é forte, mas ainda há muito para aprender.", + 3: "Essa derrota não abalará minha determinação.\nEstarei de volta mais forte!" + }, + "defeat": { + 1: "Você lutou bravamente!\nEspero batalhar com você novamente.", + 2: "Sua força é incrível!\nNão posso esperar pela nossa próxima batalha.", + 3: "Foi uma honra batalhar com você!\nAté a próxima!" + } + }, "winona": { "encounter": { 1: "Tenho sobrevoado os céus em busca de presas...\nE você é meu alvo!", @@ -3147,6 +3787,60 @@ export const PGFdialogue: DialogueTranslationEntries = { 3: "Tudo graças ao meu treinamento rigoroso com Tate.\nPosso me sincronizar com meus Pokémon." } }, + "juan": { + "encounter": { + 1: "Agora não é hora de agir timidamente.\nVamos batalhar!", + 2: "Ahahaha, você será testemunha da minha arte com Pokémon de Água!", + 3: "Um tufão se aproxima!\nVocê será capaz de me testar?", + 4: "Por favor, você será testemunha da nossa arte.\nUma grande ilusão de água esculpida por meus Pokémon e por mim!" + }, + "victory": { + 1: "Você pode ser um gênio que pode enfrentar Wallace!", + 2: "Eu me concentrei na elegância enquanto você treinava.\nÉ natural que você me derrotasse.", + 3: "Ahahaha!\nMuito bem, você venceu desta vez.", + 4: "De você, sinto o brilho brilhante da habilidade que superará tudo." + }, + "defeat": { + 1: "Meus Pokémon e eu esculpimos uma ilusão de Água e saímos vitoriosos.", + 2: "Ahahaha, eu venci, e você perdeu.", + 3: "Posso emprestar meu traje? Pode te ajudar a batalhar!\nAhahaha, estou brincando!", + 4: "Eu sou o vencedor! O que quer dizer, você perdeu." + } + }, + "crasher_wake": { + "encounter": { + 1: "Crash! Crash! Cuidado!\nDemolidor Wake… está… aqui!", + 2: "Crash! Crash! Demolidor Wake!", + 3: "Sou a onda de poder que vai te lavar!" + }, + "victory": { + 1: "Isso coloca um sorriso no meu rosto!\nGuhahaha! Foi uma explosão!", + 2: "Hunwah! Acabou e terminou!\nComo vou dizer isso...\nQuero mais! Queria batalhar muito mais!", + 3: "O QUÊ?!" + }, + "defeat": { + 1: "Siiiiim! Isso mesmo!", + 2: "Eu venci, mas quero mais! Queria batalhar muito mais!", + 3: "Até logo!" + } + }, + "falkner": { + "encounter": { + 1: "Vou mostrar o verdadeiro poder dos magníficos Pokémon pássaros!", + 2: "Ventos, fiquem comigo!", + 3: "Pai! Espero que esteja vendo minha batalha de cima!" + }, + "victory": { + 1: "Eu entendo... Vou sair graciosamente.", + 2: "Uma derrota é uma derrota. Você é realmente forte.", + 3: "...Droga! Sim, eu perdi." + }, + "defeat": { + 1: "Pai! Venci com seus amados Pokémon pássaros...", + 2: "Pokémon pássaros são os melhores afinal!", + 3: "Sinto que estou alcançando meu pai!" + } + }, "nessa": { "encounter": { 1: "Não importa que tipo de plano sua mente refinada possa estar tramando, meu parceiro e eu vamos afundá-la.", @@ -3295,6 +3989,42 @@ export const PGFdialogue: DialogueTranslationEntries = { 6: "Eu sabia que venceria!" } }, + "crispin": { + "encounter": { + 1: "Quero vencer, então é exatamente isso que vou fazer!", + 2: "Eu batalho porque quero batalhar! E sabe de uma coisa? É assim que deve ser!" + }, + "victory": { + 1: "Queria vencer... mas perdi!", + 2: "Eu perdi... porque não consegui vencer!" + }, + "defeat": { + 1: "Ei, espere um segundo. Eu acabei de vencer? Acho que acabei de vencer! Que satisfação!", + 2: "Uou! Isso foi incrível!" + } + }, + "amarys": { + "encounter": { + 1: "Quero ser a pessoa a ajudar alguém em particular. Sendo assim, não posso me dar ao luxo de perder.\n... Nossa batalha começa agora." + }, + "victory": { + 1: "Eu sou... não o suficiente, eu vejo." + }, + "defeat": { + 1: "A vitória pertence a mim. Bem lutado." + } + }, + "lacey": { + "encounter": { + 1: "Vou enfrentar você com meu time usual como membro da Elite dos Quatro." + }, + "victory": { + 1: "Foi uma excelente batalha. Estou ansiosa para o próximo desafio." + }, + "defeat": { + 1: "Fufufu... Nada mal.\nDesafiantes que derrotam a Elite dos Quatro são dignos de notar." + } + }, "drayton": { "encounter": { 1: `Cara, eu amo cadeiras. Você não ama cadeiras? Que salva-vidas. @@ -3319,6 +4049,23 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Hohoho... De fato. Pequenas lâminas frágeis de grama conseguem quebrar até mesmo concreto." } }, + "viola": { + "encounter": { + 1: `Seja as lágrimas de frustração que seguem uma derrota ou o florescer da alegria que vem com a vitória… + $Ambos são ótimos temas para minha câmera! Fantástico! Isso vai ser simplesmente fantástico! + $Agora venha para cima de mim!`, + 2: "Minha lente está sempre focada na vitória – não vou deixar nada estragar esta foto!" + }, + "victory": { + 1: "Você e seus Pokémon me mostraram uma nova profundidade de campo! Fantástico! Simplesmente fantástico!", + 2: `O mundo que você vê através de uma lente, e o mundo que você vê com um Pokémon ao seu lado… + $O mesmo mundo pode parecer completamente diferente dependendo do seu ponto de vista.` + }, + "defeat": { + 1: "A foto do momento da minha vitória vai ser um verdadeiro sucesso!", + 2: "Sim! Tirei ótimas fotos!" + } + }, "candice": { "encounter": { 1: `Você quer desafiar a Candice? Com certeza! Eu estava esperando por alguém forte! @@ -3347,6 +4094,40 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Sim! Meus Pokémon e eu somos perfeitamente bons!" } }, + "aaron": { + "encounter": { + 1: "Ok! Deixe-me enfrentar você!" + }, + "victory": { + 1: "Batalhar é um assunto profundo e complexo..." + }, + "defeat": { + 1: "Vencer um membro da Elite dos Quatro não é fácil." + } + }, + "cress": { + "encounter": { + 1: "Isso mesmo! Serei eu e meus estimados tipos Água que você deve enfrentar na batalha!" + }, + "victory": { + 1: "Perder? Eu? Não acredito nisso." + }, + "defeat": { + 1: "Este é o resultado apropriado quando eu sou seu oponente." + } + }, + "allister": { + "encounter": { + 1: "Sou Allister.\nA-aqui... vou eu..." + }, + "victory": { + 1: `Quase perdi minha máscara de tanto choque... Isso foi… + $Uau. Posso ver sua habilidade pelo que ela é.`, + }, + "defeat": { + 1: "I-isso foi incrível!" + } + }, "clay": { "encounter": { 1: "Harrumph! Me deixou esperando, não foi, garota? Tudo bem, hora de ver o que você pode fazer!" @@ -3369,6 +4150,68 @@ export const PGFdialogue: DialogueTranslationEntries = { "defeat": { 1: "Volte para me ver novamente, ouviu?" } + }, "tulip": { + "encounter": { + 1: "Permita-me usar minhas habilidades para deixar seus lindos Pokémon ainda mais bonitos!" + }, + "victory": { + 1: "Sua força tem uma magia que não pode ser apagada." + }, + "defeat": { + 1: "Você sabe, na minha linha de trabalho, pessoas que carecem de talento em uma área ou outra frequentemente desaparecem rapidamente - nunca mais se ouve falar delas." + } + }, + "sidney": { + "encounter": { + 1: `Gostei desse olhar que você me deu. Acho que você vai ser um bom desafio. + $Isso é ótimo! Parece muito bom! Vamos nessa! + $Você e eu, vamos curtir uma batalha que só pode acontecer aqui!`, + }, + "victory": { + 1: "E aí, gostou? Eu perdi! Mas foi divertido, então não importa." + }, + "defeat": { + 1: "Sem ressentimentos, beleza?" + } + }, + "phoebe": { + "encounter": { + 1: `Enquanto treinava, adquiri a habilidade de me comunicar com Pokémon do tipo Fantasma. + $Sim, o vínculo que desenvolvi com os Pokémon é extremamente forte. + $Então, vamos lá, tente ver se você consegue até mesmo causar dano aos meus Pokémon!`, + }, + "victory": { + 1: "Ah, droga. Eu perdi." + }, + "defeat": { + 1: "Estou ansiosa para batalhar com você de novo algum dia!" + } + }, + "glacia": { + "encounter": { + 1: `Tudo o que vi foram desafios de Treinadores fracos e seus Pokémon. + $E você? Ficaria extremamente satisfeita se pudesse dar tudo de mim contra você!`, + }, + "victory": { + 1: `Você e seus Pokémon… Como seus espíritos queimam! + $O calor consumido é esmagador. + $Não é surpresa que minhas habilidades geladas falharam em te machucar.`, + }, + "defeat": { + 1: "Uma batalha intensamente apaixonada, sem dúvida." + } + }, + "drake": { + "encounter": { + 1: `Para nós, batalhar com Pokémon como parceiros, você sabe o que é necessário? Você sabe o que precisa? + $Se não souber, nunca prevalecerá contra mim!`, + }, + "victory": { + 1: "Excelente, deve-se dizer." + }, + "defeat": { + 1: "Dei meu máximo nessa batalha!" + } }, "wallace": { "encounter": { @@ -3420,6 +4263,17 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Estou encantada! Sim, encantada por poder esmagar você sob meu calcanhar." } }, + "hala": { + "encounter": { + 1: "O velho Hala está aqui para fazer você gritar!" + }, + "victory": { + 1: "Pude sentir o poder que você ganhou na sua jornada." + }, + "defeat": { + 1: "Haha! Que batalha deliciosa!" + } + }, "molayne": { "encounter": { 1: `Dei a posição de capitão ao meu primo Sophocles, mas estou confiante na minha habilidade. @@ -3443,6 +4297,17 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Nahahaha! Você realmente é algo mais, garota!" } }, + "bruno": { + "encounter": { + 1: "Nós vamos te triturar com nosso poder superior! Hoo hah!" + }, + "victory": { + 1: "Por quê? Como eu poderia perder?" + }, + "defeat": { + 1: "Você pode me desafiar o quanto quiser, mas os resultados nunca vão mudar!" + } + }, "bugsy": { "encounter": { 1: "Sou Bugsy! Eu nunca perco quando se trata de Pokémon do tipo Inseto!" @@ -3454,6 +4319,30 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Obrigado! Graças à nossa batalha, eu também pude fazer progressos na minha pesquisa!" } }, + "koga": { + "encounter": { + 1: "Fwahahahaha! Pokémon não são apenas sobre força bruta--você verá em breve!" + }, + "victory": { + 1: "Ah! Você provou seu valor!" + }, + "defeat": { + 1: "Você aprendeu a temer as técnicas do ninja?" + } + }, + "bertha": { + "encounter": { + 1: "Bem, você mostraria a esta velha senhora o quanto aprendeu?" + }, + "victory": { + 1: `Bem! Querida criança, devo dizer, isso foi muito impressionante. + $Seus Pokémon acreditaram em você e fizeram o melhor para te dar a vitória. + $Mesmo tendo perdido, me encontro com esse sorriso bobo!`, + }, + "defeat": { + 1: "Hahahahah! Parece que esta velha senhora ganhou!" + } + }, "lenora": { "encounter": { 1: "Bem, desafiadora, vou pesquisar como você batalha com os Pokémon que criou com tanto carinho!" @@ -3465,6 +4354,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Ah ha ha! Se você perder, certifique-se de analisar o porquê e use esse conhecimento na próxima batalha!" } }, + "siebold": { + "encounter": { + 1: "Enquanto eu estiver vivo, continuarei em busca da culinária suprema... e dos oponentes mais fortes em batalha!" + }, + "victory": { + 1: "Guardarei minha memória de você e seus Pokémon para sempre em meu coração." + }, + "defeat": { + 1: `Nossa batalha Pokémon foi como alimento para minha alma. Isso vai me manter em frente. + $É assim que vou prestar meus respeitos a você por dar tudo de si na batalha!`, + } + }, "roxie": { "encounter": { 1: "Prepare-se! Vou arrancar algum senso de você!" @@ -3476,6 +4377,40 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Ei, vamos lá! Seja séria! Você tem que dar mais de si!" } }, + "olivia": { + "encounter": { + 1: "Não precisa de introdução aqui. Hora de batalhar comigo, Olivia!" + }, + "victory": { + 1: "Realmente encantador… Tanto você quanto seus Pokémon…" + }, + "defeat": { + 1: "Mmm-hmm." + } + }, + "poppy": { + "encounter": { + 1: "Oooh! Você quer ter uma batalha Pokémon comigo?" + }, + "victory": { + 1: "Uagh?! Mmmuuuggghhh…" + }, + "defeat": { + 1: `Yaaay! Eu consegui! Eu der-ro-tei você! Você pode vir para… Para… Uma revanche? + $Venha para uma revanche quando quiser!`, + } + }, + "agatha": { + "encounter": { + 1: "Pokémon são para batalhas! Vou te mostrar como um verdadeiro Treinador batalha!" + }, + "victory": { + 1: "Oh meu! Você é algo especial, criança!" + }, + "defeat": { + 1: "Bahaha. É assim que uma batalha adequada é feita!" + } + }, "flint": { "encounter": { 1: "Espero que você esteja aquecida, porque aqui vem o Big Bang!" @@ -3487,6 +4422,17 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Huh? Isso é tudo? Acho que você precisa de um pouco mais de paixão." } }, + "grimsley": { + "encounter": { + 1: "O vencedor leva tudo, e não sobra nada para o perdedor." + }, + "victory": { + 1: "Quando se perde, perde-se tudo… A próxima coisa que vou procurar será a vitória, também!" + }, + "defeat": { + 1: "Se alguém vence, a pessoa que lutou contra essa pessoa perde." + } + }, "caitlin": { "encounter": { 1: `Sou eu que apareci quando a flor se abriu. Você que estava esperando… @@ -3501,6 +4447,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Aspiro a reivindicar a vitória com elegância e graça." } }, + "diantha": { + "encounter": { + 1: `Batalhar contra você e seus Pokémon, todos vocês cheios de esperança para o futuro… + $Honestamente, isso apenas me enche da energia que preciso para continuar enfrentando cada novo dia! Sim!`, + }, + "victory": { + 1: "Testemunhar os espíritos nobres de você e seus Pokémon em batalha realmente tocou meu coração…" + }, + "defeat": { + 1: "Oh, fantástico! O que achou? Minha equipe foi bem legal, né?" + } + }, "wikstrom": { "encounter": { 1: `Bem encontrado, jovem desafiadora! Verdadeiramente sou a lâmina famosa de aço endurecido, Duque Wikstrom! @@ -3525,6 +4483,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Ehaha! Que vitória incrível!" } }, + "larry_elite": { + "encounter": { + 1: `Olá… Sou eu, Larry. + $Eu também sou membro da Elite dos Quatro, sim… Infelizmente para mim.`, + }, + "victory": { + 1: "Bem, isso tirou o vento debaixo das nossas asas…" + }, + "defeat": { + 1: "É hora de uma reunião com o chefe." + } + }, "lance": { "encounter": { 1: "Estive esperando por você. Permita-me testar suas habilidades.", @@ -3539,6 +4509,23 @@ export const PGFdialogue: DialogueTranslationEntries = { 2: "Não é que você seja fraca. Não se incomode com isso." } }, + "karen": { + "encounter": { + 1: "Eu sou Karen. Você gostaria de um duelo com meus Pokémon do tipo Sombrio?", + 2: "Sou diferente daqueles que você já conheceu.", + 3: "Você montou uma equipe charmosa. Nossa batalha deve ser boa." + }, + "victory": { + 1: "Não! Eu não posso vencer. Como você ficou tão forte?", + 2: "Não me desviarei do meu caminho escolhido.", + 3: "O Campeão está ansioso para te conhecer." + }, + "defeat": { + 1: "Isso era o que eu esperava.", + 2: "Bem, isso foi relativamente divertido.", + 3: "Venha me visitar a qualquer momento." + } + }, "milo": { "encounter": { 1: `Parece que você entende bem os Pokémon. @@ -3552,6 +4539,20 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Isso realmente vai te deixar em choque e admiração." } }, + "lucian": { + "encounter": { + 1: `Só um momento, por favor. O livro que estou lendo está quase no clímax emocionante… + $O herói obteve uma espada mística e está prestes a enfrentar sua prova final… Ah, tanto faz. + $Já que você chegou tão longe, vou deixar isso de lado e batalhar com você. + $Deixe-me ver se você alcançará tanta glória quanto o herói do meu livro!`, + }, + "victory": { + 1: "Eu vejo… Parece que você me colocou em xeque-mate." + }, + "defeat": { + 1: "Tenho uma reputação a manter." + } + }, "drasna": { "encounter": { 1: `Você deve ser uma Treinadora forte. Sim, bastante forte… @@ -3564,6 +4565,29 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Como isso é possível?" } }, + "kahili": { + "encounter": { + 1: "Então, aqui está você… Por que não vemos para quem os ventos favorecem hoje, você… ou eu?" + }, + "victory": { + 1: "É frustrante para mim como membro da Elite dos Quatro, mas parece que sua força é real." + }, + "defeat": { + 1: "Essa foi uma jogada de mestre!" + } + }, + "hassel": { + "encounter": { + 1: "Prepare-se para aprender em primeira mão como é a respiração ardente de uma batalha feroz!" + }, + "victory": { + 1: `A sorte sorriu para mim desta vez, mas… + $Julgando pelo andamento da luta, quem sabe se serei tão sortudo na próxima vez.`, + }, + "defeat": { + 1: "Essa foi uma jogada de mestre!" + } + }, "blue": { "encounter": { 1: "Você deve ser muito boa para chegar tão longe." @@ -3575,6 +4599,39 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Viu? Meu poder é o que me trouxe até aqui." } }, + "piers": { + "encounter": { + 1: "Prepare-se para uma mosh pit comigo e minha galera! Spikemuth, é hora de roquear!" + }, + "victory": { + 1: "Eu e minha equipe demos o nosso melhor. Vamos nos encontrar novamente para uma batalha algum dia…" + }, + "defeat": { + 1: "Minha garganta está desgastada de tanto gritar… Mas essa foi uma batalha empolgante!" + } + }, + "red": { + "encounter": { + 1: "…!" + }, + "victory": { + 1: "…?" + }, + "defeat": { + 1: "…!" + } + }, + "jasmine": { + "encounter": { + 1: "Oh… Seus Pokémon são impressionantes. Acho que vou gostar disso." + }, + "victory": { + 1: "Você é realmente forte. Vou ter que me esforçar muito mais também." + }, + "defeat": { + 1: "Eu nunca esperei ganhar." + } + }, "lance_champion": { "encounter": { 1: "Ainda sou o Campeão. Não vou segurar nada." @@ -3586,6 +4643,96 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Defendi com sucesso meu Campeonato." } }, + "steven": { + "encounter": { + 1: `Diga-me… O que você viu na sua jornada com seus Pokémon? + $O que você sentiu, encontrando tantos outros Treinadores por aí? + $Viajar por esta terra rica… Isso despertou algo dentro de você? + $Quero que você venha até mim com tudo o que aprendeu. + $Meus Pokémon e eu responderemos com tudo o que sabemos!`, + }, + "victory": { + 1: "Então eu, o Campeão, caio em derrota…" + }, + "defeat": { + 1: "Esse tempo foi bem gasto! Obrigado!" + } + }, + "cynthia": { + "encounter": { + 1: "Eu, Cynthia, aceito seu desafio! Não haverá nenhuma trégua da minha parte!" + }, + "victory": { + 1: "Não importa o quão divertida a batalha seja, ela sempre terminará algum dia…" + }, + "defeat": { + 1: "Mesmo que você perca, nunca perca o amor pelos Pokémon." + } + }, + "iris": { + "encounter": { + 1: `Sabe de uma coisa? Estou realmente ansiosa para ter batalhas sérias com Treinadores fortes! + $Quero dizer, vamos lá! Os Treinadores que chegam aqui são Treinadores que desejam a vitória com todas as fibras do seu ser! + $E eles estão batalhando ao lado de Pokémon que passaram por inúmeras batalhas difíceis! + $Se eu batalhar com pessoas assim, não só eu ficarei mais forte, meus Pokémon também! + $E nós vamos nos conhecer ainda melhor! OK! Prepare-se! + $Sou Iris, a Campeã da Liga Pokémon, e vou te derrotar!`, + }, + "victory": { + 1: "Aghhhh… Eu dei o meu melhor, mas nós perdemos…" + }, + "defeat": { + 1: "Yay! Nós vencemos!" + } + }, + "hau": { + "encounter": { + 1: `Eu me pergunto se um Treinador batalha de maneira diferente dependendo se ele é de uma região quente ou fria. + $Vamos testar isso!`, + }, + "victory": { + 1: "Isso foi incrível! Acho que entendi um pouco melhor seu estilo agora!" + }, + "defeat": { + 1: "Cara, essa foi uma batalha e tanto!" + } + }, + "geeta": { + "encounter": { + 1: `Decidi entrar na batalha mais uma vez. + $Venha agora… Mostre-me os frutos do seu treinamento.`, + }, + "victory": { + 1: "Estou ansiosa para notícias de todas as suas conquistas!" + }, + "defeat": { + 1: "Qual o problema? Isso é tudo?" + } + }, + "nemona": { + "encounter": { + 1: "Yesss! Estou tão empolgada! Hora de soltar tudo!" + }, + "victory": { + 1: "Bem, isso foi ruim, mas ainda me diverti! Eu te pego na próxima!" + }, + "defeat": { + 1: "Bem, essa foi uma ótima batalha! Frutífera, com certeza." + } + }, + "leon": { + "encounter": { + 1: "Vamos ter um tempo absolutamente campeão!" + }, + "victory": { + 1: `Meu tempo como Campeão acabou… + $Mas que tempo campeão foi! + $Obrigado pela melhor batalha que já tive!`, + }, + "defeat": { + 1: "Um tempo absolutamente campeão, foi!" + } + }, "whitney": { "encounter": { 1: "Eai! Você não acha que os Pokémon são, tipo, super fofos?" @@ -3619,6 +4766,28 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Coma, meu adorável Vivillon!" } }, + "pryce": { + "encounter": { + 1: "A juventude sozinha não garante a vitória! Experiência é o que conta." + }, + "victory": { + 1: "Excelente! Isso foi perfeito. Tente não esquecer o que sente agora." + }, + "defeat": { + 1: "Exatamente como eu imaginei." + } + }, + "clair": { + "encounter": { + 1: "Você sabe quem eu sou? E ainda se atreve a me desafiar?" + }, + "victory": { + 1: "Eu me pergunto até onde você pode ir com seu nível de habilidade. Isso deve ser fascinante." + }, + "defeat": { + 1: "E é isso." + } + }, "maylene": { "encounter": { 1: `Vim desafiá-la agora e não vou segurar nada. @@ -3631,6 +4800,18 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Isso foi incrível." } }, + "fantina": { + "encounter": { + 1: `Você vai me desafiar, não é? Mas eu vou ganhar. + $É o que a Líder do Ginásio de Hearthome faz, não?`, + }, + "victory": { + 1: "Você é tão incrivelmente forte. Sei porque perdi." + }, + "defeat": { + 1: "Estou tão, tão, muito feliz!" + } + }, "byron": { "encounter": { 1: `Treinadora! Você é jovem, assim como meu filho, Roark. @@ -3644,6 +4825,17 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Gwahahaha! Como foram meus Pokémon robustos?!" } }, + "olympia": { + "encounter": { + 1: "Um costume antigo decidindo o destino de alguém. A batalha começa!" + }, + "victory": { + 1: "Crie seu próprio caminho. Não deixe nada te atrapalhar. Seu destino, seu futuro." + }, + "defeat": { + 1: "Nosso caminho está claro agora." + } + }, "volkner": { "encounter": { 1: `Já que você chegou tão longe, deve ser bastante forte… @@ -3659,6 +4851,108 @@ export const PGFdialogue: DialogueTranslationEntries = { $Isso não é o que eu queria!`, } }, + "burgh": { + "encounter": { + 1: `M'hm… Se eu ganhar esta batalha, sinto que posso desenhar um quadro diferente de qualquer outro. + $OK! Posso ouvir minha musa da batalha claramente. Vamos direto ao ponto!`, + 2: `Claro, estou realmente orgulhoso de todos os meus Pokémon! + $Bem agora… Vamos direto ao ponto!` + }, + "victory": { + 1: "Acabou? Minha musa me abandonou?", + 2: "Hmm… Acabou! Você é incrível!" + }, + "defeat": { + 1: "Uau… É bonito de alguma forma, não é…", + 2: `Às vezes ouço as pessoas dizerem que foi uma vitória feia. + $Acho que se você está dando o seu melhor, qualquer vitória é bonita.` + } + }, + "elesa": { + "encounter": { + 1: `C'est fini! Quando tenho certeza disso, sinto um choque elétrico percorrer meu corpo! + $Quero sentir essa sensação, então agora meus amados Pokémon vão fazer sua cabeça girar!`, + }, + "victory": { + 1: "Eu queria fazer sua cabeça girar, mas você me surpreendeu." + }, + "defeat": { + 1: "Isso foi insatisfatório de alguma forma… Você dará tudo de si na próxima vez?" + } + }, + "skyla": { + "encounter": { + 1: `Finalmente é hora do confronto! Isso significa a batalha Pokémon que decide quem está no topo, certo? + $Eu amo estar no topo! Porque você pode ver para sempre e sempre de lugares altos! + $Então, que tal nós nos divertirmos?`, + }, + "victory": { + 1: "Ser seu oponente na batalha é uma nova fonte de força para mim. Obrigada!" + }, + "defeat": { + 1: "Ganhar ou perder, você sempre ganha algo com uma batalha, certo?" + } + }, + "brycen": { + "encounter": { + 1: `Há também força em estar com outras pessoas e Pokémon. + $Receber o apoio deles te fortalece. Vou te mostrar esse poder!`, + }, + "victory": { + 1: "A maravilhosa combinação de você e seus Pokémon! Que amizade linda!" + }, + "defeat": { + 1: "Condições extremas realmente testam e treinam você!" + } + }, + "drayden": { + "encounter": { + 1: `O que eu quero encontrar é um jovem Treinador que possa me mostrar um futuro brilhante. + $Vamos batalhar com tudo o que temos: sua habilidade, minha experiência e o amor com que criamos nossos Pokémon!`, + }, + "victory": { + 1: "Esse sentimento intenso que me invade após uma derrota… Não sei como descrevê-lo." + }, + "defeat": { + 1: "Harrumph! Sei que sua habilidade é maior que isso!" + } + }, + "grant": { + "encounter": { + 1: `Só há uma coisa que desejo. + $Que, superando um ao outro, encontremos um caminho para alturas ainda maiores.`, + }, + "victory": { + 1: "Você é uma parede que não consigo superar!" + }, + "defeat": { + 1: `Não desista. + $Isso é tudo o que realmente importa. + $As lições mais importantes da vida são simples.`, + } + }, + "korrina": { + "encounter": { + 1: "Hora da grande aparição de Lady Korrina!" + }, + "victory": { + 1: "É o seu próprio ser que permite que seus Pokémon evoluam!" + }, + "defeat": { + 1: "Que batalha explosiva!" + } + }, + "clemont": { + "encounter": { + 1: "Oh! Estou feliz por termos nos encontrado!" + }, + "victory": { + 1: "Sua paixão pela batalha me inspira!" + }, + "defeat": { + 1: "Parece que minha Máquina Treinadora-Crescer-Forte, Mach 2 está realmente funcionando!" + } + }, "valerie": { "encounter": { 1: `Oh, se não é uma jovem Treinadora… É adorável conhecê-la assim. @@ -3732,6 +5026,42 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Bom trabalho, eu suponho." } }, + "gordie": { + "encounter": { + 1: "Então, vamos acabar com isso." + }, + "victory": { + 1: "Eu só quero me enterrar em um buraco… Bem, acho que seria mais como cair daqui." + }, + "defeat": { + 1: "Batalhe como sempre faz, a vitória seguirá!" + } + }, + "marnie": { + "encounter": { + 1: `A verdade é que, quando tudo está dito e feito… Eu realmente só quero me tornar Campeã por mim mesma! + $Então, não leve para o pessoal quando eu chutar seu traseiro!`, + }, + "victory": { + 1: "OK, então eu perdi… Mas consegui ver muitos dos pontos bons de você e seus Pokémon!" + }, + "defeat": { + 1: "Espero que você tenha gostado das nossas táticas de batalha." + } + }, + "raihan": { + "encounter": { + 1: "Vou derrotar o Campeão, vencer todo o torneio e provar ao mundo o quão forte o grande Raihan realmente é!" + }, + "victory": { + 1: `Eu pareço bem mesmo quando perco. + $É uma verdadeira maldição. + $Acho que é hora de mais uma selfie!`, + }, + "defeat": { + 1: "Vamos tirar uma selfie para lembrar disso." + } + }, "brassius": { "encounter": { 1: "Pressuponho que você está pronta? Que nossa obra de arte colaborativa comece!" @@ -3757,6 +5087,17 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Seus olhos são MEUS!" } }, + "larry": { + "encounter": { + 1: "Quando tudo está dito e feito, a simplicidade é mais forte." + }, + "victory": { + 1: "Uma porção de derrota, hein?" + }, + "defeat": { + 1: "Vou encerrar o dia." + } + }, "ryme": { "encounter": { 1: "Vamos lá, baby! Me agite até os ossos!" @@ -3768,6 +5109,31 @@ export const PGFdialogue: DialogueTranslationEntries = { 1: "Até mais, baby!" } }, + "grusha": { + "encounter": { + 1: "Tudo o que preciso fazer é garantir que o poder do meu Pokémon te arrependa até os ossos!" + }, + "victory": { + 1: "Sua paixão ardente... Eu meio que gosto, para ser honesto." + }, + "defeat": { + 1: "As coisas não esquentaram para você." + } + }, + "marnie_elite": { + "encounter": { + 1: "Você chegou até aqui, hein? Vamos ver se você pode lidar com meus Pokémon!", + 2: "Vou dar o meu melhor, mas não pense que vou pegar leve com você!" + }, + "victory": { + 1: "Não acredito que perdi... Mas você mereceu essa vitória. Bem feito!", + 2: "Parece que ainda tenho muito a aprender. Porém, grande batalha!" + }, + "defeat": { + 1: "Você lutou bem, mas eu tenho a vantagem! Melhor sorte na próxima vez!", + 2: "Parece que meu treinamento valeu a pena. Obrigado pela batalha!" + } + }, "nessa_elite": { "encounter": { 1: "As marés estão mudando a meu favor. Pronta para ser levada pela corrente?", @@ -3782,6 +5148,20 @@ export const PGFdialogue: DialogueTranslationEntries = { 2: "Você lutou bem, mas o poder do oceano é imparável!" } }, + "bea_elite": { + "encounter": { + 1: "Prepare-se! Meu espírito de luta brilha intensamente!", + 2: "Vamos ver se você consegue acompanhar meu ritmo implacável!" + }, + "victory": { + 1: "Sua força... É impressionante. Você realmente merece essa vitória.", + 2: "Nunca senti essa intensidade antes. Trabalho incrível!" + }, + "defeat": { + 1: "Outra vitória para meu rigoroso regime de treinamento! Bem feito!", + 2: "Você tem força, mas eu treinei mais. Grande batalha!" + } + }, "allister_elite": { "encounter": { 1: "As sombras caem... Você está pronta para enfrentar seus medos?", @@ -3810,6 +5190,32 @@ export const PGFdialogue: DialogueTranslationEntries = { 2: "Você foi pega na minha tempestade! Melhor sorte na próxima vez!" } }, + "alder": { + "encounter": { + 1: "Se prepare para uma batalha contra o Treinador mais forte de Unova!" + }, + "victory": { + 1: "Muito bem! Você certamente é um talento incomparável." + }, + "defeat": { + 1: `Um vento fresco sopra em meu coração... + $Que esforço extraordinário!` + } + }, + "kieran": { + "encounter": { + 1: `Através do trabalho duro, eu me torno cada vez mais forte! + $Eu não perco.` + }, + "victory": { + 1: `Eu não acredito... + $Que batalha divertida e emocionante!` + }, + "defeat": { + 1: `Uau, que batalha! + $Hora de você treinar ainda mais.` + } + }, "rival": { "encounter": { 1: `@c{smile}Eai, estava procurando você! Sabia que você estava ansiosa para começar, mas esperava pelo menos um tchau… diff --git a/src/locales/pt_BR/menu.ts b/src/locales/pt_BR/menu.ts index 927ccce518b..87be5d8bed0 100644 --- a/src/locales/pt_BR/menu.ts +++ b/src/locales/pt_BR/menu.ts @@ -35,11 +35,11 @@ export const menu: SimpleTranslationEntries = { "sessionSuccess": "Sessão carregada com sucesso.", "failedToLoadSession": "Não foi possível carregar os dados da sua sessão.\nEles podem estar corrompidos.", "boyOrGirl": "Você é um menino ou uma menina?", - "evolving": "Que?\n{{pokemonName}} tá evoluindo!", + "evolving": "Quê?\n{{pokemonName}} tá evoluindo!", "stoppedEvolving": "{{pokemonName}} parou de evoluir.", "pauseEvolutionsQuestion": "Gostaria de pausar evoluções para {{pokemonName}}?\nEvoluções podem ser religadas na tela de equipe.", "evolutionsPaused": "Evoluções foram paradas para {{pokemonName}}.", - "evolutionDone": "Parabéns!\nSeu {{pokemonName}} evolui para {{evolvedPokemonName}}!", + "evolutionDone": "Parabéns!\nSeu {{pokemonName}} evoluiu para {{evolvedPokemonName}}!", "dailyRankings": "Classificação Diária", "weeklyRankings": "Classificação Semanal", "noRankings": "Sem Classificação", diff --git a/src/locales/pt_BR/modifier.ts b/src/locales/pt_BR/modifier.ts index 168665205c3..eadd5c5667a 100644 --- a/src/locales/pt_BR/modifier.ts +++ b/src/locales/pt_BR/modifier.ts @@ -4,7 +4,7 @@ export const modifier: SimpleTranslationEntries = { "surviveDamageApply": "{{pokemonNameWithAffix}} aguentou o tranco\nusando sua {{typeName}}!", "turnHealApply": "{{pokemonNameWithAffix}} restaurou um pouco de PS usando\nsuas {{typeName}}!", "hitHealApply": "{{pokemonNameWithAffix}} restaurou um pouco de PS usando\nsua {{typeName}}!", - "pokemonInstantReviveApply": "{{pokemonNameWithAffix}} foi revivido\npor sua {{typeName}}!", + "pokemonInstantReviveApply": "{{pokemonNameWithAffix}} foi reanimado\npor sua {{typeName}}!", "pokemonResetNegativeStatStageApply": "Os atributos diminuídos de {{pokemonNameWithAffix}} foram\nrestaurados por seu(sua) {{typeName}}!", "moneyInterestApply": "Você recebeu um juros de ₽{{moneyAmount}}\nde sua {{typeName}}!", "turnHeldItemTransferApply": "{{itemName}} de {{pokemonNameWithAffix}} foi absorvido(a)\npelo {{typeName}} de {{pokemonName}}!", diff --git a/src/locales/pt_BR/move-trigger.ts b/src/locales/pt_BR/move-trigger.ts index 042d539338e..620f867ae9a 100644 --- a/src/locales/pt_BR/move-trigger.ts +++ b/src/locales/pt_BR/move-trigger.ts @@ -26,7 +26,7 @@ export const moveTriggers: SimpleTranslationEntries = { "soothingAromaWaftedThroughArea": "Um aroma suave se espalhou pelo ambiente!", "sprangUp": "{{pokemonName}} se levantou!", "choseDoomDesireAsDestiny": "{{pokemonName}} escolheu\no Desejo da Perdição como seu destino!", - "vanishedInstantly": "{{pokemonName}} desapareceu/nde repente!", + "vanishedInstantly": "{{pokemonName}} desapareceu\nde repente!", "tookTargetIntoSky": "{{pokemonName}} levou {{targetName}}\npara o céu!", "becameCloakedInFreezingLight": "{{pokemonName}} ficou envolto/nem uma luz congelante!", "becameCloakedInFreezingAir": "{{pokemonName}} ficou envolto/nem ar congelante!", diff --git a/src/locales/pt_BR/party-ui-handler.ts b/src/locales/pt_BR/party-ui-handler.ts index 08132b4bfc0..1f3e0fbe242 100644 --- a/src/locales/pt_BR/party-ui-handler.ts +++ b/src/locales/pt_BR/party-ui-handler.ts @@ -15,7 +15,7 @@ export const partyUiHandler: SimpleTranslationEntries = { "ALL": "Tudo", "PASS_BATON": "Passar Bastão", "UNPAUSE_EVOLUTION": "Ativar Evolução", - "REVIVE": "Reviver", + "REVIVE": "Reanimar", "RENAME": "Renomear", "choosePokemon": "Escolha um Pokémon.", diff --git a/src/locales/pt_BR/pokemon-form.ts b/src/locales/pt_BR/pokemon-form.ts index 062fc165ae0..dbe63fb7864 100644 --- a/src/locales/pt_BR/pokemon-form.ts +++ b/src/locales/pt_BR/pokemon-form.ts @@ -29,7 +29,7 @@ export const pokemonForm: SimpleTranslationEntries = { "pikachuPartner": "Parceiro", "eeveePartner": "Parceiro", // 2G - "pichuSpiky": "Spiky", + "pichuSpiky": "Orelha Espetada", "unownA": "A", "unownB": "B", "unownC": "C", @@ -74,8 +74,8 @@ export const pokemonForm: SimpleTranslationEntries = { "rotomFrost": "Congelante", "rotomFan": "Ventilador", "rotomMow": "Corte", - "giratinaAltered": "Altered", - "shayminLand": "Land", + "giratinaAltered": "Alterado", + "shayminLand": "Terrestre", // 5G "basculinRedStriped": "Listras Vermelhas", "basculinBlueStriped": "Listras Azuis", @@ -84,11 +84,11 @@ export const pokemonForm: SimpleTranslationEntries = { "deerlingSummer": "Verão", "deerlingAutumn": "Outono", "deerlingWinter": "Inverno", - "tornadusIncarnate": "Incarnate", - "thundurusIncarnate": "Incarnate", - "landorusIncarnate": "Incarnate", - "keldeoOrdinary": "Ordinary", - "meloettaAria": "Aria", + "tornadusIncarnate": "Materializado", + "thundurusIncarnate": "Materializado", + "landorusIncarnate": "Materializado", + "keldeoOrdinary": "Comum", + "meloettaAria": "Ária", // 6G "froakieBattleBond": "Vínculo de Batalha", "scatterbugMeadow": "Prado", @@ -165,11 +165,11 @@ export const pokemonForm: SimpleTranslationEntries = { "eiscueNoIce": "Descongelado", "indeedeeMale": "Macho", "indeedeeFemale": "Fêmea", - "morpekoFullBelly": "Full Belly", - "zacianHeroOfManyBattles": "Hero Of Many Battles", - "zamazentaHeroOfManyBattles": "Hero Of Many Battles", + "morpekoFullBelly": "Saciado", + "zacianHeroOfManyBattles": "Herói Veterano", + "zamazentaHeroOfManyBattles": "Herói Veterano", "zarudeDada": "Papa", - "enamorusIncarnate": "Incarnate", + "enamorusIncarnate": "Materializado", // 9G "squawkabillyGreenPlumage": "Plumas Verdes", "squawkabillyBluePlumage": "Plumas Azuis", diff --git a/src/locales/pt_BR/settings.ts b/src/locales/pt_BR/settings.ts index 14646b59742..e34fdfa0e5d 100644 --- a/src/locales/pt_BR/settings.ts +++ b/src/locales/pt_BR/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "Suporte para Controle", "showBgmBar": "Exibir Nomes das Músicas", "moveTouchControls": "Move Touch Controls", - "shopOverlayOpacity": "Opacidade da Loja" + "shopOverlayOpacity": "Opacidade da Loja", + "shopCursorTarget": "Alvo do Cursor da Loja", + "items": "Itens", + "reroll": "Atualizar", + "shop": "Loja", + "checkTeam": "Checar Time" } as const; diff --git a/src/locales/zh_CN/ability-trigger.ts b/src/locales/zh_CN/ability-trigger.ts index 0d69a78f0f7..337c0655c87 100644 --- a/src/locales/zh_CN/ability-trigger.ts +++ b/src/locales/zh_CN/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}的{{abilityName}}\n使对方受到了伤害!", "postFaintHpDamage": "{{pokemonNameWithAffix}}的{{abilityName}}\n使对方受到了伤害!", "postSummonPressure": "从{{pokemonNameWithAffix}}的身上\n感到了一种压迫感!", + "weatherEffectDisappeared": "天气的影响消失了!", "postSummonMoldBreaker": "{{pokemonNameWithAffix}}\n打破了常规!", "postSummonAnticipation": "{{pokemonNameWithAffix}}\n发抖了!", "postSummonTurboblaze": "{{pokemonNameWithAffix}}\n正在释放炽焰气场!", diff --git a/src/locales/zh_CN/battle-scene.ts b/src/locales/zh_CN/battle-scene.ts new file mode 100644 index 00000000000..573e1791724 --- /dev/null +++ b/src/locales/zh_CN/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "₽{{formattedMoney}}" +} as const; diff --git a/src/locales/zh_CN/config.ts b/src/locales/zh_CN/config.ts index 24c8b870ffa..99b4e56ffc2 100644 --- a/src/locales/zh_CN/config.ts +++ b/src/locales/zh_CN/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const zhCnConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/zh_CN/settings.ts b/src/locales/zh_CN/settings.ts index 422b1bd591d..d727ac2bef5 100644 --- a/src/locales/zh_CN/settings.ts +++ b/src/locales/zh_CN/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "手柄支持", "showBgmBar": "显示音乐名称", "moveTouchControls": "移动触摸控制", - "shopOverlayOpacity": "商店显示不透明度" + "shopOverlayOpacity": "商店显示不透明度", + "shopCursorTarget": "商店指针位置", + "items": "道具", + "reroll": "刷新", + "shop": "购买", + "checkTeam": "检查队伍" } as const; diff --git a/src/locales/zh_TW/ability-trigger.ts b/src/locales/zh_TW/ability-trigger.ts index c0d348633bc..14aa6de1af7 100644 --- a/src/locales/zh_TW/ability-trigger.ts +++ b/src/locales/zh_TW/ability-trigger.ts @@ -46,6 +46,7 @@ export const abilityTriggers: SimpleTranslationEntries = { "postFaintContactDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postFaintHpDamage": "{{pokemonNameWithAffix}}'s {{abilityName}}\nhurt its attacker!", "postSummonPressure": "{{pokemonNameWithAffix}} is exerting its Pressure!", + "weatherEffectDisappeared": "天氣的影響消失了!", "postSummonMoldBreaker": "{{pokemonNameWithAffix}} breaks the mold!", "postSummonAnticipation": "{{pokemonNameWithAffix}} shuddered!", "postSummonTurboblaze": "{{pokemonNameWithAffix}} is radiating a blazing aura!", diff --git a/src/locales/zh_TW/battle-scene.ts b/src/locales/zh_TW/battle-scene.ts new file mode 100644 index 00000000000..573e1791724 --- /dev/null +++ b/src/locales/zh_TW/battle-scene.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleScene: SimpleTranslationEntries = { + "moneyOwned": "₽{{formattedMoney}}" +} as const; diff --git a/src/locales/zh_TW/config.ts b/src/locales/zh_TW/config.ts index 004ed1da1ab..269ea3003b9 100644 --- a/src/locales/zh_TW/config.ts +++ b/src/locales/zh_TW/config.ts @@ -4,6 +4,7 @@ import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleScene } from "./battle-scene"; import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battlerTags } from "./battler-tags"; @@ -60,6 +61,7 @@ export const zhTwConfig = { arenaFlyout: arenaFlyout, arenaTag: arenaTag, battle: battle, + battleScene: battleScene, battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, battlePokemonForm: battlePokemonForm, diff --git a/src/locales/zh_TW/settings.ts b/src/locales/zh_TW/settings.ts index 35499f45d15..7e6bf25bd7a 100644 --- a/src/locales/zh_TW/settings.ts +++ b/src/locales/zh_TW/settings.ts @@ -98,5 +98,10 @@ export const settings: SimpleTranslationEntries = { "gamepadSupport": "手柄支持", "showBgmBar": "Show Music Names", "moveTouchControls": "移動觸控控制", - "shopOverlayOpacity": "Shop Overlay Opacity" + "shopOverlayOpacity": "Shop Overlay Opacity", + "shopCursorTarget": "Shop Cursor Target", + "items": "Items", + "reroll": "Reroll", + "shop": "Shop", + "checkTeam": "Check Team" } as const; diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 8a6598f5849..99f4540f493 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1160,7 +1160,7 @@ export class TurnHealModifier extends PokemonHeldItemModifier { if (!pokemon.isFullHp()) { const scene = pokemon.scene; scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / 16) * this.stackCount, 1), i18next.t("modifier:turnHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); + Utils.toDmgValue(pokemon.getMaxHp() / 16) * this.stackCount, i18next.t("modifier:turnHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); return true; } @@ -1251,7 +1251,7 @@ export class HitHealModifier extends PokemonHeldItemModifier { if (pokemon.turnData.damageDealt && !pokemon.isFullHp()) { const scene = pokemon.scene; scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); + Utils.toDmgValue(pokemon.turnData.damageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); } return true; @@ -1386,7 +1386,7 @@ export class PokemonInstantReviveModifier extends PokemonHeldItemModifier { const pokemon = args[0] as Pokemon; pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(), - Math.max(Math.floor(pokemon.getMaxHp() / 2), 1), i18next.t("modifier:pokemonInstantReviveApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), false, false, true)); + Utils.toDmgValue(pokemon.getMaxHp() / 2), i18next.t("modifier:pokemonInstantReviveApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), false, false, true)); pokemon.resetStatus(true, false, true); return true; diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 9781ca6d360..17625c57fc6 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -23,7 +23,7 @@ export class AttemptRunPhase extends PokemonPhase { const enemySpeed = enemyField.reduce((total: integer, enemyPokemon: Pokemon) => total + enemyPokemon.getStat(Stat.SPD), 0) / enemyField.length; const escapeChance = new Utils.IntegerHolder((((playerPokemon.getStat(Stat.SPD) * 128) / enemySpeed) + (30 * this.scene.currentBattle.escapeAttempts++)) % 256); - applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, escapeChance); + applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, false, escapeChance); if (playerPokemon.randSeedInt(256) < escapeChance.value) { this.scene.playSound("flee"); diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 5d466e5d3b6..68ede826d95 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -189,7 +189,7 @@ export class CommandPhase extends FieldPhase { const batonPass = isSwitch && args[0] as boolean; const trappedAbMessages: string[] = []; if (!batonPass) { - enemyField.forEach(enemyPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, enemyPokemon, trapped, playerPokemon, true, trappedAbMessages)); + enemyField.forEach(enemyPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, enemyPokemon, trapped, playerPokemon, trappedAbMessages, true)); } if (batonPass || (!trapTag && !trapped.value)) { this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index 739bb1d93f1..dfa198c8339 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -67,7 +67,7 @@ export class EncounterPhase extends BattlePhase { battle.enemyParty[e].ivs = new Array(6).fill(31); } this.scene.getParty().slice(0, !battle.double ? 1 : 2).reverse().forEach(playerPokemon => { - applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, battle.enemyParty[e]); + applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]); }); } } diff --git a/src/phases/enemy-command-phase.ts b/src/phases/enemy-command-phase.ts index d7f553681c2..0b62fcbe813 100644 --- a/src/phases/enemy-command-phase.ts +++ b/src/phases/enemy-command-phase.ts @@ -47,7 +47,7 @@ export class EnemyCommandPhase extends FieldPhase { const trapTag = enemyPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag; const trapped = new Utils.BooleanHolder(false); - opponents.forEach(playerPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, playerPokemon, trapped, enemyPokemon, true, [])); + opponents.forEach(playerPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, playerPokemon, trapped, enemyPokemon, [], true)); if (!trapTag && !trapped.value) { const partyMemberScores = trainer.getPartyMemberMatchupScores(enemyPokemon.trainerSlot, true); diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index a5ac913cc5d..12018656458 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -74,7 +74,7 @@ export class MoveEffectPhase extends PokemonPhase { // Assume single target for multi hit applyMoveAttrs(MultiHitAttr, user, this.getTarget() ?? null, move, hitCount); // If Parental Bond is applicable, double the hit count - applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, targets.length, hitCount, new Utils.IntegerHolder(0)); + applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, false, targets.length, hitCount, new Utils.IntegerHolder(0)); // If Multi-Lens is applicable, multiply the hit count by 1 + the number of Multi-Lenses held by the user if (move instanceof AttackMove && !move.hasAttr(FixedDamageAttr)) { this.scene.applyModifiers(PokemonMultiHitModifier, user.isPlayer(), user, hitCount, new Utils.IntegerHolder(0)); diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index b9656df856b..2aed0bb9495 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -90,7 +90,7 @@ export class MovePhase extends BattlePhase { : null; if (moveTarget) { const oldTarget = moveTarget.value; - this.scene.getField(true).filter(p => p !== this.pokemon).forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, this.move.moveId, moveTarget)); + this.scene.getField(true).filter(p => p !== this.pokemon).forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, false, this.move.moveId, moveTarget)); this.pokemon.getOpponents().forEach(p => { const redirectTag = p.getTag(CenterOfAttentionTag) as CenterOfAttentionTag; if (redirectTag && (!redirectTag.powder || (!this.pokemon.isOfType(Type.GRASS) && !this.pokemon.hasAbility(Abilities.OVERCOAT)))) { diff --git a/src/phases/post-turn-status-effect-phase.ts b/src/phases/post-turn-status-effect-phase.ts index 8b533f2e90a..47db32303a5 100644 --- a/src/phases/post-turn-status-effect-phase.ts +++ b/src/phases/post-turn-status-effect-phase.ts @@ -34,7 +34,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { break; case StatusEffect.BURN: damage.value = Math.max(pokemon.getMaxHp() >> 4, 1); - applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, damage); + applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage); break; } if (damage.value) { diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 67ae904fb58..57b842e7b38 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -205,7 +205,7 @@ export class SelectModifierPhase extends BattlePhase { return true; } - getRerollCost(typeOptions: ModifierTypeOption[], lockRarities: boolean): integer { + getRerollCost(typeOptions: ModifierTypeOption[], lockRarities: boolean): number { let baseValue = 0; if (Overrides.WAIVE_ROLL_FEE_OVERRIDE) { return baseValue; diff --git a/src/phases/stat-change-phase.ts b/src/phases/stat-change-phase.ts index 3469cc62942..fec3da9bc9a 100644 --- a/src/phases/stat-change-phase.ts +++ b/src/phases/stat-change-phase.ts @@ -68,7 +68,7 @@ export class StatChangePhase extends PokemonPhase { const levels = new Utils.IntegerHolder(this.levels); if (!this.ignoreAbilities) { - applyAbAttrs(StatChangeMultiplierAbAttr, pokemon, null, levels); + applyAbAttrs(StatChangeMultiplierAbAttr, pokemon, null, false, levels); } const battleStats = this.getPokemon().summonData.battleStats; @@ -90,7 +90,7 @@ export class StatChangePhase extends PokemonPhase { if (levels.value > 0 && this.canBeCopied) { for (const opponent of pokemon.getOpponents()) { - applyAbAttrs(StatChangeCopyAbAttr, opponent, null, this.stats, levels.value); + applyAbAttrs(StatChangeCopyAbAttr, opponent, null, false, this.stats, levels.value); } } diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index d43f57ace57..394dacd1854 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -65,8 +65,8 @@ export class TurnStartPhase extends FieldPhase { this.scene.getField(true).filter(p => p.summonData).map(p => { const bypassSpeed = new Utils.BooleanHolder(false); const canCheckHeldItems = new Utils.BooleanHolder(true); - applyAbAttrs(BypassSpeedChanceAbAttr, p, null, bypassSpeed); - applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, bypassSpeed, canCheckHeldItems); + applyAbAttrs(BypassSpeedChanceAbAttr, p, null, false, bypassSpeed); + applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, false, bypassSpeed, canCheckHeldItems); if (canCheckHeldItems.value) { this.scene.applyModifiers(BypassSpeedChanceModifier, p.isPlayer(), p, bypassSpeed); } @@ -97,8 +97,8 @@ export class TurnStartPhase extends FieldPhase { applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority); //TODO: is the bang correct here? applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority); //TODO: is the bang correct here? - applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority); //TODO: is the bang correct here? - applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority); //TODO: is the bang correct here? + applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, false, aMove, aPriority); //TODO: is the bang correct here? + applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, false, bMove, bPriority); //TODO: is the bang correct here? // The game now checks for differences in priority levels. // If the moves share the same original priority bracket, it can check for differences in battlerBypassSpeed and return the result. diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 33f00d22555..b786787f83e 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -26,6 +26,7 @@ const unicodeRanges = { kana: "U+3040-30FF", CJKCommon: "U+2E80-2EFF,U+3000-303F,U+31C0-31EF,U+3200-32FF,U+3400-4DBF,U+F900-FAFF,U+FE30-FE4F", CJKIdeograph: "U+4E00-9FFF", + specialCharacters: "U+266A,U+2605,U+2665,U+2663" //♪.★,♥,♣ }; const rangesByLanguage = { korean: [unicodeRanges.CJKCommon, unicodeRanges.hangul].join(","), @@ -34,6 +35,15 @@ const rangesByLanguage = { }; const fonts: Array = [ + // unicode (special character from PokePT) + { + face: new FontFace("emerald", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: unicodeRanges.specialCharacters }), + }, + { + face: new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: unicodeRanges.specialCharacters }), + extraOptions: { sizeAdjust: "133%" }, + }, + // unicode (korean) { face: new FontFace("emerald", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: rangesByLanguage.korean }), }, diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index 7263ae3a3de..4bd69788f04 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -9,6 +9,7 @@ import { EaseType } from "#enums/ease-type"; import { MoneyFormat } from "#enums/money-format"; import { PlayerGender } from "#enums/player-gender"; import { getIsInitialized, initI18n } from "#app/plugins/i18n.js"; +import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; function getTranslation(key: string): string { if (!getIsInitialized()) { @@ -102,6 +103,7 @@ export const SettingKeys = { Damage_Numbers: "DAMAGE_NUMBERS", Move_Animations: "MOVE_ANIMATIONS", Show_Stats_on_Level_Up: "SHOW_LEVEL_UP_STATS", + Reroll_Target: "REROLL_TARGET", Candy_Upgrade_Notification: "CANDY_UPGRADE_NOTIFICATION", Candy_Upgrade_Display: "CANDY_UPGRADE_DISPLAY", Move_Info: "MOVE_INFO", @@ -577,6 +579,30 @@ export const Setting: Array = [ activatable: true, isHidden: () => !hasTouchscreen() }, + { + key: SettingKeys.Reroll_Target, + label: i18next.t("settings:shopCursorTarget"), + options: [ + { + value:"Reroll", + label: i18next.t("settings:reroll") + }, + { + value:"Items", + label: i18next.t("settings:items") + }, + { + value:"Shop", + label: i18next.t("settings:shop") + }, + { + value:"Check Team", + label: i18next.t("settings:checkTeam") + } + ], + default: ShopCursorTarget.CHECK_TEAM, + type: SettingType.DISPLAY + }, { key: SettingKeys.Shop_Overlay_Opacity, label: i18next.t("settings:shopOverlayOpacity"), @@ -709,6 +735,8 @@ export function setSetting(scene: BattleScene, setting: string, value: integer): case SettingKeys.Show_Stats_on_Level_Up: scene.showLevelUpStats = Setting[index].options[value].value === "On"; break; + case SettingKeys.Reroll_Target: + scene.shopCursorTarget = value; case SettingKeys.EXP_Gains_Speed: scene.expGainsSpeed = value; break; diff --git a/src/test/abilities/ability_timing.test.ts b/src/test/abilities/ability_timing.test.ts index c117c62d45b..3238f880992 100644 --- a/src/test/abilities/ability_timing.test.ts +++ b/src/test/abilities/ability_timing.test.ts @@ -1,15 +1,15 @@ +import { CommandPhase } from "#app/phases/command-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import i18next, { initI18n } from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Ability Timing", () => { diff --git a/src/test/abilities/aura_break.test.ts b/src/test/abilities/aura_break.test.ts index bca400bc0e3..7de300c157a 100644 --- a/src/test/abilities/aura_break.test.ts +++ b/src/test/abilities/aura_break.test.ts @@ -1,19 +1,18 @@ -import { allMoves } from "#app/data/move.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; describe("Abilities - Aura Break", () => { let phaserGame: Phaser.Game; let game: GameManager; - const auraBreakMultiplier = 9/16 * 4/3; + const auraBreakMultiplier = 9 / 16 * 4 / 3; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -42,7 +41,7 @@ describe("Abilities - Aura Break", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.MOONBLAST)); + game.move.select(Moves.MOONBLAST); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(expect.closeTo(basePower * auraBreakMultiplier)); @@ -56,7 +55,7 @@ describe("Abilities - Aura Break", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DARK_PULSE)); + game.move.select(Moves.DARK_PULSE); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(expect.closeTo(basePower * auraBreakMultiplier)); diff --git a/src/test/abilities/battery.test.ts b/src/test/abilities/battery.test.ts index 766c1c30ecc..020866509d6 100644 --- a/src/test/abilities/battery.test.ts +++ b/src/test/abilities/battery.test.ts @@ -1,14 +1,13 @@ -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Abilities - Battery", () => { let phaserGame: Phaser.Game; @@ -43,8 +42,8 @@ describe("Abilities - Battery", () => { await game.startBattle([Species.PIKACHU, Species.CHARJABUG]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.DAZZLING_GLEAM); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * batteryMultiplier); @@ -58,8 +57,8 @@ describe("Abilities - Battery", () => { await game.startBattle([Species.PIKACHU, Species.CHARJABUG]); - game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.BREAKING_SWIPE); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); @@ -73,8 +72,8 @@ describe("Abilities - Battery", () => { await game.startBattle([Species.CHARJABUG, Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.DAZZLING_GLEAM); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); diff --git a/src/test/abilities/battle_bond.test.ts b/src/test/abilities/battle_bond.test.ts index c28a00e821d..71e9438db8f 100644 --- a/src/test/abilities/battle_bond.test.ts +++ b/src/test/abilities/battle_bond.test.ts @@ -1,11 +1,10 @@ -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; @@ -53,7 +52,7 @@ describe("Abilities - BATTLE BOND", () => { greninja!.status = new Status(StatusEffect.FAINT); expect(greninja!.isFainted()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); diff --git a/src/test/abilities/costar.test.ts b/src/test/abilities/costar.test.ts index 9410ee55069..9a4baeef1fb 100644 --- a/src/test/abilities/costar.test.ts +++ b/src/test/abilities/costar.test.ts @@ -1,14 +1,13 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; +import { BattleStat } from "#app/data/battle-stat"; +import { Abilities } from "#app/enums/abilities"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { CommandPhase } from "#app/phases/command-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; const TIMEOUT = 20 * 1000; @@ -44,15 +43,15 @@ describe("Abilities - COSTAR", () => { let [leftPokemon, rightPokemon] = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.NASTY_PLOT)); + game.move.select(Moves.NASTY_PLOT); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.toNextTurn(); expect(leftPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2); expect(rightPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(CommandPhase); game.doSwitchPokemon(2); await game.phaseInterceptor.to(MessagePhase); @@ -76,7 +75,7 @@ describe("Abilities - COSTAR", () => { expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2); expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(CommandPhase); game.doSwitchPokemon(2); await game.phaseInterceptor.to(MessagePhase); diff --git a/src/test/abilities/disguise.test.ts b/src/test/abilities/disguise.test.ts index 969375c397e..58087b408a5 100644 --- a/src/test/abilities/disguise.test.ts +++ b/src/test/abilities/disguise.test.ts @@ -1,17 +1,17 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { StatusEffect } from "#app/data/status-effect"; +import { CommandPhase } from "#app/phases/command-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; +import { Mode } from "#app/ui/ui"; +import { toDmgValue } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; -import { StatusEffect } from "#app/data/status-effect.js"; -import { BattleStat } from "#app/data/battle-stat.js"; +import GameManager from "#test/utils/gameManager"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { Mode } from "#app/ui/ui.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; const TIMEOUT = 20 * 1000; @@ -47,11 +47,11 @@ describe("Abilities - Disguise", () => { const mimikyu = game.scene.getEnemyPokemon()!; const maxHp = mimikyu.getMaxHp(); - const disguiseDamage = Math.floor(maxHp / 8); + const disguiseDamage = toDmgValue(maxHp / 8); expect(mimikyu.formIndex).toBe(disguisedForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to(MoveEndPhase); @@ -66,7 +66,7 @@ describe("Abilities - Disguise", () => { expect(mimikyu.formIndex).toBe(disguisedForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.VACUUM_WAVE)); + game.move.select(Moves.VACUUM_WAVE); await game.phaseInterceptor.to(MoveEndPhase); @@ -80,11 +80,11 @@ describe("Abilities - Disguise", () => { const mimikyu = game.scene.getEnemyPokemon()!; const maxHp = mimikyu.getMaxHp(); - const disguiseDamage = Math.floor(maxHp / 8); + const disguiseDamage = toDmgValue(maxHp / 8); expect(mimikyu.formIndex).toBe(disguisedForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURGING_STRIKES)); + game.move.select(Moves.SURGING_STRIKES); // First hit await game.phaseInterceptor.to(MoveEffectPhase); @@ -103,7 +103,7 @@ describe("Abilities - Disguise", () => { const mimikyu = game.scene.getEnemyPokemon()!; expect(mimikyu.hp).toBe(mimikyu.getMaxHp()); - game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC_THREAD)); + game.move.select(Moves.TOXIC_THREAD); await game.phaseInterceptor.to(TurnEndPhase); @@ -121,9 +121,9 @@ describe("Abilities - Disguise", () => { const mimikyu = game.scene.getPlayerPokemon()!; const maxHp = mimikyu.getMaxHp(); - const disguiseDamage = Math.floor(maxHp / 8); + const disguiseDamage = toDmgValue(maxHp / 8); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -148,7 +148,7 @@ describe("Abilities - Disguise", () => { const mimikyu = game.scene.getParty()[1]!; expect(mimikyu.formIndex).toBe(bustedForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.toNextWave(); @@ -168,7 +168,7 @@ describe("Abilities - Disguise", () => { expect(mimikyu.formIndex).toBe(bustedForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.toNextWave(); @@ -188,11 +188,11 @@ describe("Abilities - Disguise", () => { expect(mimikyu1.formIndex).toBe(bustedForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.killPokemon(mimikyu1); game.doSelectPartyPokemon(1); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { // TODO: Make tests run in set mode instead of switch mode game.setMode(Mode.MESSAGE); diff --git a/src/test/abilities/dry_skin.test.ts b/src/test/abilities/dry_skin.test.ts index 1e3860da985..b337e4d96f7 100644 --- a/src/test/abilities/dry_skin.test.ts +++ b/src/test/abilities/dry_skin.test.ts @@ -1,12 +1,11 @@ -import { Species } from "#app/enums/species.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { Species } from "#app/enums/species"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Abilities - Dry Skin", () => { let phaserGame: Phaser.Game; @@ -43,13 +42,13 @@ describe("Abilities - Dry Skin", () => { // first turn let previousEnemyHp = enemy.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.SUNNY_DAY)); + game.move.select(Moves.SUNNY_DAY); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBeLessThan(previousEnemyHp); // second turn previousEnemyHp = enemy.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBeLessThan(previousEnemyHp); }); @@ -66,13 +65,13 @@ describe("Abilities - Dry Skin", () => { // first turn let previousEnemyHp = enemy.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.RAIN_DANCE)); + game.move.select(Moves.RAIN_DANCE); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBeGreaterThan(previousEnemyHp); // second turn previousEnemyHp = enemy.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBeGreaterThan(previousEnemyHp); }); @@ -87,7 +86,7 @@ describe("Abilities - Dry Skin", () => { enemy.hp = initialHP; // first turn - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); + game.move.select(Moves.FLAMETHROWER); await game.phaseInterceptor.to(TurnEndPhase); const fireDamageTakenWithDrySkin = initialHP - enemy.hp; @@ -96,7 +95,7 @@ describe("Abilities - Dry Skin", () => { game.override.enemyAbility(Abilities.NONE); // second turn - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); + game.move.select(Moves.FLAMETHROWER); await game.phaseInterceptor.to(TurnEndPhase); const fireDamageTakenWithoutDrySkin = initialHP - enemy.hp; @@ -113,7 +112,7 @@ describe("Abilities - Dry Skin", () => { enemy.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); + game.move.select(Moves.WATER_GUN); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBeGreaterThan(1); }); @@ -129,7 +128,7 @@ describe("Abilities - Dry Skin", () => { enemy.hp = 1; game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]); - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); + game.move.select(Moves.WATER_GUN); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBe(1); }); @@ -145,14 +144,14 @@ describe("Abilities - Dry Skin", () => { enemy.hp = 1; // first turn - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_SHURIKEN)); + game.move.select(Moves.WATER_SHURIKEN); await game.phaseInterceptor.to(TurnEndPhase); const healthGainedFromWaterShuriken = enemy.hp - 1; enemy.hp = 1; // second turn - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); + game.move.select(Moves.WATER_GUN); await game.phaseInterceptor.to(TurnEndPhase); const healthGainedFromWaterGun = enemy.hp - 1; diff --git a/src/test/abilities/flash_fire.test.ts b/src/test/abilities/flash_fire.test.ts index 28c59903b68..de40873998f 100644 --- a/src/test/abilities/flash_fire.test.ts +++ b/src/test/abilities/flash_fire.test.ts @@ -1,16 +1,15 @@ -import { Species } from "#app/enums/species.js"; -import GameManager from "#test/utils/gameManager"; +import { BattlerIndex } from "#app/battle"; +import { StatusEffect } from "#app/data/status-effect"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { Species } from "#app/enums/species"; +import { MovePhase } from "#app/phases/move-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { StatusEffect } from "#app/data/status-effect.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { BattlerIndex } from "#app/battle.js"; -import { MovePhase } from "#app/phases/move-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Abilities - Flash Fire", () => { let phaserGame: Phaser.Game; @@ -38,35 +37,35 @@ describe("Abilities - Flash Fire", () => { }); - it("immune to Fire-type moves", async() => { + it("immune to Fire-type moves", async () => { game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset(SPLASH_ONLY); await game.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(blissey.hp).toBe(blissey.getMaxHp()); }, 20000); - it("not activate if the Pokémon is protected from the Fire-type move", async() => { + it("not activate if the Pokémon is protected from the Fire-type move", async () => { game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset([Moves.PROTECT]); await game.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); + game.move.select(Moves.PROTECT); await game.phaseInterceptor.to(TurnEndPhase); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined(); }, 20000); - it("activated by Will-O-Wisp", async() => { + it("activated by Will-O-Wisp", async () => { game.override.enemyMoveset(Array(4).fill(Moves.WILL_O_WISP)).moveset(SPLASH_ONLY); await game.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.move.forceHit(); await game.phaseInterceptor.to(MovePhase, false); await game.move.forceHit(); @@ -75,25 +74,25 @@ describe("Abilities - Flash Fire", () => { expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined(); }, 20000); - it("activated after being frozen", async() => { + it("activated after being frozen", async () => { game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset(SPLASH_ONLY); game.override.statusEffect(StatusEffect.FREEZE); await game.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined(); }, 20000); - it("not passing with baton pass", async() => { + it("not passing with baton pass", async () => { game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset([Moves.BATON_PASS]); await game.startBattle([Species.BLISSEY, Species.CHANSEY]); // ensure use baton pass after enemy moved - game.doAttack(getMovePosition(game.scene, 0, Moves.BATON_PASS)); + game.move.select(Moves.BATON_PASS); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); @@ -104,7 +103,7 @@ describe("Abilities - Flash Fire", () => { expect(chansey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined(); }, 20000); - it("boosts Fire-type move when the ability is activated", async() => { + it("boosts Fire-type move when the ability is activated", async () => { game.override.enemyMoveset(Array(4).fill(Moves.FIRE_PLEDGE)).moveset([Moves.EMBER, Moves.SPLASH]); game.override.enemyAbility(Abilities.FLASH_FIRE).ability(Abilities.NONE); await game.startBattle([Species.BLISSEY]); @@ -113,7 +112,7 @@ describe("Abilities - Flash Fire", () => { blissey.hp = initialHP; // first turn - game.doAttack(getMovePosition(game.scene, 0, Moves.EMBER)); + game.move.select(Moves.EMBER); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(TurnEndPhase); const originalDmg = initialHP - blissey.hp; @@ -122,7 +121,7 @@ describe("Abilities - Flash Fire", () => { blissey.hp = initialHP; // second turn - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); const flashFireDmg = initialHP - blissey.hp; diff --git a/src/test/abilities/gulp_missile.test.ts b/src/test/abilities/gulp_missile.test.ts index d033604fe00..a451d290906 100644 --- a/src/test/abilities/gulp_missile.test.ts +++ b/src/test/abilities/gulp_missile.test.ts @@ -1,19 +1,18 @@ -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; +import { BattleStat } from "#app/data/battle-stat"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { StatusEffect } from "#app/enums/status-effect"; +import Pokemon from "#app/field/pokemon"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { TurnStartPhase } from "#app/phases/turn-start-phase"; import GameManager from "#app/test/utils/gameManager"; -import { getMovePosition } from "#app/test/utils/gameManagerUtils"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { StatusEffect } from "#app/enums/status-effect.js"; -import Pokemon from "#app/field/pokemon.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; describe("Abilities - Gulp Missile", () => { let phaserGame: Phaser.Game; @@ -30,7 +29,7 @@ describe("Abilities - Gulp Missile", () => { * @returns The effect damage of Gulp Missile */ const getEffectDamage = (pokemon: Pokemon): number => { - return Math.max(1, Math.floor(pokemon.getMaxHp() * 1/4)); + return Math.max(1, Math.floor(pokemon.getMaxHp() * 1 / 4)); }; beforeAll(() => { @@ -58,9 +57,9 @@ describe("Abilities - Gulp Missile", () => { await game.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); + game.move.select(Moves.DIVE); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); + game.move.select(Moves.DIVE); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getHpRatio()).toBeGreaterThanOrEqual(.5); @@ -75,7 +74,7 @@ describe("Abilities - Gulp Missile", () => { vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.49); expect(cramorant.getHpRatio()).toBe(.49); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined(); @@ -86,7 +85,7 @@ describe("Abilities - Gulp Missile", () => { await game.startBattle([Species.CRAMORANT, Species.MAGIKARP]); const cramorant = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.toNextTurn(); game.doSwitchPokemon(1); @@ -101,7 +100,7 @@ describe("Abilities - Gulp Missile", () => { await game.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); + game.move.select(Moves.DIVE); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); @@ -115,7 +114,7 @@ describe("Abilities - Gulp Missile", () => { const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "damageAndUpdate"); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.damageAndUpdate).toHaveReturnedWith(getEffectDamage(enemy)); @@ -128,7 +127,7 @@ describe("Abilities - Gulp Missile", () => { const cramorant = game.scene.getPlayerPokemon()!; vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); @@ -150,7 +149,7 @@ describe("Abilities - Gulp Missile", () => { vi.spyOn(enemy, "damageAndUpdate"); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); @@ -174,7 +173,7 @@ describe("Abilities - Gulp Missile", () => { vi.spyOn(enemy, "damageAndUpdate"); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.45); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined(); @@ -194,7 +193,7 @@ describe("Abilities - Gulp Missile", () => { const cramorant = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); + game.move.select(Moves.DIVE); await game.phaseInterceptor.to(BerryPhase, false); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); @@ -210,7 +209,7 @@ describe("Abilities - Gulp Missile", () => { vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); const enemyHpPreEffect = enemy.hp; @@ -232,7 +231,7 @@ describe("Abilities - Gulp Missile", () => { const cramorant = game.scene.getPlayerPokemon()!; vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); @@ -252,7 +251,7 @@ describe("Abilities - Gulp Missile", () => { const cramorant = game.scene.getPlayerPokemon()!; vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(MoveEndPhase); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); @@ -269,7 +268,7 @@ describe("Abilities - Gulp Missile", () => { game.override.enemyAbility(Abilities.TRACE); await game.startBattle([Species.CRAMORANT]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnStartPhase); expect(game.scene.getEnemyPokemon()?.hasAbility(Abilities.GULP_MISSILE)).toBe(false); diff --git a/src/test/abilities/heatproof.test.ts b/src/test/abilities/heatproof.test.ts index 64a45c5023f..e2a558e6d99 100644 --- a/src/test/abilities/heatproof.test.ts +++ b/src/test/abilities/heatproof.test.ts @@ -1,13 +1,13 @@ -import { Species } from "#app/enums/species.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { Species } from "#app/enums/species"; +import { StatusEffect } from "#app/enums/status-effect"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { toDmgValue } from "#app/utils"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { StatusEffect } from "#app/enums/status-effect.js"; describe("Abilities - Heatproof", () => { let phaserGame: Phaser.Game; @@ -45,14 +45,14 @@ describe("Abilities - Heatproof", () => { const initialHP = 1000; enemy.hp = initialHP; - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); + game.move.select(Moves.FLAMETHROWER); await game.phaseInterceptor.to(TurnEndPhase); const heatproofDamage = initialHP - enemy.hp; enemy.hp = initialHP; game.override.enemyAbility(Abilities.BALL_FETCH); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); + game.move.select(Moves.FLAMETHROWER); await game.phaseInterceptor.to(TurnEndPhase); const regularDamage = initialHP - enemy.hp; @@ -68,10 +68,10 @@ describe("Abilities - Heatproof", () => { const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.toNextTurn(); // Normal burn damage is /16 - expect(enemy.hp).toBe(enemy.getMaxHp() - Math.floor(enemy.getMaxHp() / 32)); + expect(enemy.hp).toBe(enemy.getMaxHp() - toDmgValue(enemy.getMaxHp() / 32)); }); }); diff --git a/src/test/abilities/hustle.test.ts b/src/test/abilities/hustle.test.ts index 8f5547a5518..b7c3b723c4b 100644 --- a/src/test/abilities/hustle.test.ts +++ b/src/test/abilities/hustle.test.ts @@ -1,15 +1,14 @@ -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { Stat } from "#app/enums/stat.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { Stat } from "#app/enums/stat"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; describe("Abilities - Hustle", () => { let phaserGame: Phaser.Game; @@ -44,7 +43,7 @@ describe("Abilities - Hustle", () => { vi.spyOn(pikachu, "getBattleStat"); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -57,7 +56,7 @@ describe("Abilities - Hustle", () => { vi.spyOn(pikachu, "getAccuracyMultiplier"); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase); expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(0.8); @@ -71,7 +70,7 @@ describe("Abilities - Hustle", () => { vi.spyOn(pikachu, "getBattleStat"); vi.spyOn(pikachu, "getAccuracyMultiplier"); - game.doAttack(getMovePosition(game.scene, 0, Moves.GIGA_DRAIN)); + game.move.select(Moves.GIGA_DRAIN); await game.phaseInterceptor.to(DamagePhase); expect(pikachu.getBattleStat).toHaveReturnedWith(spatk); @@ -89,7 +88,7 @@ describe("Abilities - Hustle", () => { vi.spyOn(pikachu, "getAccuracyMultiplier"); vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy"); - game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); + game.move.select(Moves.FISSURE); await game.phaseInterceptor.to(DamagePhase); expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp()); diff --git a/src/test/abilities/hyper_cutter.test.ts b/src/test/abilities/hyper_cutter.test.ts index 9637a80ddb4..28fcc2f6085 100644 --- a/src/test/abilities/hyper_cutter.test.ts +++ b/src/test/abilities/hyper_cutter.test.ts @@ -3,7 +3,6 @@ import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -40,16 +39,16 @@ describe("Abilities - Hyper Cutter", () => { const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.OCTOLOCK)); + game.move.select(Moves.OCTOLOCK); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.DEFOG)); + game.move.select(Moves.DEFOG); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.NOBLE_ROAR)); + game.move.select(Moves.NOBLE_ROAR); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SAND_ATTACK)); + game.move.select(Moves.SAND_ATTACK); await game.toNextTurn(); game.override.moveset([Moves.STRING_SHOT]); - game.doAttack(getMovePosition(game.scene, 0, Moves.STRING_SHOT)); + game.move.select(Moves.STRING_SHOT); await game.toNextTurn(); expect(enemy.summonData.battleStats[BattleStat.ATK]).toEqual(0); diff --git a/src/test/abilities/ice_face.test.ts b/src/test/abilities/ice_face.test.ts index 905e0dfdaf7..fbc660c27c2 100644 --- a/src/test/abilities/ice_face.test.ts +++ b/src/test/abilities/ice_face.test.ts @@ -1,16 +1,15 @@ -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Abilities - Ice Face", () => { let phaserGame: Phaser.Game; @@ -39,7 +38,7 @@ describe("Abilities - Ice Face", () => { it("takes no damage from physical move and transforms to Noice", async () => { await game.startBattle([Species.HITMONLEE]); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEndPhase); @@ -55,7 +54,7 @@ describe("Abilities - Ice Face", () => { game.override.enemyLevel(1); await game.startBattle([Species.HITMONLEE]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURGING_STRIKES)); + game.move.select(Moves.SURGING_STRIKES); const eiscue = game.scene.getEnemyPokemon()!; expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeDefined(); @@ -81,7 +80,7 @@ describe("Abilities - Ice Face", () => { it("takes damage from special moves", async () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); + game.move.select(Moves.ICE_BEAM); await game.phaseInterceptor.to(MoveEndPhase); @@ -95,7 +94,7 @@ describe("Abilities - Ice Face", () => { it("takes effects from status moves", async () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC_THREAD)); + game.move.select(Moves.TOXIC_THREAD); await game.phaseInterceptor.to(MoveEndPhase); @@ -111,7 +110,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); + game.move.select(Moves.QUICK_ATTACK); await game.phaseInterceptor.to(MoveEndPhase); @@ -133,7 +132,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.EISCUE, Species.NINJASK]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SNOWSCAPE)); + game.move.select(Moves.SNOWSCAPE); await game.phaseInterceptor.to(TurnEndPhase); let eiscue = game.scene.getPlayerPokemon()!; @@ -160,7 +159,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.EISCUE]); - game.doAttack(getMovePosition(game.scene, 0, Moves.HAIL)); + game.move.select(Moves.HAIL); const eiscue = game.scene.getPlayerPokemon()!; await game.phaseInterceptor.to(QuietFormChangePhase); @@ -179,7 +178,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.EISCUE, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); + game.move.select(Moves.ICE_BEAM); await game.phaseInterceptor.to(TurnEndPhase); let eiscue = game.scene.getPlayerPokemon()!; @@ -213,7 +212,7 @@ describe("Abilities - Ice Face", () => { expect(eiscue.formIndex).toBe(noiceForm); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); + game.move.select(Moves.ICE_BEAM); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); @@ -228,7 +227,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.GASTRO_ACID)); + game.move.select(Moves.GASTRO_ACID); await game.phaseInterceptor.to(TurnEndPhase); @@ -244,7 +243,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SKILL_SWAP)); + game.move.select(Moves.SKILL_SWAP); await game.phaseInterceptor.to(TurnEndPhase); @@ -260,7 +259,7 @@ describe("Abilities - Ice Face", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SIMPLE_BEAM)); + game.move.select(Moves.SIMPLE_BEAM); await game.phaseInterceptor.to(TurnInitPhase); diff --git a/src/test/abilities/intimidate.test.ts b/src/test/abilities/intimidate.test.ts index 842b33108a3..93b663d06da 100644 --- a/src/test/abilities/intimidate.test.ts +++ b/src/test/abilities/intimidate.test.ts @@ -1,22 +1,21 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Mode } from "#app/ui/ui"; import { BattleStat } from "#app/data/battle-stat"; -import { generateStarter, getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; import { Status, StatusEffect } from "#app/data/status-effect"; import { GameModes, getGameMode } from "#app/game-mode"; +import { CommandPhase } from "#app/phases/command-phase"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { EncounterPhase } from "#app/phases/encounter-phase"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { SelectStarterPhase } from "#app/phases/select-starter-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; +import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { generateStarter } from "#test/utils/gameManagerUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { EncounterPhase } from "#app/phases/encounter-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Abilities - Intimidate", () => { let phaserGame: Phaser.Game; @@ -217,13 +216,7 @@ describe("Abilities - Intimidate", () => { let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.AERIAL_ACE); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(DamagePhase); await game.killPokemon(game.scene.currentBattle.enemyParty[0]); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); @@ -243,13 +236,7 @@ describe("Abilities - Intimidate", () => { let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.AERIAL_ACE); console.log("===to new turn==="); await game.toNextTurn(); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; @@ -268,13 +255,7 @@ describe("Abilities - Intimidate", () => { let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.AERIAL_ACE); console.log("===to new turn==="); await game.toNextTurn(); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; @@ -282,13 +263,7 @@ describe("Abilities - Intimidate", () => { battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; expect(battleStatsOpponent[BattleStat.ATK]).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.AERIAL_ACE); console.log("===to new turn==="); await game.toNextTurn(); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; @@ -307,13 +282,7 @@ describe("Abilities - Intimidate", () => { let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.AERIAL_ACE); console.log("===to new turn==="); await game.toNextTurn(); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; @@ -321,13 +290,7 @@ describe("Abilities - Intimidate", () => { battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.AERIAL_ACE); console.log("===to new turn==="); await game.toNextTurn(); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; diff --git a/src/test/abilities/intrepid_sword.test.ts b/src/test/abilities/intrepid_sword.test.ts index c1c05b59997..18d6c04adbc 100644 --- a/src/test/abilities/intrepid_sword.test.ts +++ b/src/test/abilities/intrepid_sword.test.ts @@ -1,10 +1,10 @@ import { BattleStat } from "#app/data/battle-stat"; -import GameManager from "#test/utils/gameManager"; +import { CommandPhase } from "#app/phases/command-phase"; import { Abilities } from "#enums/abilities"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; describe("Abilities - Intrepid Sword", () => { diff --git a/src/test/abilities/libero.test.ts b/src/test/abilities/libero.test.ts index d35cb8b6e2d..16597e90285 100644 --- a/src/test/abilities/libero.test.ts +++ b/src/test/abilities/libero.test.ts @@ -1,18 +1,17 @@ -import { allMoves } from "#app/data/move.js"; -import { Type } from "#app/data/type.js"; -import { Weather, WeatherType } from "#app/data/weather.js"; -import { PlayerPokemon } from "#app/field/pokemon.js"; +import { allMoves } from "#app/data/move"; +import { Type } from "#app/data/type"; +import { Weather, WeatherType } from "#app/data/weather"; +import { PlayerPokemon } from "#app/field/pokemon"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Biome } from "#enums/biome"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -49,7 +48,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); @@ -67,12 +66,12 @@ describe("Abilities - Libero", () => { let leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - game.doAttack(getMovePosition(game.scene, 0, Moves.AGILITY)); + game.move.select(Moves.AGILITY); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.LIBERO)).toHaveLength(1); @@ -89,7 +88,7 @@ describe("Abilities - Libero", () => { leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); @@ -108,7 +107,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.scene.arena.weather = new Weather(WeatherType.SUNNY); - game.doAttack(getMovePosition(game.scene, 0, Moves.WEATHER_BALL)); + game.move.select(Moves.WEATHER_BALL); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); @@ -131,7 +130,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); @@ -154,7 +153,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.scene.arena.biomeType = Biome.MOUNTAIN; - game.doAttack(getMovePosition(game.scene, 0, Moves.NATURE_POWER)); + game.move.select(Moves.NATURE_POWER); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); @@ -172,7 +171,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.DIG)); + game.move.select(Moves.DIG); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); @@ -191,7 +190,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.move.forceMiss(); await game.phaseInterceptor.to(TurnEndPhase); @@ -213,7 +212,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); @@ -232,7 +231,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); @@ -251,7 +250,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); leadPokemon.summonData.types = [allMoves[Moves.SPLASH].defaultType]; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); @@ -271,7 +270,7 @@ describe("Abilities - Libero", () => { vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); @@ -289,7 +288,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE)); + game.move.select(Moves.STRUGGLE); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); @@ -307,7 +306,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.BURN_UP)); + game.move.select(Moves.BURN_UP); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); @@ -326,7 +325,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TRICK_OR_TREAT)); + game.move.select(Moves.TRICK_OR_TREAT); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); @@ -344,7 +343,7 @@ describe("Abilities - Libero", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE)); + game.move.select(Moves.CURSE); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); diff --git a/src/test/abilities/magic_guard.test.ts b/src/test/abilities/magic_guard.test.ts index c7404f83a54..64c1746c7d9 100644 --- a/src/test/abilities/magic_guard.test.ts +++ b/src/test/abilities/magic_guard.test.ts @@ -1,17 +1,16 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { Moves } from "#enums/moves"; -import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagSide, getArenaTag } from "#app/data/arena-tag"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Abilities } from "#enums/abilities"; -import { WeatherType } from "#app/data/weather.js"; import { StatusEffect, getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; +import { WeatherType } from "#app/data/weather"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { Abilities } from "#enums/abilities"; +import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import { SPLASH_ONLY } from "#test/utils/testUtils"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; const TIMEOUT = 20 * 1000; // 20 sec timeout @@ -58,7 +57,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -82,7 +81,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -99,14 +98,14 @@ describe("Abilities - Magic Guard", () => { it( "ability effect should not persist when the ability is replaced", async () => { - game.override.enemyMoveset([Moves.WORRY_SEED,Moves.WORRY_SEED,Moves.WORRY_SEED,Moves.WORRY_SEED]); + game.override.enemyMoveset([Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED]); game.override.statusEffect(StatusEffect.POISON); await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -126,7 +125,7 @@ describe("Abilities - Magic Guard", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -150,7 +149,7 @@ describe("Abilities - Magic Guard", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -180,7 +179,7 @@ describe("Abilities - Magic Guard", () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -206,7 +205,7 @@ describe("Abilities - Magic Guard", () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -233,7 +232,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE)); + game.move.select(Moves.CURSE); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -257,7 +256,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.HIGH_JUMP_KICK)); + game.move.select(Moves.HIGH_JUMP_KICK); await game.move.forceMiss(); await game.phaseInterceptor.to(TurnEndPhase); @@ -276,7 +275,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.TAKE_DOWN)); + game.move.select(Moves.TAKE_DOWN); await game.phaseInterceptor.to(TurnEndPhase); @@ -294,7 +293,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE)); + game.move.select(Moves.STRUGGLE); await game.phaseInterceptor.to(TurnEndPhase); @@ -313,7 +312,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.STEEL_BEAM)); + game.move.select(Moves.STEEL_BEAM); await game.phaseInterceptor.to(TurnEndPhase); @@ -329,7 +328,7 @@ describe("Abilities - Magic Guard", () => { it("Magic Guard does not prevent self-damage from confusion", async () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); + game.move.select(Moves.CHARM); await game.phaseInterceptor.to(TurnEndPhase); }); @@ -341,7 +340,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); + game.move.select(Moves.BELLY_DRUM); await game.phaseInterceptor.to(TurnEndPhase); @@ -353,7 +352,7 @@ describe("Abilities - Magic Guard", () => { }, TIMEOUT ); - it("Magic Guard prevents damage from abilities with PostTurnHurtIfSleepingAbAttr", async() => { + it("Magic Guard prevents damage from abilities with PostTurnHurtIfSleepingAbAttr", async () => { //Tests the ability Bad Dreams game.override.statusEffect(StatusEffect.SLEEP); //enemy pokemon is given Spore just in case player pokemon somehow awakens during test @@ -364,7 +363,7 @@ describe("Abilities - Magic Guard", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -378,7 +377,7 @@ describe("Abilities - Magic Guard", () => { }, TIMEOUT ); - it("Magic Guard prevents damage from abilities with PostFaintContactDamageAbAttr", async() => { + it("Magic Guard prevents damage from abilities with PostFaintContactDamageAbAttr", async () => { //Tests the abilities Innards Out/Aftermath game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.AFTERMATH); @@ -390,7 +389,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); /** @@ -403,7 +402,7 @@ describe("Abilities - Magic Guard", () => { }, TIMEOUT ); - it("Magic Guard prevents damage from abilities with PostDefendContactDamageAbAttr", async() => { + it("Magic Guard prevents damage from abilities with PostDefendContactDamageAbAttr", async () => { //Tests the abilities Iron Barbs/Rough Skin game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.IRON_BARBS); @@ -414,7 +413,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); /** @@ -427,7 +426,7 @@ describe("Abilities - Magic Guard", () => { }, TIMEOUT ); - it("Magic Guard prevents damage from abilities with ReverseDrainAbAttr", async() => { + it("Magic Guard prevents damage from abilities with ReverseDrainAbAttr", async () => { //Tests the ability Liquid Ooze game.override.moveset([Moves.ABSORB]); game.override.enemyAbility(Abilities.LIQUID_OOZE); @@ -438,7 +437,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.ABSORB)); + game.move.select(Moves.ABSORB); await game.phaseInterceptor.to(TurnEndPhase); /** @@ -451,14 +450,14 @@ describe("Abilities - Magic Guard", () => { }, TIMEOUT ); - it("Magic Guard prevents HP loss from abilities with PostWeatherLapseDamageAbAttr", async() => { + it("Magic Guard prevents HP loss from abilities with PostWeatherLapseDamageAbAttr", async () => { //Tests the abilities Solar Power/Dry Skin game.override.passiveAbility(Abilities.SOLAR_POWER); game.override.weather(WeatherType.SUNNY); await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); /** diff --git a/src/test/abilities/moxie.test.ts b/src/test/abilities/moxie.test.ts index 6550dcab526..6a1838c9a98 100644 --- a/src/test/abilities/moxie.test.ts +++ b/src/test/abilities/moxie.test.ts @@ -1,17 +1,13 @@ import { BattleStat } from "#app/data/battle-stat"; import { Stat } from "#app/data/pokemon-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { VictoryPhase } from "#app/phases/victory-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { VictoryPhase } from "#app/phases/victory-phase.js"; describe("Abilities - Moxie", () => { @@ -37,10 +33,10 @@ describe("Abilities - Moxie", () => { game.override.ability(Abilities.MOXIE); game.override.startingLevel(2000); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("MOXIE", async() => { + it("MOXIE", async () => { const moveToUse = Moves.AERIAL_ACE; await game.startBattle([ Species.MIGHTYENA, @@ -50,13 +46,7 @@ describe("Abilities - Moxie", () => { let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[Stat.ATK]).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.ATK]).toBe(1); diff --git a/src/test/abilities/mycelium_might.test.ts b/src/test/abilities/mycelium_might.test.ts index 79716250047..7734ad08dec 100644 --- a/src/test/abilities/mycelium_might.test.ts +++ b/src/test/abilities/mycelium_might.test.ts @@ -1,12 +1,11 @@ +import { BattleStat } from "#app/data/battle-stat"; +import { MovePhase } from "#app/phases/move-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnStartPhase } from "#app/phases/turn-start-phase"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { Abilities } from "#enums/abilities"; -import { BattleStat } from "#app/data/battle-stat"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -42,13 +41,14 @@ describe("Abilities - Mycelium Might", () => { * https://www.smogon.com/forums/threads/scarlet-violet-battle-mechanics-research.3709545/page-24 **/ - it("If a Pokemon with Mycelium Might uses a status move, it will always move last but the status move will ignore protective abilities", async() => { - await game.startBattle([ Species.REGIELEKI ]); + it("will move last in its priority bracket and ignore protective abilities", async () => { + await game.startBattle([Species.REGIELEKI]); const enemyPokemon = game.scene.getEnemyPokemon(); - const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); - const enemyPokemonIndex = enemyPokemon?.getBattlerIndex(); - game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); + const playerIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); + const enemyIndex = enemyPokemon?.getBattlerIndex(); + + game.move.select(Moves.BABY_DOLL_EYES); await game.phaseInterceptor.run(EnemyCommandPhase); const phase = game.scene.getCurrentPhase() as TurnStartPhase; @@ -56,21 +56,22 @@ describe("Abilities - Mycelium Might", () => { const commandOrder = phase.getCommandOrder(); // The opponent Pokemon (without Mycelium Might) goes first despite having lower speed than the player Pokemon. // The player Pokemon (with Mycelium Might) goes last despite having higher speed than the opponent. - expect(speedOrder).toEqual([playerPokemonIndex, enemyPokemonIndex]); - expect(commandOrder).toEqual([enemyPokemonIndex, playerPokemonIndex]); + expect(speedOrder).toEqual([playerIndex, enemyIndex]); + expect(commandOrder).toEqual([enemyIndex, playerIndex]); await game.phaseInterceptor.to(TurnEndPhase); // Despite the opponent's ability (Clear Body), its attack stat is still reduced. expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1); }, 20000); - it("Pokemon with Mycelium Might will go first if a status move that is in a higher priority bracket than the opponent's move is used", async() => { + it("will still go first if a status move that is in a higher priority bracket than the opponent's move is used", async () => { game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); - await game.startBattle([ Species.REGIELEKI ]); + await game.startBattle([Species.REGIELEKI]); const enemyPokemon = game.scene.getEnemyPokemon(); - const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); - const enemyPokemonIndex = enemyPokemon?.getBattlerIndex(); - game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); + const playerIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); + const enemyIndex = enemyPokemon?.getBattlerIndex(); + + game.move.select(Moves.BABY_DOLL_EYES); await game.phaseInterceptor.run(EnemyCommandPhase); const phase = game.scene.getCurrentPhase() as TurnStartPhase; @@ -78,19 +79,20 @@ describe("Abilities - Mycelium Might", () => { const commandOrder = phase.getCommandOrder(); // The player Pokemon (with M.M.) goes first because its move is still within a higher priority bracket than its opponent. // The enemy Pokemon goes second because its move is in a lower priority bracket. - expect(speedOrder).toEqual([playerPokemonIndex, enemyPokemonIndex]); - expect(commandOrder).toEqual([playerPokemonIndex, enemyPokemonIndex]); + expect(speedOrder).toEqual([playerIndex, enemyIndex]); + expect(commandOrder).toEqual([playerIndex, enemyIndex]); await game.phaseInterceptor.to(TurnEndPhase); // Despite the opponent's ability (Clear Body), its attack stat is still reduced. expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1); }, 20000); - it("Order is established normally if the Pokemon uses a non-status move", async() => { - await game.startBattle([ Species.REGIELEKI ]); + it("will not affect non-status moves", async () => { + await game.startBattle([Species.REGIELEKI]); - const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); - const enemyPokemonIndex = game.scene.getEnemyPokemon()?.getBattlerIndex(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); + const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); + const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); + + game.move.select(Moves.QUICK_ATTACK); await game.phaseInterceptor.run(EnemyCommandPhase); const phase = game.scene.getCurrentPhase() as TurnStartPhase; @@ -99,7 +101,7 @@ describe("Abilities - Mycelium Might", () => { // The player Pokemon (with M.M.) goes first because it has a higher speed and did not use a status move. // The enemy Pokemon (without M.M.) goes second because its speed is lower. // This means that the commandOrder should be identical to the speedOrder - expect(speedOrder).toEqual([playerPokemonIndex, enemyPokemonIndex]); - expect(commandOrder).toEqual([playerPokemonIndex, enemyPokemonIndex]); + expect(speedOrder).toEqual([playerIndex, enemyIndex]); + expect(commandOrder).toEqual([playerIndex, enemyIndex]); }, 20000); }); diff --git a/src/test/abilities/parental_bond.test.ts b/src/test/abilities/parental_bond.test.ts index ef0ad7785d2..1404f597ccf 100644 --- a/src/test/abilities/parental_bond.test.ts +++ b/src/test/abilities/parental_bond.test.ts @@ -1,21 +1,21 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { StatusEffect } from "#app/data/status-effect.js"; -import { Type } from "#app/data/type.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; +import { BattleStat } from "#app/data/battle-stat"; +import { StatusEffect } from "#app/data/status-effect"; +import { Type } from "#app/data/type"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { toDmgValue } from "#app/utils"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -60,7 +60,7 @@ describe("Abilities - Parental Bond", () => { let enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -73,7 +73,7 @@ describe("Abilities - Parental Bond", () => { const secondStrikeDamage = enemyStartingHp - enemyPokemon.hp; expect(leadPokemon.turnData.hitCount).toBe(2); - expect(secondStrikeDamage).toBe(Math.ceil(0.25 * firstStrikeDamage)); + expect(secondStrikeDamage).toBe(toDmgValue(0.25 * firstStrikeDamage)); }, TIMEOUT ); @@ -91,7 +91,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_UP_PUNCH)); + game.move.select(Moves.POWER_UP_PUNCH); await game.phaseInterceptor.to(BerryPhase, false); @@ -113,7 +113,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); + game.move.select(Moves.BABY_DOLL_EYES); await game.phaseInterceptor.to(BerryPhase, false); expect(enemyPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-1); @@ -133,7 +133,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.DOUBLE_HIT)); + game.move.select(Moves.DOUBLE_HIT); await game.move.forceHit(); await game.phaseInterceptor.to(BerryPhase, false); @@ -155,7 +155,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SELF_DESTRUCT)); + game.move.select(Moves.SELF_DESTRUCT); await game.phaseInterceptor.to(DamagePhase, false); @@ -176,7 +176,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.ROLLOUT)); + game.move.select(Moves.ROLLOUT); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase, false); @@ -200,7 +200,7 @@ describe("Abilities - Parental Bond", () => { const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(BerryPhase, false); expect(enemyPokemon.hp).toBe(enemyStartingHp - 80); @@ -211,7 +211,7 @@ describe("Abilities - Parental Bond", () => { "ability should not apply multiplier to counter moves", async () => { game.override.moveset([Moves.COUNTER]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle([Species.CHARIZARD]); @@ -224,14 +224,14 @@ describe("Abilities - Parental Bond", () => { const playerStartingHp = leadPokemon.hp; const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.COUNTER)); + game.move.select(Moves.COUNTER); await game.phaseInterceptor.to(DamagePhase); const playerDamage = playerStartingHp - leadPokemon.hp; await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.hp).toBe(enemyStartingHp - 4*playerDamage); + expect(enemyPokemon.hp).toBe(enemyStartingHp - 4 * playerDamage); }, TIMEOUT ); @@ -251,10 +251,10 @@ describe("Abilities - Parental Bond", () => { expect(enemyPokemon.length).toBe(2); enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); - game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); + game.move.select(Moves.EARTHQUAKE); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.EARTHQUAKE)); + game.move.select(Moves.EARTHQUAKE, 1); await game.phaseInterceptor.to(BerryPhase, false); playerPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1)); @@ -274,7 +274,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); + game.move.select(Moves.EARTHQUAKE); await game.phaseInterceptor.to(DamagePhase, false); expect(leadPokemon.turnData.hitCount).toBe(2); @@ -294,7 +294,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.MIND_BLOWN)); + game.move.select(Moves.MIND_BLOWN); await game.phaseInterceptor.to(DamagePhase, false); @@ -303,7 +303,7 @@ describe("Abilities - Parental Bond", () => { // This test will time out if the user faints await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.hp).toBe(Math.floor(leadPokemon.getMaxHp()/2)); + expect(leadPokemon.hp).toBe(toDmgValue(leadPokemon.getMaxHp() / 2)); }, TIMEOUT ); @@ -320,7 +320,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.BURN_UP)); + game.move.select(Moves.BURN_UP); await game.phaseInterceptor.to(DamagePhase); @@ -338,7 +338,7 @@ describe("Abilities - Parental Bond", () => { "Moves boosted by this ability and Multi-Lens should strike 4 times", async () => { game.override.moveset([Moves.TACKLE]); - game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); await game.startBattle([Species.CHARIZARD]); @@ -348,7 +348,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(DamagePhase); @@ -360,7 +360,7 @@ describe("Abilities - Parental Bond", () => { "Super Fang boosted by this ability and Multi-Lens should strike twice", async () => { game.override.moveset([Moves.SUPER_FANG]); - game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); await game.startBattle([Species.CHARIZARD]); @@ -372,7 +372,7 @@ describe("Abilities - Parental Bond", () => { const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.SUPER_FANG)); + game.move.select(Moves.SUPER_FANG); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -389,7 +389,7 @@ describe("Abilities - Parental Bond", () => { "Seismic Toss boosted by this ability and Multi-Lens should strike twice", async () => { game.override.moveset([Moves.SEISMIC_TOSS]); - game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); await game.startBattle([Species.CHARIZARD]); @@ -401,7 +401,7 @@ describe("Abilities - Parental Bond", () => { const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.SEISMIC_TOSS)); + game.move.select(Moves.SEISMIC_TOSS); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -427,7 +427,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.HYPER_BEAM)); + game.move.select(Moves.HYPER_BEAM); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -455,7 +455,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.ANCHOR_SHOT)); + game.move.select(Moves.ANCHOR_SHOT); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -485,7 +485,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SMACK_DOWN)); + game.move.select(Moves.SMACK_DOWN); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -512,7 +512,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN)); + game.move.select(Moves.U_TURN); await game.move.forceHit(); await game.phaseInterceptor.to(MoveEffectPhase); @@ -536,7 +536,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.WAKE_UP_SLAP)); + game.move.select(Moves.WAKE_UP_SLAP); await game.move.forceHit(); await game.phaseInterceptor.to(DamagePhase); @@ -554,7 +554,7 @@ describe("Abilities - Parental Bond", () => { "ability should not cause user to hit into King's Shield more than once", async () => { game.override.moveset([Moves.TACKLE]); - game.override.enemyMoveset([Moves.KINGS_SHIELD,Moves.KINGS_SHIELD,Moves.KINGS_SHIELD,Moves.KINGS_SHIELD]); + game.override.enemyMoveset([Moves.KINGS_SHIELD, Moves.KINGS_SHIELD, Moves.KINGS_SHIELD, Moves.KINGS_SHIELD]); await game.startBattle([Species.CHARIZARD]); @@ -564,7 +564,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(BerryPhase, false); @@ -586,7 +586,7 @@ describe("Abilities - Parental Bond", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); + game.move.select(Moves.WATER_GUN); await game.phaseInterceptor.to(BerryPhase, false); @@ -599,7 +599,7 @@ describe("Abilities - Parental Bond", () => { async () => { game.override.battleType("double"); game.override.moveset([Moves.EARTHQUAKE, Moves.SPLASH]); - game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); await game.startBattle([Species.CHARIZARD, Species.PIDGEOT]); @@ -613,10 +613,10 @@ describe("Abilities - Parental Bond", () => { const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); + game.move.select(Moves.EARTHQUAKE); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -625,7 +625,7 @@ describe("Abilities - Parental Bond", () => { await game.phaseInterceptor.to(BerryPhase, false); - enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(2*enemyFirstHitDamage[i])); + enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(2 * enemyFirstHitDamage[i])); }, TIMEOUT ); diff --git a/src/test/abilities/pastel_veil.test.ts b/src/test/abilities/pastel_veil.test.ts index cb6be666d5f..ba90c7e3b3f 100644 --- a/src/test/abilities/pastel_veil.test.ts +++ b/src/test/abilities/pastel_veil.test.ts @@ -1,15 +1,14 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; +import { BattlerIndex } from "#app/battle"; +import { StatusEffect } from "#app/data/status-effect"; +import { Abilities } from "#app/enums/abilities"; +import { CommandPhase } from "#app/phases/command-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { StatusEffect } from "#app/data/status-effect.js"; -import { allAbilities } from "#app/data/ability.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { BattlerIndex } from "#app/battle.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { SPLASH_ONLY } from "../utils/testUtils"; describe("Abilities - Pastel Veil", () => { let phaserGame: Phaser.Game; @@ -27,50 +26,49 @@ describe("Abilities - Pastel Veil", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("double"); - game.override.moveset([Moves.SPLASH]); - game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD]); + game.override + .battleType("double") + .moveset([Moves.TOXIC_THREAD, Moves.SPLASH]) + .enemyAbility(Abilities.BALL_FETCH) + .enemySpecies(Species.SUNKERN) + .enemyMoveset(SPLASH_ONLY); }); it("prevents the user and its allies from being afflicted by poison", async () => { - await game.startBattle([Species.GALAR_PONYTA, Species.MAGIKARP]); - const ponyta = game.scene.getPlayerField()[0]; - - vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]); + await game.startBattle([Species.MAGIKARP, Species.GALAR_PONYTA]); + const ponyta = game.scene.getPlayerField()[1]; + const magikarp = game.scene.getPlayerField()[0]; + ponyta.abilityIndex = 1; expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.TOXIC_THREAD, 1, BattlerIndex.PLAYER); await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); + expect(magikarp.status?.effect).toBeUndefined(); }); it("it heals the poisoned status condition of allies if user is sent out into battle", async () => { - await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.GALAR_PONYTA]); - const ponyta = game.scene.getParty().find(p => p.species.speciesId === Species.GALAR_PONYTA)!; - - vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]); + await game.startBattle([Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA]); + const ponyta = game.scene.getParty()[2]; + const magikarp = game.scene.getPlayerField()[0]; + ponyta.abilityIndex = 1; expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.TOXIC_THREAD, 1, BattlerIndex.PLAYER); await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerField().some(p => p.status?.effect === StatusEffect.POISON)).toBe(true); - - const poisonedMon = game.scene.getPlayerField().find(p => p.status?.effect === StatusEffect.POISON); + expect(magikarp.status?.effect).toBe(StatusEffect.POISON); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, (poisonedMon!.getBattlerIndex() as BattlerIndex.PLAYER | BattlerIndex.PLAYER_2), Moves.SPLASH)); + game.move.select(Moves.SPLASH); game.doSwitchPokemon(2); await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); + expect(magikarp.status?.effect).toBeUndefined(); }); }); diff --git a/src/test/abilities/power_construct.test.ts b/src/test/abilities/power_construct.test.ts index e6a319d229f..ec37bc96c2f 100644 --- a/src/test/abilities/power_construct.test.ts +++ b/src/test/abilities/power_construct.test.ts @@ -1,11 +1,10 @@ -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; @@ -53,7 +52,7 @@ describe("Abilities - POWER CONSTRUCT", () => { zygarde!.status = new Status(StatusEffect.FAINT); expect(zygarde!.isFainted()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); diff --git a/src/test/abilities/power_spot.test.ts b/src/test/abilities/power_spot.test.ts index 467fc677ac0..b83284c0bac 100644 --- a/src/test/abilities/power_spot.test.ts +++ b/src/test/abilities/power_spot.test.ts @@ -1,14 +1,13 @@ -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Abilities - Power Spot", () => { let phaserGame: Phaser.Game; @@ -42,8 +41,8 @@ describe("Abilities - Power Spot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.DAZZLING_GLEAM); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier); @@ -56,8 +55,8 @@ describe("Abilities - Power Spot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]); - game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.BREAKING_SWIPE); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier); @@ -70,8 +69,8 @@ describe("Abilities - Power Spot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); await game.startBattle([Species.STONJOURNER, Species.REGIELEKI]); - game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.BREAKING_SWIPE); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); diff --git a/src/test/abilities/protean.test.ts b/src/test/abilities/protean.test.ts index ed63613945a..a7c6799132f 100644 --- a/src/test/abilities/protean.test.ts +++ b/src/test/abilities/protean.test.ts @@ -1,18 +1,17 @@ -import { allMoves } from "#app/data/move.js"; -import { Type } from "#app/data/type.js"; -import { Weather, WeatherType } from "#app/data/weather.js"; -import { PlayerPokemon } from "#app/field/pokemon.js"; +import { allMoves } from "#app/data/move"; +import { Type } from "#app/data/type"; +import { Weather, WeatherType } from "#app/data/weather"; +import { PlayerPokemon } from "#app/field/pokemon"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Biome } from "#enums/biome"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -49,7 +48,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); @@ -67,12 +66,12 @@ describe("Abilities - Protean", () => { let leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - game.doAttack(getMovePosition(game.scene, 0, Moves.AGILITY)); + game.move.select(Moves.AGILITY); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.PROTEAN)).toHaveLength(1); @@ -89,7 +88,7 @@ describe("Abilities - Protean", () => { leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); @@ -108,7 +107,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.scene.arena.weather = new Weather(WeatherType.SUNNY); - game.doAttack(getMovePosition(game.scene, 0, Moves.WEATHER_BALL)); + game.move.select(Moves.WEATHER_BALL); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); @@ -131,7 +130,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); @@ -154,7 +153,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.scene.arena.biomeType = Biome.MOUNTAIN; - game.doAttack(getMovePosition(game.scene, 0, Moves.NATURE_POWER)); + game.move.select(Moves.NATURE_POWER); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); @@ -172,7 +171,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.DIG)); + game.move.select(Moves.DIG); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); @@ -191,7 +190,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.move.forceMiss(); await game.phaseInterceptor.to(TurnEndPhase); @@ -213,7 +212,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); @@ -232,7 +231,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); @@ -251,7 +250,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); leadPokemon.summonData.types = [allMoves[Moves.SPLASH].defaultType]; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); @@ -271,7 +270,7 @@ describe("Abilities - Protean", () => { vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); @@ -289,7 +288,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE)); + game.move.select(Moves.STRUGGLE); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); @@ -307,7 +306,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.BURN_UP)); + game.move.select(Moves.BURN_UP); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); @@ -326,7 +325,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.TRICK_OR_TREAT)); + game.move.select(Moves.TRICK_OR_TREAT); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); @@ -344,7 +343,7 @@ describe("Abilities - Protean", () => { const leadPokemon = game.scene.getPlayerPokemon()!; expect(leadPokemon).not.toBe(undefined); - game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE)); + game.move.select(Moves.CURSE); await game.phaseInterceptor.to(TurnEndPhase); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); diff --git a/src/test/abilities/quick_draw.test.ts b/src/test/abilities/quick_draw.test.ts index 6e3416b0724..00d344ed333 100644 --- a/src/test/abilities/quick_draw.test.ts +++ b/src/test/abilities/quick_draw.test.ts @@ -1,12 +1,11 @@ import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { FaintPhase } from "#app/phases/faint-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; -import { FaintPhase } from "#app/phases/faint-phase.js"; describe("Abilities - Quick Draw", () => { let phaserGame: Phaser.Game; @@ -47,7 +46,7 @@ describe("Abilities - Quick Draw", () => { pokemon.hp = 1; enemy.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(FaintPhase, false); expect(pokemon.isFainted()).toBe(false); @@ -67,7 +66,7 @@ describe("Abilities - Quick Draw", () => { pokemon.hp = 1; enemy.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.TAIL_WHIP)); + game.move.select(Moves.TAIL_WHIP); await game.phaseInterceptor.to(FaintPhase, false); expect(pokemon.isFainted()).toBe(true); @@ -87,7 +86,7 @@ describe("Abilities - Quick Draw", () => { pokemon.hp = 1; enemy.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(FaintPhase, false); expect(pokemon.isFainted()).toBe(true); diff --git a/src/test/abilities/sand_spit.test.ts b/src/test/abilities/sand_spit.test.ts index 59d311adb80..041e20faf7f 100644 --- a/src/test/abilities/sand_spit.test.ts +++ b/src/test/abilities/sand_spit.test.ts @@ -1,11 +1,10 @@ -import GameManager from "#test/utils/gameManager"; +import { WeatherType } from "#app/enums/weather-type"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { WeatherType } from "#app/enums/weather-type.js"; describe("Abilities - Sand Spit", () => { @@ -35,21 +34,21 @@ describe("Abilities - Sand Spit", () => { game.override.moveset([Moves.SPLASH, Moves.COIL]); }); - it("should trigger when hit with damaging move", async() => { + it("should trigger when hit with damaging move", async () => { game.override.enemyMoveset(Array(4).fill(Moves.TACKLE)); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SANDSTORM); }, 20000); - it("should not trigger when targetted with status moves", async() => { + it("should not trigger when targetted with status moves", async () => { game.override.enemyMoveset(Array(4).fill(Moves.GROWL)); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.COIL)); + game.move.select(Moves.COIL); await game.toNextTurn(); expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SANDSTORM); diff --git a/src/test/abilities/sand_veil.test.ts b/src/test/abilities/sand_veil.test.ts index 010878db68d..2336e2b50de 100644 --- a/src/test/abilities/sand_veil.test.ts +++ b/src/test/abilities/sand_veil.test.ts @@ -1,16 +1,15 @@ -import { BattleStatMultiplierAbAttr, allAbilities } from "#app/data/ability.js"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { WeatherType } from "#app/data/weather.js"; +import { BattleStatMultiplierAbAttr, allAbilities } from "#app/data/ability"; +import { BattleStat } from "#app/data/battle-stat"; +import { WeatherType } from "#app/data/weather"; +import { CommandPhase } from "#app/phases/command-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -52,7 +51,7 @@ describe("Abilities - Sand Veil", () => { const sandVeilAttr = allAbilities[Abilities.SAND_VEIL].getAttrs(BattleStatMultiplierAbAttr)[0]; vi.spyOn(sandVeilAttr, "applyBattleStat").mockImplementation( - (pokemon, passive, battleStat, statValue, args) => { + (pokemon, passive, simulated, battleStat, statValue, args) => { if (battleStat === BattleStat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) { statValue.value *= -1; // will make all attacks miss return true; @@ -64,11 +63,11 @@ describe("Abilities - Sand Veil", () => { expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true); expect(leadPokemon[1].hasAbility(Abilities.SAND_VEIL)).toBe(false); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase, false); diff --git a/src/test/abilities/sap_sipper.test.ts b/src/test/abilities/sap_sipper.test.ts index dfb4ab7e976..f9c20e85eab 100644 --- a/src/test/abilities/sap_sipper.test.ts +++ b/src/test/abilities/sap_sipper.test.ts @@ -1,15 +1,14 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { TerrainType } from "#app/data/terrain.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { TerrainType } from "#app/data/terrain"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; // See also: TypeImmunityAbAttr describe("Abilities - Sap Sipper", () => { @@ -32,7 +31,7 @@ describe("Abilities - Sap Sipper", () => { game.override.disableCrits(); }); - it("raise attack 1 level and block effects when activated against a grass attack", async() => { + it("raise attack 1 level and block effects when activated against a grass attack", async () => { const moveToUse = Moves.LEAFAGE; const enemyAbility = Abilities.SAP_SIPPER; @@ -45,7 +44,7 @@ describe("Abilities - Sap Sipper", () => { const startingOppHp = game.scene.currentBattle.enemyParty[0].hp; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); @@ -53,7 +52,7 @@ describe("Abilities - Sap Sipper", () => { expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1); }); - it("raise attack 1 level and block effects when activated against a grass status move", async() => { + it("raise attack 1 level and block effects when activated against a grass status move", async () => { const moveToUse = Moves.SPORE; const enemyAbility = Abilities.SAP_SIPPER; @@ -64,7 +63,7 @@ describe("Abilities - Sap Sipper", () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); @@ -72,7 +71,7 @@ describe("Abilities - Sap Sipper", () => { expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1); }); - it("do not activate against status moves that target the field", async() => { + it("do not activate against status moves that target the field", async () => { const moveToUse = Moves.GRASSY_TERRAIN; const enemyAbility = Abilities.SAP_SIPPER; @@ -83,7 +82,7 @@ describe("Abilities - Sap Sipper", () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); @@ -92,7 +91,7 @@ describe("Abilities - Sap Sipper", () => { expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(0); }); - it("activate once against multi-hit grass attacks", async() => { + it("activate once against multi-hit grass attacks", async () => { const moveToUse = Moves.BULLET_SEED; const enemyAbility = Abilities.SAP_SIPPER; @@ -105,7 +104,7 @@ describe("Abilities - Sap Sipper", () => { const startingOppHp = game.scene.currentBattle.enemyParty[0].hp; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); @@ -113,7 +112,7 @@ describe("Abilities - Sap Sipper", () => { expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1); }); - it("do not activate against status moves that target the user", async() => { + it("do not activate against status moves that target the user", async () => { const moveToUse = Moves.SPIKY_SHIELD; const ability = Abilities.SAP_SIPPER; @@ -125,7 +124,7 @@ describe("Abilities - Sap Sipper", () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(MoveEndPhase); @@ -139,7 +138,7 @@ describe("Abilities - Sap Sipper", () => { // TODO Add METRONOME outcome override // To run this testcase, manually modify the METRONOME move to always give SAP_SIPPER, then uncomment - it.todo("activate once against multi-hit grass attacks (metronome)", async() => { + it.todo("activate once against multi-hit grass attacks (metronome)", async () => { const moveToUse = Moves.METRONOME; const enemyAbility = Abilities.SAP_SIPPER; @@ -152,7 +151,7 @@ describe("Abilities - Sap Sipper", () => { const startingOppHp = game.scene.currentBattle.enemyParty[0].hp; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/abilities/schooling.test.ts b/src/test/abilities/schooling.test.ts index 62a7e98bc76..ad9663bf8e5 100644 --- a/src/test/abilities/schooling.test.ts +++ b/src/test/abilities/schooling.test.ts @@ -1,11 +1,10 @@ -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; @@ -53,7 +52,7 @@ describe("Abilities - SCHOOLING", () => { wishiwashi.status = new Status(StatusEffect.FAINT); expect(wishiwashi.isFainted()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); diff --git a/src/test/abilities/screen_cleaner.test.ts b/src/test/abilities/screen_cleaner.test.ts index 403efcce1c0..3c0d12a06ea 100644 --- a/src/test/abilities/screen_cleaner.test.ts +++ b/src/test/abilities/screen_cleaner.test.ts @@ -1,13 +1,12 @@ -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { PostSummonPhase } from "#app/phases/post-summon-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { PostSummonPhase } from "#app/phases/post-summon-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Abilities - Screen Cleaner", () => { let phaserGame: Phaser.Game; @@ -36,7 +35,7 @@ describe("Abilities - Screen Cleaner", () => { await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.HAIL)); + game.move.select(Moves.HAIL); await game.phaseInterceptor.to(TurnEndPhase); expect(game.scene.arena.getTag(ArenaTagType.AURORA_VEIL)).toBeDefined(); @@ -53,7 +52,7 @@ describe("Abilities - Screen Cleaner", () => { await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(game.scene.arena.getTag(ArenaTagType.LIGHT_SCREEN)).toBeDefined(); @@ -70,7 +69,7 @@ describe("Abilities - Screen Cleaner", () => { await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(game.scene.arena.getTag(ArenaTagType.REFLECT)).toBeDefined(); diff --git a/src/test/abilities/serene_grace.test.ts b/src/test/abilities/serene_grace.test.ts index 5e4841f005a..7316b2ea920 100644 --- a/src/test/abilities/serene_grace.test.ts +++ b/src/test/abilities/serene_grace.test.ts @@ -1,18 +1,14 @@ +import { BattlerIndex } from "#app/battle"; import { applyAbAttrs, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability"; import { Stat } from "#app/data/pokemon-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import * as Utils from "#app/utils"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { BattlerIndex } from "#app/battle.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; describe("Abilities - Serene Grace", () => { @@ -36,10 +32,10 @@ describe("Abilities - Serene Grace", () => { game.override.enemySpecies(Species.ONIX); game.override.startingLevel(100); game.override.moveset(movesToUse); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("Move chance without Serene Grace", async() => { + it("Move chance without Serene Grace", async () => { const moveToUse = Moves.AIR_SLASH; await game.startBattle([ Species.PIDGEOT @@ -49,13 +45,7 @@ describe("Abilities - Serene Grace", () => { game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -67,12 +57,12 @@ describe("Abilities - Serene Grace", () => { const chance = new Utils.IntegerHolder(move.chance); console.log(move.chance + " Their ability is " + phase.getUserPokemon()!.getAbility().name); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getTarget(), false); expect(chance.value).toBe(30); }, 20000); - it("Move chance with Serene Grace", async() => { + it("Move chance with Serene Grace", async () => { const moveToUse = Moves.AIR_SLASH; game.override.ability(Abilities.SERENE_GRACE); await game.startBattle([ @@ -82,13 +72,7 @@ describe("Abilities - Serene Grace", () => { game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -99,7 +83,7 @@ describe("Abilities - Serene Grace", () => { expect(move.id).toBe(Moves.AIR_SLASH); const chance = new Utils.IntegerHolder(move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getTarget(), false); expect(chance.value).toBe(60); }, 20000); diff --git a/src/test/abilities/sheer_force.test.ts b/src/test/abilities/sheer_force.test.ts index 33b34124cc4..f73b749dac2 100644 --- a/src/test/abilities/sheer_force.test.ts +++ b/src/test/abilities/sheer_force.test.ts @@ -1,18 +1,14 @@ +import { BattlerIndex } from "#app/battle"; import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability"; import { Stat } from "#app/data/pokemon-stat"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import * as Utils from "#app/utils"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { BattlerIndex } from "#app/battle.js"; describe("Abilities - Sheer Force", () => { @@ -36,10 +32,10 @@ describe("Abilities - Sheer Force", () => { game.override.enemySpecies(Species.ONIX); game.override.startingLevel(100); game.override.moveset(movesToUse); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("Sheer Force", async() => { + it("Sheer Force", async () => { const moveToUse = Moves.AIR_SLASH; game.override.ability(Abilities.SHEER_FORCE); await game.startBattle([ @@ -50,13 +46,7 @@ describe("Abilities - Sheer Force", () => { game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -69,16 +59,16 @@ describe("Abilities - Sheer Force", () => { const power = new Utils.IntegerHolder(move.power); const chance = new Utils.IntegerHolder(move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false); - applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, power); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getTarget(), false); + applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, false, power); expect(chance.value).toBe(0); - expect(power.value).toBe(move.power * 5461/4096); + expect(power.value).toBe(move.power * 5461 / 4096); }, 20000); - it("Sheer Force with exceptions including binding moves", async() => { + it("Sheer Force with exceptions including binding moves", async () => { const moveToUse = Moves.BIND; game.override.ability(Abilities.SHEER_FORCE); await game.startBattle([ @@ -89,13 +79,7 @@ describe("Abilities - Sheer Force", () => { game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -108,8 +92,8 @@ describe("Abilities - Sheer Force", () => { const power = new Utils.IntegerHolder(move.power); const chance = new Utils.IntegerHolder(move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false); - applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, power); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getTarget(), false); + applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, false, power); expect(chance.value).toBe(-1); expect(power.value).toBe(move.power); @@ -117,7 +101,7 @@ describe("Abilities - Sheer Force", () => { }, 20000); - it("Sheer Force with moves with no secondary effect", async() => { + it("Sheer Force with moves with no secondary effect", async () => { const moveToUse = Moves.TACKLE; game.override.ability(Abilities.SHEER_FORCE); await game.startBattle([ @@ -128,13 +112,7 @@ describe("Abilities - Sheer Force", () => { game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -147,8 +125,8 @@ describe("Abilities - Sheer Force", () => { const power = new Utils.IntegerHolder(move.power); const chance = new Utils.IntegerHolder(move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false); - applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, power); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getTarget(), false); + applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, false, power); expect(chance.value).toBe(-1); expect(power.value).toBe(move.power); @@ -156,10 +134,10 @@ describe("Abilities - Sheer Force", () => { }, 20000); - it("Sheer Force Disabling Specific Abilities", async() => { + it("Sheer Force Disabling Specific Abilities", async () => { const moveToUse = Moves.CRUSH_CLAW; game.override.enemyAbility(Abilities.COLOR_CHANGE); - game.override.startingHeldItems([{name: "KINGS_ROCK", count: 1}]); + game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]); game.override.ability(Abilities.SHEER_FORCE); await game.startBattle([ Species.PIDGEOT @@ -169,13 +147,7 @@ describe("Abilities - Sheer Force", () => { game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -191,12 +163,12 @@ describe("Abilities - Sheer Force", () => { const target = phase.getTarget()!; const opponentType = target.getTypes()[0]; - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, chance, move, target, false); - applyPreAttackAbAttrs(MovePowerBoostAbAttr, user, target, move, power); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, chance, move, target, false); + applyPreAttackAbAttrs(MovePowerBoostAbAttr, user, target, move, false, power); applyPostDefendAbAttrs(PostDefendTypeChangeAbAttr, target, user, move, target.apply(user, move)); expect(chance.value).toBe(0); - expect(power.value).toBe(move.power * 5461/4096); + expect(power.value).toBe(move.power * 5461 / 4096); expect(target.getTypes().length).toBe(2); expect(target.getTypes()[0]).toBe(opponentType); diff --git a/src/test/abilities/shield_dust.test.ts b/src/test/abilities/shield_dust.test.ts index b40689a180a..14770c49427 100644 --- a/src/test/abilities/shield_dust.test.ts +++ b/src/test/abilities/shield_dust.test.ts @@ -1,18 +1,14 @@ +import { BattlerIndex } from "#app/battle"; import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability"; import { Stat } from "#app/data/pokemon-stat"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import * as Utils from "#app/utils"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { BattlerIndex } from "#app/battle.js"; describe("Abilities - Shield Dust", () => { @@ -37,10 +33,10 @@ describe("Abilities - Shield Dust", () => { game.override.enemyAbility(Abilities.SHIELD_DUST); game.override.startingLevel(100); game.override.moveset(movesToUse); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("Shield Dust", async() => { + it("Shield Dust", async () => { const moveToUse = Moves.AIR_SLASH; await game.startBattle([ Species.PIDGEOT @@ -50,13 +46,7 @@ describe("Abilities - Shield Dust", () => { game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -67,8 +57,8 @@ describe("Abilities - Shield Dust", () => { expect(move.id).toBe(Moves.AIR_SLASH); const chance = new Utils.IntegerHolder(move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false); - applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getTarget()!, phase.getUserPokemon()!, null!, null!, chance); + applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getTarget(), false); + applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getTarget()!, phase.getUserPokemon()!, null, null, false, chance); expect(chance.value).toBe(0); }, 20000); diff --git a/src/test/abilities/shields_down.test.ts b/src/test/abilities/shields_down.test.ts index e07c12ebb63..9bfec23ddf1 100644 --- a/src/test/abilities/shields_down.test.ts +++ b/src/test/abilities/shields_down.test.ts @@ -1,11 +1,10 @@ -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; @@ -53,7 +52,7 @@ describe("Abilities - SHIELDS DOWN", () => { minior.status = new Status(StatusEffect.FAINT); expect(minior.isFainted()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); diff --git a/src/test/abilities/stall.test.ts b/src/test/abilities/stall.test.ts index 0e3c56017a3..e406a88eb78 100644 --- a/src/test/abilities/stall.test.ts +++ b/src/test/abilities/stall.test.ts @@ -1,8 +1,8 @@ -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { MovePhase } from "#app/phases/move-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { TurnStartPhase } from "#app/phases/turn-start-phase"; @@ -38,12 +38,13 @@ describe("Abilities - Stall", () => { * https://bulbapedia.bulbagarden.net/wiki/Priority **/ - it("Pokemon with Stall should move last in its priority bracket regardless of speed", async() => { - await game.startBattle([ Species.SHUCKLE ]); + it("Pokemon with Stall should move last in its priority bracket regardless of speed", async () => { + await game.startBattle([Species.SHUCKLE]); - const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); - const enemyPokemonIndex = game.scene.getEnemyPokemon()?.getBattlerIndex(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); + const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); + const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); + + game.move.select(Moves.QUICK_ATTACK); await game.phaseInterceptor.run(EnemyCommandPhase); const phase = game.scene.getCurrentPhase() as TurnStartPhase; @@ -51,16 +52,17 @@ describe("Abilities - Stall", () => { const commandOrder = phase.getCommandOrder(); // The player Pokemon (without Stall) goes first despite having lower speed than the opponent. // The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon. - expect(speedOrder).toEqual([enemyPokemonIndex, playerPokemonIndex]); - expect(commandOrder).toEqual([playerPokemonIndex, enemyPokemonIndex]); + expect(speedOrder).toEqual([enemyIndex, playerIndex]); + expect(commandOrder).toEqual([playerIndex, enemyIndex]); }, 20000); - it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async() => { - await game.startBattle([ Species.SHUCKLE ]); + it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async () => { + await game.startBattle([Species.SHUCKLE]); - const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); - const enemyPokemonIndex = game.scene.getEnemyPokemon()?.getBattlerIndex(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); + const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); + + game.move.select(Moves.TACKLE); await game.phaseInterceptor.run(EnemyCommandPhase); const phase = game.scene.getCurrentPhase() as TurnStartPhase; @@ -68,17 +70,18 @@ describe("Abilities - Stall", () => { const commandOrder = phase.getCommandOrder(); // The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent. // The player Pokemon goes second because its move is in a lower priority bracket. - expect(speedOrder).toEqual([enemyPokemonIndex, playerPokemonIndex]); - expect(commandOrder).toEqual([enemyPokemonIndex, playerPokemonIndex]); + expect(speedOrder).toEqual([enemyIndex, playerIndex]); + expect(commandOrder).toEqual([enemyIndex, playerIndex]); }, 20000); - it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async() => { + it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async () => { game.override.ability(Abilities.STALL); - await game.startBattle([ Species.SHUCKLE ]); + await game.startBattle([Species.SHUCKLE]); - const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); - const enemyPokemonIndex = game.scene.getEnemyPokemon()?.getBattlerIndex(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); + const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); + + game.move.select(Moves.TACKLE); await game.phaseInterceptor.run(EnemyCommandPhase); const phase = game.scene.getCurrentPhase() as TurnStartPhase; @@ -87,7 +90,7 @@ describe("Abilities - Stall", () => { // The opponent Pokemon (with Stall) goes first because it has a higher speed. // The player Pokemon (with Stall) goes second because its speed is lower. - expect(speedOrder).toEqual([enemyPokemonIndex, playerPokemonIndex]); - expect(commandOrder).toEqual([enemyPokemonIndex, playerPokemonIndex]); + expect(speedOrder).toEqual([enemyIndex, playerIndex]); + expect(commandOrder).toEqual([enemyIndex, playerIndex]); }, 20000); }); diff --git a/src/test/abilities/steely_spirit.test.ts b/src/test/abilities/steely_spirit.test.ts index 3ca1a55ebee..c632d0be777 100644 --- a/src/test/abilities/steely_spirit.test.ts +++ b/src/test/abilities/steely_spirit.test.ts @@ -1,15 +1,13 @@ -import { allAbilities } from "#app/data/ability.js"; -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allAbilities } from "#app/data/ability"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; describe("Abilities - Steely Spirit", () => { let phaserGame: Phaser.Game; @@ -47,10 +45,8 @@ describe("Abilities - Steely Spirit", () => { expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, moveToCheck)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(enemyToCheck.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex()); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * steelySpiritMultiplier); @@ -66,12 +62,8 @@ describe("Abilities - Steely Spirit", () => { expect(game.scene.getPlayerField().every(p => p.hasAbility(Abilities.STEELY_SPIRIT))).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, moveToCheck)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(enemyToCheck.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, moveToCheck)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(enemyToCheck.getBattlerIndex()); + game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex()); + game.move.select(moveToCheck, 1, enemyToCheck.getBattlerIndex()); await game.phaseInterceptor.to(MoveEffectPhase); expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * Math.pow(steelySpiritMultiplier, 2)); @@ -90,10 +82,8 @@ describe("Abilities - Steely Spirit", () => { expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(false); expect(boostSource.summonData.abilitySuppressed).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, moveToCheck)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(enemyToCheck.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex()); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower); diff --git a/src/test/abilities/sturdy.test.ts b/src/test/abilities/sturdy.test.ts index 602b2c04eb1..dc9f774cc5b 100644 --- a/src/test/abilities/sturdy.test.ts +++ b/src/test/abilities/sturdy.test.ts @@ -1,13 +1,12 @@ -import { EnemyPokemon } from "#app/field/pokemon.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { EnemyPokemon } from "#app/field/pokemon"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -42,7 +41,7 @@ describe("Abilities - Sturdy", () => { "Sturdy activates when user is at full HP", async () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); + game.move.select(Moves.CLOSE_COMBAT); await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.getEnemyParty()[0].hp).toBe(1); }, @@ -57,7 +56,7 @@ describe("Abilities - Sturdy", () => { const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); + game.move.select(Moves.CLOSE_COMBAT); await game.phaseInterceptor.to(DamagePhase); expect(enemyPokemon.hp).toBe(0); @@ -70,7 +69,7 @@ describe("Abilities - Sturdy", () => { "Sturdy pokemon should be immune to OHKO moves", async () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); + game.move.select(Moves.FISSURE); await game.phaseInterceptor.to(MoveEndPhase); const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; @@ -85,7 +84,7 @@ describe("Abilities - Sturdy", () => { game.override.ability(Abilities.MOLD_BREAKER); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); + game.move.select(Moves.CLOSE_COMBAT); await game.phaseInterceptor.to(DamagePhase); const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; diff --git a/src/test/abilities/sweet_veil.test.ts b/src/test/abilities/sweet_veil.test.ts index 8ab384ae59e..5de3c7285a9 100644 --- a/src/test/abilities/sweet_veil.test.ts +++ b/src/test/abilities/sweet_veil.test.ts @@ -1,16 +1,14 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; +import { BattlerIndex } from "#app/battle"; +import { Abilities } from "#app/enums/abilities"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { CommandPhase } from "#app/phases/command-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { BattlerIndex } from "#app/battle.js"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MovePhase } from "#app/phases/move-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Abilities - Sweet Veil", () => { let phaserGame: Phaser.Game; @@ -29,7 +27,7 @@ describe("Abilities - Sweet Veil", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("double"); - game.override.moveset([Moves.SPLASH, Moves.REST]); + game.override.moveset([Moves.SPLASH, Moves.REST, Moves.YAWN]); game.override.enemySpecies(Species.MAGIKARP); game.override.enemyAbility(Abilities.BALL_FETCH); game.override.enemyMoveset([Moves.POWDER, Moves.POWDER, Moves.POWDER, Moves.POWDER]); @@ -38,8 +36,8 @@ describe("Abilities - Sweet Veil", () => { it("prevents the user and its allies from falling asleep", async () => { await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); @@ -50,8 +48,8 @@ describe("Abilities - Sweet Veil", () => { game.override.enemyMoveset(SPLASH_ONLY); await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.REST)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.REST, 1); await game.phaseInterceptor.to(TurnEndPhase); @@ -62,8 +60,8 @@ describe("Abilities - Sweet Veil", () => { game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]); await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); @@ -74,28 +72,19 @@ describe("Abilities - Sweet Veil", () => { game.override.enemySpecies(Species.PIKACHU); game.override.enemyLevel(5); game.override.startingLevel(5); - game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]); + game.override.enemyMoveset(SPLASH_ONLY); await game.startBattle([Species.SHUCKLE, Species.SHUCKLE, Species.SWIRLIX]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.YAWN, 1, BattlerIndex.PLAYER); - // First pokemon move - await game.move.forceHit(); - - // Second pokemon move - await game.phaseInterceptor.to(MovePhase, false); - await game.move.forceHit(); + await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.getPlayerField().some(p => !!p.getTag(BattlerTagType.DROWSY))).toBe(true); - await game.phaseInterceptor.to(TurnEndPhase); - - const drowsyMon = game.scene.getPlayerField().find(p => !!p.getTag(BattlerTagType.DROWSY))!; - await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, (drowsyMon.getBattlerIndex() as BattlerIndex.PLAYER | BattlerIndex.PLAYER_2), Moves.SPLASH)); + game.move.select(Moves.SPLASH); game.doSwitchPokemon(2); expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); diff --git a/src/test/abilities/unseen_fist.test.ts b/src/test/abilities/unseen_fist.test.ts index 7d47d73bb16..ea1996ec66b 100644 --- a/src/test/abilities/unseen_fist.test.ts +++ b/src/test/abilities/unseen_fist.test.ts @@ -1,11 +1,10 @@ +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -80,7 +79,7 @@ async function testUnseenFistHitResult(game: GameManager, attackMove: Moves, pro const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, attackMove)); + game.move.select(attackMove); await game.phaseInterceptor.to(TurnEndPhase, false); if (shouldSucceed) { diff --git a/src/test/abilities/volt_absorb.test.ts b/src/test/abilities/volt_absorb.test.ts index 0e3d5c9792f..d9c3fe34c24 100644 --- a/src/test/abilities/volt_absorb.test.ts +++ b/src/test/abilities/volt_absorb.test.ts @@ -1,11 +1,10 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -42,7 +41,7 @@ describe("Abilities - Volt Absorb", () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/abilities/wind_power.test.ts b/src/test/abilities/wind_power.test.ts index 24f01cceebc..c944e01b43a 100644 --- a/src/test/abilities/wind_power.test.ts +++ b/src/test/abilities/wind_power.test.ts @@ -1,13 +1,12 @@ -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Abilities - Wind Power", () => { let phaserGame: Phaser.Game; @@ -38,7 +37,7 @@ describe("Abilities - Wind Power", () => { expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.PETAL_BLIZZARD)); + game.move.select(Moves.PETAL_BLIZZARD); await game.phaseInterceptor.to(TurnEndPhase); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); @@ -53,7 +52,7 @@ describe("Abilities - Wind Power", () => { expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.phaseInterceptor.to(TurnEndPhase); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); @@ -70,7 +69,7 @@ describe("Abilities - Wind Power", () => { expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); expect(magikarp.getTag(BattlerTagType.CHARGED)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.phaseInterceptor.to(TurnEndPhase); @@ -86,7 +85,7 @@ describe("Abilities - Wind Power", () => { expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SANDSTORM)); + game.move.select(Moves.SANDSTORM); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/abilities/wind_rider.test.ts b/src/test/abilities/wind_rider.test.ts index 92c38507e4f..97e2e6456dc 100644 --- a/src/test/abilities/wind_rider.test.ts +++ b/src/test/abilities/wind_rider.test.ts @@ -1,13 +1,12 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Abilities - Wind Rider", () => { let phaserGame: Phaser.Game; @@ -38,7 +37,7 @@ describe("Abilities - Wind Rider", () => { expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.PETAL_BLIZZARD)); + game.move.select(Moves.PETAL_BLIZZARD); await game.phaseInterceptor.to(TurnEndPhase); @@ -55,7 +54,7 @@ describe("Abilities - Wind Rider", () => { expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.phaseInterceptor.to(TurnEndPhase); @@ -73,7 +72,7 @@ describe("Abilities - Wind Rider", () => { expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.phaseInterceptor.to(TurnEndPhase); @@ -91,7 +90,7 @@ describe("Abilities - Wind Rider", () => { expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.phaseInterceptor.to(TurnEndPhase); @@ -108,7 +107,7 @@ describe("Abilities - Wind Rider", () => { expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(shiftry.isFullHp()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SANDSTORM)); + game.move.select(Moves.SANDSTORM); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/abilities/wonder_skin.test.ts b/src/test/abilities/wonder_skin.test.ts index d6e2b2443c4..0c2aedc8ce8 100644 --- a/src/test/abilities/wonder_skin.test.ts +++ b/src/test/abilities/wonder_skin.test.ts @@ -1,14 +1,13 @@ -import { allAbilities } from "#app/data/ability.js"; -import { allMoves } from "#app/data/move.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allAbilities } from "#app/data/ability"; +import { allMoves } from "#app/data/move"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Abilities - Wonder Skin", () => { let phaserGame: Phaser.Game; @@ -40,7 +39,7 @@ describe("Abilities - Wonder Skin", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); + game.move.select(Moves.CHARM); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(50); @@ -52,7 +51,7 @@ describe("Abilities - Wonder Skin", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); @@ -68,7 +67,7 @@ describe("Abilities - Wonder Skin", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); + game.move.select(Moves.CHARM); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); diff --git a/src/test/abilities/zen_mode.test.ts b/src/test/abilities/zen_mode.test.ts index 72fdc5442c5..677d998e876 100644 --- a/src/test/abilities/zen_mode.test.ts +++ b/src/test/abilities/zen_mode.test.ts @@ -1,26 +1,23 @@ +import { BattlerIndex } from "#app/battle"; import { Stat } from "#app/data/pokemon-stat"; -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import { PostSummonPhase } from "#app/phases/post-summon-phase"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { SwitchPhase } from "#app/phases/switch-phase"; +import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; +import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { BattlerIndex } from "#app/battle.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; -import { PostSummonPhase } from "#app/phases/post-summon-phase.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { SwitchPhase } from "#app/phases/switch-phase.js"; -import { SwitchSummonPhase } from "#app/phases/switch-summon-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; const TIMEOUT = 20 * 1000; @@ -59,13 +56,7 @@ describe("Abilities - ZEN MODE", () => { game.scene.getParty()[0].hp = 100; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(DamagePhase, false); @@ -88,13 +79,7 @@ describe("Abilities - ZEN MODE", () => { game.scene.getParty()[0].hp = 100; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(QuietFormChangePhase); @@ -114,13 +99,7 @@ describe("Abilities - ZEN MODE", () => { game.scene.getParty()[0].hp = 100; expect(game.scene.getParty()[0].formIndex).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(DamagePhase, false); @@ -169,7 +148,7 @@ describe("Abilities - ZEN MODE", () => { darmanitan.status = new Status(StatusEffect.FAINT); expect(darmanitan.isFainted()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); diff --git a/src/test/abilities/zero_to_hero.test.ts b/src/test/abilities/zero_to_hero.test.ts index ee6c07096a8..1a9697f974e 100644 --- a/src/test/abilities/zero_to_hero.test.ts +++ b/src/test/abilities/zero_to_hero.test.ts @@ -1,11 +1,10 @@ -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; @@ -52,7 +51,7 @@ describe("Abilities - ZERO TO HERO", () => { palafin2.status = new Status(StatusEffect.FAINT); expect(palafin2.isFainted()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(TurnEndPhase); game.doSelectModifier(); @@ -80,7 +79,7 @@ describe("Abilities - ZERO TO HERO", () => { const palafin = game.scene.getPlayerPokemon()!; expect(palafin.formIndex).toBe(baseForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.killPokemon(palafin); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -97,7 +96,7 @@ describe("Abilities - ZERO TO HERO", () => { const palafin = game.scene.getPlayerPokemon()!; expect(palafin.formIndex).toBe(heroForm); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.killPokemon(palafin); game.doSelectPartyPokemon(1); await game.toNextTurn(); diff --git a/src/test/account.spec.ts b/src/test/account.spec.ts index d5d0458c7e8..eb6002f3cf2 100644 --- a/src/test/account.spec.ts +++ b/src/test/account.spec.ts @@ -1,4 +1,4 @@ -import * as battleScene from "#app/battle-scene.js"; +import * as battleScene from "#app/battle-scene"; import { describe, expect, it, vi } from "vitest"; import { initLoggedInUser, loggedInUser, updateUserInfo } from "../account"; import * as utils from "../utils"; diff --git a/src/test/achievements/achievement.test.ts b/src/test/achievements/achievement.test.ts index 5cd9c4d4094..36c20ae2248 100644 --- a/src/test/achievements/achievement.test.ts +++ b/src/test/achievements/achievement.test.ts @@ -1,7 +1,7 @@ -import { TurnHeldItemTransferModifier } from "#app/modifier/modifier.js"; +import { TurnHeldItemTransferModifier } from "#app/modifier/modifier"; import { Achv, AchvTier, DamageAchv, HealAchv, LevelAchv, ModifierAchv, MoneyAchv, RibbonAchv, achvs } from "#app/system/achv"; +import { IntegerHolder, NumberHolder } from "#app/utils"; import GameManager from "#test/utils/gameManager"; -import { IntegerHolder, NumberHolder } from "#app/utils.js"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import BattleScene from "../../battle-scene"; diff --git a/src/test/arena/arena_gravity.test.ts b/src/test/arena/arena_gravity.test.ts index 68c31258454..eda8c687ba1 100644 --- a/src/test/arena/arena_gravity.test.ts +++ b/src/test/arena/arena_gravity.test.ts @@ -1,14 +1,14 @@ -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { SPLASH_ONLY } from "../utils/testUtils"; describe("Arena - Gravity", () => { let phaserGame: Phaser.Game; @@ -26,14 +26,17 @@ describe("Arena - Gravity", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single"); - game.override.moveset([Moves.TACKLE, Moves.GRAVITY, Moves.FISSURE]); - game.override.ability(Abilities.UNNERVE); - game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemySpecies(Species.SHUCKLE); - game.override.enemyMoveset(new Array(4).fill(Moves.SPLASH)); + game.override + .battleType("single") + .moveset([Moves.TACKLE, Moves.GRAVITY, Moves.FISSURE]) + .ability(Abilities.UNNERVE) + .enemyAbility(Abilities.BALL_FETCH) + .enemySpecies(Species.SHUCKLE) + .enemyMoveset(SPLASH_ONLY); }); + // Reference: https://bulbapedia.bulbagarden.net/wiki/Gravity_(move) + it("non-OHKO move accuracy is multiplied by 1.67", async () => { const moveToCheck = allMoves[Moves.TACKLE]; @@ -41,14 +44,14 @@ describe("Arena - Gravity", () => { // Setup Gravity on first turn await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY)); + game.move.select(Moves.GRAVITY); await game.phaseInterceptor.to(TurnEndPhase); expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); // Use non-OHKO move on second turn await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 1.67); @@ -65,16 +68,77 @@ describe("Arena - Gravity", () => { // Setup Gravity on first turn await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY)); + game.move.select(Moves.GRAVITY); await game.phaseInterceptor.to(TurnEndPhase); expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); // Use OHKO move on second turn await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); + game.move.select(Moves.FISSURE); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(30); }); + + describe("Against flying types", () => { + it("can be hit by ground-type moves now", async () => { + game.override + .startingLevel(5) + .enemyLevel(5) + .enemySpecies(Species.PIDGEOT) + .moveset([Moves.GRAVITY, Moves.EARTHQUAKE]); + + await game.startBattle([Species.PIKACHU]); + + const pidgeot = game.scene.getEnemyPokemon()!; + vi.spyOn(pidgeot, "getAttackTypeEffectiveness"); + + // Try earthquake on 1st turn (fails!); + game.move.select(Moves.EARTHQUAKE); + await game.phaseInterceptor.to(TurnEndPhase); + + expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(0); + + // Setup Gravity on 2nd turn + await game.toNextTurn(); + game.move.select(Moves.GRAVITY); + await game.phaseInterceptor.to(TurnEndPhase); + + expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); + + // Use ground move on 3rd turn + await game.toNextTurn(); + game.move.select(Moves.EARTHQUAKE); + await game.phaseInterceptor.to(TurnEndPhase); + + expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(1); + }); + + it("keeps super-effective moves super-effective after using gravity", async () => { + game.override + .startingLevel(5) + .enemyLevel(5) + .enemySpecies(Species.PIDGEOT) + .moveset([Moves.GRAVITY, Moves.THUNDERBOLT]); + + await game.startBattle([Species.PIKACHU]); + + const pidgeot = game.scene.getEnemyPokemon()!; + vi.spyOn(pidgeot, "getAttackTypeEffectiveness"); + + // Setup Gravity on 1st turn + game.move.select(Moves.GRAVITY); + await game.phaseInterceptor.to(TurnEndPhase); + + expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); + + // Use electric move on 2nd turn + await game.toNextTurn(); + game.move.select(Moves.THUNDERBOLT); + await game.phaseInterceptor.to(TurnEndPhase); + + expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(2); + }); + }); }); diff --git a/src/test/arena/weather_fog.test.ts b/src/test/arena/weather_fog.test.ts index 350007ae943..b36b0de2e06 100644 --- a/src/test/arena/weather_fog.test.ts +++ b/src/test/arena/weather_fog.test.ts @@ -1,11 +1,10 @@ -import { allMoves } from "#app/data/move.js"; -import { WeatherType } from "#app/data/weather.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { WeatherType } from "#app/data/weather"; +import { Abilities } from "#app/enums/abilities"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -41,7 +40,7 @@ describe("Weather - Fog", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 0.9); diff --git a/src/test/arena/weather_strong_winds.test.ts b/src/test/arena/weather_strong_winds.test.ts index 79fba30c019..8b2d3e2547e 100644 --- a/src/test/arena/weather_strong_winds.test.ts +++ b/src/test/arena/weather_strong_winds.test.ts @@ -1,12 +1,11 @@ -import { allMoves } from "#app/data/move.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; describe("Weather - Strong Winds", () => { let phaserGame: Phaser.Game; @@ -38,7 +37,7 @@ describe("Weather - Strong Winds", () => { const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.THUNDERBOLT)); + game.move.select(Moves.THUNDERBOLT); await game.phaseInterceptor.to(TurnStartPhase); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.THUNDERBOLT].type, pikachu)).toBe(0.5); @@ -49,7 +48,7 @@ describe("Weather - Strong Winds", () => { const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.THUNDERBOLT)); + game.move.select(Moves.THUNDERBOLT); await game.phaseInterceptor.to(TurnStartPhase); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.THUNDERBOLT].type, pikachu)).toBe(1); @@ -60,7 +59,7 @@ describe("Weather - Strong Winds", () => { const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); + game.move.select(Moves.ICE_BEAM); await game.phaseInterceptor.to(TurnStartPhase); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.ICE_BEAM].type, pikachu)).toBe(1); @@ -71,7 +70,7 @@ describe("Weather - Strong Winds", () => { const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.ROCK_SLIDE)); + game.move.select(Moves.ROCK_SLIDE); await game.phaseInterceptor.to(TurnStartPhase); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.ROCK_SLIDE].type, pikachu)).toBe(1); diff --git a/src/test/battle-scene.test.ts b/src/test/battle-scene.test.ts index 21d3f689d1c..9e28ec99791 100644 --- a/src/test/battle-scene.test.ts +++ b/src/test/battle-scene.test.ts @@ -1,4 +1,4 @@ -import { LoadingScene } from "#app/loading-scene.js"; +import { LoadingScene } from "#app/loading-scene"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "./utils/gameManager"; diff --git a/src/test/battle-stat.spec.ts b/src/test/battle-stat.spec.ts index 775dd40ff34..16fce962838 100644 --- a/src/test/battle-stat.spec.ts +++ b/src/test/battle-stat.spec.ts @@ -1,4 +1,4 @@ -import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat.js"; +import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat"; import { describe, expect, it } from "vitest"; import { arrayOfRange, mockI18next } from "./utils/testUtils"; diff --git a/src/test/battle/battle-order.test.ts b/src/test/battle/battle-order.test.ts index ab6a173bafd..b354be75b9c 100644 --- a/src/test/battle/battle-order.test.ts +++ b/src/test/battle/battle-order.test.ts @@ -1,20 +1,13 @@ import { Stat } from "#app/data/pokemon-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import TargetSelectUiHandler from "#app/ui/target-select-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { Abilities } from "#enums/abilities"; -import { Button } from "#enums/buttons"; -import { Moves } from "#enums/moves"; -import { Species } from "#enums/species"; -import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; import { SelectTargetPhase } from "#app/phases/select-target-phase"; import { TurnStartPhase } from "#app/phases/turn-start-phase"; - +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Battle order", () => { let phaserGame: Phaser.Game; @@ -39,7 +32,7 @@ describe("Battle order", () => { game.override.moveset([Moves.TACKLE]); }); - it("opponent faster than player 50 vs 150", async() => { + it("opponent faster than player 50 vs 150", async () => { await game.startBattle([ Species.BULBASAUR, ]); @@ -47,13 +40,7 @@ describe("Battle order", () => { game.scene.getParty()[0].stats[Stat.SPD] = 50; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.run(EnemyCommandPhase); const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); @@ -64,20 +51,14 @@ describe("Battle order", () => { expect(order[1]).toBe(playerPokemonIndex); }, 20000); - it("Player faster than opponent 150 vs 50", async() => { + it("Player faster than opponent 150 vs 50", async () => { await game.startBattle([ Species.BULBASAUR, ]); game.scene.getParty()[0].stats[Stat.SPD] = 150; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 50; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.run(EnemyCommandPhase); const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); @@ -88,7 +69,7 @@ describe("Battle order", () => { expect(order[1]).toBe(enemyPokemonIndex); }, 20000); - it("double - both opponents faster than player 50/50 vs 150/150", async() => { + it("double - both opponents faster than player 50/50 vs 150/150", async () => { game.override.battleType("double"); await game.startBattle([ Species.BULBASAUR, @@ -105,28 +86,8 @@ describe("Battle order", () => { enemyPokemon1.stats[Stat.SPD] = 150; enemyPokemon2.stats[Stat.SPD] = 150; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = game.scene.ui.getHandler() as TargetSelectUiHandler; - handler.processInput(Button.ACTION); - }); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = game.scene.ui.getHandler() as TargetSelectUiHandler; - handler.processInput(Button.ACTION); - }); + game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE, 1); await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); const pp1Index = playerPokemon1?.getBattlerIndex(); @@ -141,7 +102,7 @@ describe("Battle order", () => { expect(order.slice(2,4).includes(pp2Index)).toBe(true); }, 20000); - it("double - speed tie except 1 - 100/100 vs 100/150", async() => { + it("double - speed tie except 1 - 100/100 vs 100/150", async () => { game.override.battleType("double"); await game.startBattle([ Species.BULBASAUR, @@ -157,28 +118,8 @@ describe("Battle order", () => { enemyPokemon1.stats[Stat.SPD] = 100; enemyPokemon2.stats[Stat.SPD] = 150; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = game.scene.ui.getHandler() as TargetSelectUiHandler; - handler.processInput(Button.ACTION); - }); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = game.scene.ui.getHandler() as TargetSelectUiHandler; - handler.processInput(Button.ACTION); - }); + game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE, 1); await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); const pp1Index = playerPokemon1?.getBattlerIndex(); @@ -193,7 +134,7 @@ describe("Battle order", () => { expect(order.slice(1,4).includes(pp1Index)).toBe(true); }, 20000); - it("double - speed tie 100/150 vs 100/150", async() => { + it("double - speed tie 100/150 vs 100/150", async () => { game.override.battleType("double"); await game.startBattle([ Species.BULBASAUR, @@ -209,28 +150,8 @@ describe("Battle order", () => { enemyPokemon1.stats[Stat.SPD] = 100; enemyPokemon2.stats[Stat.SPD] = 150; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = game.scene.ui.getHandler() as TargetSelectUiHandler; - handler.processInput(Button.ACTION); - }); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = game.scene.ui.getHandler() as TargetSelectUiHandler; - handler.processInput(Button.ACTION); - }); + game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE, 1); await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); const pp1Index = playerPokemon1?.getBattlerIndex(); diff --git a/src/test/battle/battle.test.ts b/src/test/battle/battle.test.ts index 43d8ddce4b0..c79eee63a7c 100644 --- a/src/test/battle/battle.test.ts +++ b/src/test/battle/battle.test.ts @@ -1,10 +1,23 @@ import { allSpecies } from "#app/data/pokemon-species"; -import { TempBattleStat } from "#app/data/temp-battle-stat.js"; -import { GameModes } from "#app/game-mode"; -import { getGameMode } from "#app/game-mode.js"; +import { TempBattleStat } from "#app/data/temp-battle-stat"; +import { GameModes, getGameMode } from "#app/game-mode"; +import { BattleEndPhase } from "#app/phases/battle-end-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { EncounterPhase } from "#app/phases/encounter-phase"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { LoginPhase } from "#app/phases/login-phase"; +import { NextEncounterPhase } from "#app/phases/next-encounter-phase"; +import { SelectGenderPhase } from "#app/phases/select-gender-phase"; +import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; +import { SelectStarterPhase } from "#app/phases/select-starter-phase"; +import { SummonPhase } from "#app/phases/summon-phase"; +import { SwitchPhase } from "#app/phases/switch-phase"; +import { TitlePhase } from "#app/phases/title-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; +import { VictoryPhase } from "#app/phases/victory-phase"; import GameManager from "#app/test/utils/gameManager"; -import { generateStarter, getMovePosition, } from "#app/test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; +import { generateStarter } from "#app/test/utils/gameManagerUtils"; import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; @@ -13,21 +26,6 @@ import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { BattleEndPhase } from "#app/phases/battle-end-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { EncounterPhase } from "#app/phases/encounter-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { LoginPhase } from "#app/phases/login-phase.js"; -import { NextEncounterPhase } from "#app/phases/next-encounter-phase.js"; -import { SelectGenderPhase } from "#app/phases/select-gender-phase.js"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase.js"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase.js"; -import { SummonPhase } from "#app/phases/summon-phase.js"; -import { SwitchPhase } from "#app/phases/switch-phase.js"; -import { TitlePhase } from "#app/phases/title-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; -import { VictoryPhase } from "#app/phases/victory-phase.js"; describe("Test Battle Phase", () => { let phaserGame: Phaser.Game; @@ -47,7 +45,7 @@ describe("Test Battle Phase", () => { game = new GameManager(phaserGame); }); - it("test phase interceptor with prompt", async() => { + it("test phase interceptor with prompt", async () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { @@ -65,7 +63,7 @@ describe("Test Battle Phase", () => { expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); }, 20000); - it("test phase interceptor with prompt with preparation for a future prompt", async() => { + it("test phase interceptor with prompt with preparation for a future prompt", async () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { @@ -87,13 +85,13 @@ describe("Test Battle Phase", () => { expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); }, 20000); - it("newGame one-liner", async() => { + it("newGame one-liner", async () => { await game.startBattle(); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("do attack wave 3 - single battle - regular - OHKO", async() => { + it("do attack wave 3 - single battle - regular - OHKO", async () => { game.override.starterSpecies(Species.MEWTWO); game.override.enemySpecies(Species.RATTATA); game.override.startingLevel(2000); @@ -104,17 +102,11 @@ describe("Test Battle Phase", () => { game.override.enemyAbility(Abilities.HYDRATION); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle(); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(SelectModifierPhase, false); }, 20000); - it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async() => { + it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async () => { game.override.starterSpecies(Species.MEWTWO); game.override.enemySpecies(Species.RATTATA); game.override.startingLevel(5); @@ -124,17 +116,11 @@ describe("Test Battle Phase", () => { game.override.enemyMoveset([Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP]); game.override.battleType("single"); await game.startBattle(); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase, false); }, 20000); - it("load 100% data file", async() => { + it("load 100% data file", async () => { await game.importData("src/test/utils/saves/everything.prsv"); const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { const species = game.scene.gameData.dexData[key]; @@ -143,7 +129,7 @@ describe("Test Battle Phase", () => { expect(caughtCount).toBe(Object.keys(allSpecies).length); }, 20000); - it("start battle with selected team", async() => { + it("start battle with selected team", async () => { await game.startBattle([ Species.CHARIZARD, Species.CHANSEY, @@ -154,26 +140,26 @@ describe("Test Battle Phase", () => { expect(game.scene.getParty()[2].species.speciesId).toBe(Species.MEW); }, 20000); - it("test remove random battle seed int", async() => { - for (let i=0; i<10; i++) { + it("test remove random battle seed int", async () => { + for (let i = 0; i < 10; i++) { const rand = game.scene.randBattleSeedInt(16); expect(rand).toBe(15); } }); - it("wrong phase", async() => { + it("wrong phase", async () => { await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase).catch((e) => { expect(e).toBe("Wrong phase: this is SelectGenderPhase and not LoginPhase"); }); }, 20000); - it("wrong phase but skip", async() => { + it("wrong phase but skip", async () => { await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase, () => game.isCurrentPhase(SelectGenderPhase)); }, 20000); - it("good run", async() => { + it("good run", async () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; @@ -183,7 +169,7 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(TitlePhase); }, 20000); - it("good run from select gender to title", async() => { + it("good run from select gender to title", async () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; @@ -192,7 +178,7 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.runFrom(SelectGenderPhase).to(TitlePhase); }, 20000); - it("good run to SummonPhase phase", async() => { + it("good run to SummonPhase phase", async () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; @@ -208,7 +194,7 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase); }, 20000); - it("2vs1", async() => { + it("2vs1", async () => { game.override.battleType("single"); game.override.enemySpecies(Species.MIGHTYENA); game.override.enemyAbility(Abilities.HYDRATION); @@ -221,7 +207,7 @@ describe("Test Battle Phase", () => { expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("1vs1", async() => { + it("1vs1", async () => { game.override.battleType("single"); game.override.enemySpecies(Species.MIGHTYENA); game.override.enemyAbility(Abilities.HYDRATION); @@ -233,7 +219,7 @@ describe("Test Battle Phase", () => { expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("2vs2", async() => { + it("2vs2", async () => { game.override.battleType("double"); game.override.enemySpecies(Species.MIGHTYENA); game.override.enemyAbility(Abilities.HYDRATION); @@ -247,7 +233,7 @@ describe("Test Battle Phase", () => { expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("4vs2", async() => { + it("4vs2", async () => { game.override.battleType("double"); game.override.enemySpecies(Species.MIGHTYENA); game.override.enemyAbility(Abilities.HYDRATION); @@ -263,7 +249,7 @@ describe("Test Battle Phase", () => { expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("kill opponent pokemon", async() => { + it("kill opponent pokemon", async () => { const moveToUse = Moves.SPLASH; game.override.battleType("single"); game.override.starterSpecies(Species.MEWTWO); @@ -273,26 +259,20 @@ describe("Test Battle Phase", () => { game.override.startingLevel(2000); game.override.startingWave(3); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle([ Species.DARMANITAN, Species.CHARIZARD, ]); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.phaseInterceptor.to(DamagePhase, false); await game.killPokemon(game.scene.currentBattle.enemyParty[0]); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); await game.phaseInterceptor.to(VictoryPhase, false); }, 200000); - it("to next turn", async() => { + it("to next turn", async () => { const moveToUse = Moves.SPLASH; game.override.battleType("single"); game.override.starterSpecies(Species.MEWTWO); @@ -302,15 +282,15 @@ describe("Test Battle Phase", () => { game.override.startingLevel(2000); game.override.startingWave(3); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle(); const turn = game.scene.currentBattle.turn; - game.doAttack(0); + game.move.select(moveToUse); await game.toNextTurn(); expect(game.scene.currentBattle.turn).toBeGreaterThan(turn); }, 20000); - it("to next wave with pokemon killed, single", async() => { + it("to next wave with pokemon killed, single", async () => { const moveToUse = Moves.SPLASH; game.override.battleType("single"); game.override.starterSpecies(Species.MEWTWO); @@ -320,10 +300,10 @@ describe("Test Battle Phase", () => { game.override.startingLevel(2000); game.override.startingWave(3); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle(); const waveIndex = game.scene.currentBattle.waveIndex; - game.doAttack(0); + game.move.select(moveToUse); await game.doKillOpponents(); await game.toNextWave(); expect(game.scene.currentBattle.waveIndex).toBeGreaterThan(waveIndex); @@ -343,7 +323,7 @@ describe("Test Battle Phase", () => { await game.startBattle(); game.scene.getPlayerPokemon()!.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(BattleEndPhase); game.doRevivePokemon(0); // pretend max revive was picked diff --git a/src/test/battle/damage_calculation.test.ts b/src/test/battle/damage_calculation.test.ts new file mode 100644 index 00000000000..665000450be --- /dev/null +++ b/src/test/battle/damage_calculation.test.ts @@ -0,0 +1,70 @@ +import { DamagePhase } from "#app/phases/damage-phase.js"; +import { toDmgValue } from "#app/utils"; +import { Abilities } from "#enums/abilities"; +import { ArenaTagType } from "#enums/arena-tag-type"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +describe("Round Down and Minimun 1 test in Damage Calculation", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override.battleType("single"); + game.override.startingLevel(10); + }); + + it("When the user fails to use Jump Kick with Wonder Guard ability, the damage should be 1.", async () => { + game.override.enemySpecies(Species.GASTLY); + game.override.enemyMoveset(SPLASH_ONLY); + game.override.starterSpecies(Species.SHEDINJA); + game.override.moveset([Moves.JUMP_KICK]); + game.override.ability(Abilities.WONDER_GUARD); + + await game.startBattle(); + + const shedinja = game.scene.getPlayerPokemon()!; + + game.move.select(Moves.JUMP_KICK); + + await game.phaseInterceptor.to(DamagePhase); + + expect(shedinja.hp).toBe(shedinja.getMaxHp() - 1); + }); + + + it("Charizard with odd HP survives Stealth Rock damage twice", async () => { + game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0); + game.override.seed("Charizard Stealth Rock test"); + game.override.enemySpecies(Species.CHARIZARD); + game.override.enemyAbility(Abilities.BLAZE); + game.override.starterSpecies(Species.PIKACHU); + game.override.enemyLevel(100); + + await game.startBattle(); + + const charizard = game.scene.getEnemyPokemon()!; + + const maxHp = charizard.getMaxHp(); + const damage_prediction = toDmgValue(charizard.getMaxHp() / 2); + const currentHp = charizard.hp; + const expectedHP = maxHp - damage_prediction; + + expect(currentHp).toBe(expectedHP); + }); +}); diff --git a/src/test/battle/double_battle.test.ts b/src/test/battle/double_battle.test.ts index d2ee3812b3e..d264a29ef9b 100644 --- a/src/test/battle/double_battle.test.ts +++ b/src/test/battle/double_battle.test.ts @@ -1,13 +1,12 @@ -import GameManager from "#test/utils/gameManager"; -import { getMovePosition, } from "#test/utils/gameManagerUtils"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { BattleEndPhase } from "#app/phases/battle-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { BattleEndPhase } from "#app/phases/battle-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Double Battles", () => { let phaserGame: Phaser.Game; @@ -29,7 +28,7 @@ describe("Double Battles", () => { // double-battle player's pokemon both fainted in same round, then revive one, and next double battle summons two player's pokemon successfully. // (There were bugs that either only summon one when can summon two, player stuck in switchPhase etc) - it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async() => { + it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async () => { game.override.battleType("double").enemyMoveset(SPLASH_ONLY).moveset(SPLASH_ONLY); await game.startBattle([ Species.BULBASAUR, @@ -37,8 +36,8 @@ describe("Double Battles", () => { Species.SQUIRTLE, ]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH, 1); for (const pokemon of game.scene.getPlayerField()) { pokemon.hp = 0; diff --git a/src/test/battle/error-handling.test.ts b/src/test/battle/error-handling.test.ts index a88d7cd8c18..da5cc4d1969 100644 --- a/src/test/battle/error-handling.test.ts +++ b/src/test/battle/error-handling.test.ts @@ -1,13 +1,14 @@ -import GameManager from "#test/utils/gameManager"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Error Handling", () => { let phaserGame: Phaser.Game; let game: GameManager; + const moveToUse = Moves.SPLASH; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -21,7 +22,6 @@ describe("Error Handling", () => { beforeEach(() => { game = new GameManager(phaserGame); - const moveToUse = Moves.SPLASH; game.override .battleType("single") .startingWave(3); @@ -31,13 +31,13 @@ describe("Error Handling", () => { game.override.ability(Abilities.ZEN_MODE); game.override.startingLevel(2000); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it.skip("to next turn", async() => { + it.skip("to next turn", async () => { await game.startBattle(); const turn = game.scene.currentBattle.turn; - game.doAttack(0); + game.move.select(moveToUse); await game.toNextTurn(); expect(game.scene.currentBattle.turn).toBeGreaterThan(turn); }, 20000); diff --git a/src/test/battle/special_battle.test.ts b/src/test/battle/special_battle.test.ts index 9b0fd1b3ab1..1d319bea372 100644 --- a/src/test/battle/special_battle.test.ts +++ b/src/test/battle/special_battle.test.ts @@ -1,9 +1,9 @@ -import { CommandPhase } from "#app/phases/command-phase.js"; -import GameManager from "#test/utils/gameManager"; +import { CommandPhase } from "#app/phases/command-phase"; import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; diff --git a/src/test/battlerTags/octolock.test.ts b/src/test/battlerTags/octolock.test.ts index a69b45cdfd2..fa491589f09 100644 --- a/src/test/battlerTags/octolock.test.ts +++ b/src/test/battlerTags/octolock.test.ts @@ -1,10 +1,10 @@ +import BattleScene from "#app/battle-scene"; +import { BattleStat } from "#app/data/battle-stat"; +import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import Pokemon from "#app/field/pokemon"; +import { StatChangePhase } from "#app/phases/stat-change-phase"; import { describe, expect, it, vi } from "vitest"; -import Pokemon from "#app/field/pokemon.js"; -import BattleScene from "#app/battle-scene.js"; -import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags.js"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { StatChangePhase } from "#app/phases/stat-change-phase.js"; vi.mock("#app/battle-scene.js"); diff --git a/src/test/battlerTags/stockpiling.test.ts b/src/test/battlerTags/stockpiling.test.ts index 1a39d11e1bd..fef1e938c09 100644 --- a/src/test/battlerTags/stockpiling.test.ts +++ b/src/test/battlerTags/stockpiling.test.ts @@ -1,10 +1,10 @@ +import BattleScene from "#app/battle-scene"; +import { BattleStat } from "#app/data/battle-stat"; +import { StockpilingTag } from "#app/data/battler-tags"; +import Pokemon, { PokemonSummonData } from "#app/field/pokemon"; +import * as messages from "#app/messages"; +import { StatChangePhase } from "#app/phases/stat-change-phase"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import Pokemon, { PokemonSummonData } from "#app/field/pokemon.js"; -import BattleScene from "#app/battle-scene.js"; -import { StockpilingTag } from "#app/data/battler-tags.js"; -import { BattleStat } from "#app/data/battle-stat.js"; -import * as messages from "#app/messages.js"; -import { StatChangePhase } from "#app/phases/stat-change-phase.js"; beforeEach(() => { vi.spyOn(messages, "getPokemonNameWithAffix").mockImplementation(() => ""); diff --git a/src/test/eggs/egg.test.ts b/src/test/eggs/egg.test.ts index 0bc2972e2dc..a01d2257099 100644 --- a/src/test/eggs/egg.test.ts +++ b/src/test/eggs/egg.test.ts @@ -1,14 +1,14 @@ +import { Egg, getLegendaryGachaSpeciesForTimestamp } from "#app/data/egg"; +import { EggSourceType } from "#app/enums/egg-source-types"; +import { EggTier } from "#app/enums/egg-type"; +import { VariantTier } from "#app/enums/variant-tiers"; +import EggData from "#app/system/egg-data"; +import * as Utils from "#app/utils"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import BattleScene from "../../battle-scene"; -import { Egg, getLegendaryGachaSpeciesForTimestamp } from "#app/data/egg.js"; -import { Species } from "#enums/species"; -import Phaser from "phaser"; -import { EggSourceType } from "#app/enums/egg-source-types.js"; -import { EggTier } from "#app/enums/egg-type.js"; -import { VariantTier } from "#app/enums/variant-tiers.js"; -import GameManager from "#test/utils/gameManager"; -import EggData from "#app/system/egg-data.js"; -import * as Utils from "#app/utils.js"; describe("Egg Generation Tests", () => { let phaserGame: Phaser.Game; diff --git a/src/test/evolution.test.ts b/src/test/evolution.test.ts index b54deaa4611..41088c17bcb 100644 --- a/src/test/evolution.test.ts +++ b/src/test/evolution.test.ts @@ -1,6 +1,6 @@ -import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { Species } from "#app/enums/species.js"; +import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions"; +import { Abilities } from "#app/enums/abilities"; +import { Species } from "#app/enums/species"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; diff --git a/src/test/evolutions/evolutions.test.ts b/src/test/evolutions/evolutions.test.ts index af43e91b059..2028764115c 100644 --- a/src/test/evolutions/evolutions.test.ts +++ b/src/test/evolutions/evolutions.test.ts @@ -1,8 +1,8 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; import * as Utils from "#app/utils"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; describe("Evolution tests", () => { let phaserGame: Phaser.Game; diff --git a/src/test/field/pokemon.test.ts b/src/test/field/pokemon.test.ts index ee8e41e8b42..d597cd5219c 100644 --- a/src/test/field/pokemon.test.ts +++ b/src/test/field/pokemon.test.ts @@ -1,4 +1,4 @@ -import { Species } from "#app/enums/species.js"; +import { Species } from "#app/enums/species"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "../utils/gameManager"; diff --git a/src/test/final_boss.test.ts b/src/test/final_boss.test.ts index a57d71534a3..0f59572619b 100644 --- a/src/test/final_boss.test.ts +++ b/src/test/final_boss.test.ts @@ -1,8 +1,8 @@ -import { Biome } from "#app/enums/biome.js"; -import { Species } from "#app/enums/species.js"; +import { Biome } from "#app/enums/biome"; +import { Species } from "#app/enums/species"; +import { GameModes } from "#app/game-mode"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "./utils/gameManager"; -import { GameModes } from "#app/game-mode"; const FinalWave = { Classic: 200, diff --git a/src/test/game-mode.test.ts b/src/test/game-mode.test.ts index 4a1960a05ff..ccec3a3aa16 100644 --- a/src/test/game-mode.test.ts +++ b/src/test/game-mode.test.ts @@ -1,7 +1,7 @@ -import { GameMode, GameModes, getGameMode } from "#app/game-mode.js"; +import { GameMode, GameModes, getGameMode } from "#app/game-mode"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import GameManager from "./utils/gameManager"; import * as Utils from "../utils"; +import GameManager from "./utils/gameManager"; describe("game-mode", () => { let phaserGame: Phaser.Game; let game: GameManager; diff --git a/src/test/imports.test.ts b/src/test/imports.test.ts index 69c145236bc..305eccdc465 100644 --- a/src/test/imports.test.ts +++ b/src/test/imports.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, it } from "vitest"; import { initStatsKeys } from "#app/ui/game-stats-ui-handler"; +import { describe, expect, it } from "vitest"; async function importModule() { try { diff --git a/src/test/inputs/inputs.test.ts b/src/test/inputs/inputs.test.ts index 7182ac2c02c..6306c1b9da6 100644 --- a/src/test/inputs/inputs.test.ts +++ b/src/test/inputs/inputs.test.ts @@ -1,9 +1,9 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import pad_xbox360 from "#app/configs/inputs/pad_xbox360"; import cfg_keyboard_qwerty from "#app/configs/inputs/cfg_keyboard_qwerty"; +import pad_xbox360 from "#app/configs/inputs/pad_xbox360"; +import GameManager from "#test/utils/gameManager"; import InputsHandler from "#test/utils/inputsHandler"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Inputs", () => { diff --git a/src/test/internals.test.ts b/src/test/internals.test.ts index 0ecd156431d..3c76b40e901 100644 --- a/src/test/internals.test.ts +++ b/src/test/internals.test.ts @@ -1,8 +1,8 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; +import { Abilities } from "#app/enums/abilities"; +import { Species } from "#app/enums/species"; import GameManager from "#test/utils/gameManager"; -import { Species } from "#app/enums/species.js"; -import { Abilities } from "#app/enums/abilities.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Internals", () => { let phaserGame: Phaser.Game; diff --git a/src/test/items/eviolite.test.ts b/src/test/items/eviolite.test.ts index 0fe90866de8..e491784acec 100644 --- a/src/test/items/eviolite.test.ts +++ b/src/test/items/eviolite.test.ts @@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat"; import { EvolutionStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; import * as Utils from "#app/utils"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/src/test/items/exp_booster.test.ts b/src/test/items/exp_booster.test.ts index 2b700c92086..9a7464e4866 100644 --- a/src/test/items/exp_booster.test.ts +++ b/src/test/items/exp_booster.test.ts @@ -1,7 +1,7 @@ -import { Abilities } from "#app/enums/abilities.js"; -import { PokemonExpBoosterModifier } from "#app/modifier/modifier.js"; -import GameManager from "#test/utils/gameManager"; +import { Abilities } from "#app/enums/abilities"; +import { PokemonExpBoosterModifier } from "#app/modifier/modifier"; import * as Utils from "#app/utils"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; diff --git a/src/test/items/grip_claw.test.ts b/src/test/items/grip_claw.test.ts index ecf144c96c5..09afa9aea0b 100644 --- a/src/test/items/grip_claw.test.ts +++ b/src/test/items/grip_claw.test.ts @@ -1,16 +1,14 @@ -import { BattlerIndex } from "#app/battle.js"; -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { BerryType } from "#app/enums/berry-type.js"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; +import { BattlerIndex } from "#app/battle"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { BerryType } from "#app/enums/berry-type"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; +import { SPLASH_ONLY } from "../utils/testUtils"; const TIMEOUT = 20 * 1000; // 20 seconds @@ -35,12 +33,12 @@ describe("Items - Grip Claw", () => { .battleType("double") .moveset([Moves.POPULATION_BOMB, Moves.SPLASH]) .startingHeldItems([ - { name: "GRIP_CLAW", count: 5 }, + { name: "GRIP_CLAW", count: 5 }, // TODO: Find a way to mock the steal chance of grip claw { name: "MULTI_LENS", count: 3 }, ]) .enemySpecies(Species.SNORLAX) .ability(Abilities.KLUTZ) - .enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]) + .enemyMoveset(SPLASH_ONLY) .enemyHeldItems([ { name: "BERRY", type: BerryType.SITRUS, count: 2 }, { name: "BERRY", type: BerryType.LUM, count: 2 }, @@ -54,19 +52,14 @@ describe("Items - Grip Claw", () => { it( "should only steal items from the attack target", async () => { - await game.startBattle([Species.PANSEAR, Species.ROWLET, Species.PANPOUR, Species.PANSAGE, Species.CHARMANDER, Species.SQUIRTLE]); + await game.startBattle([Species.PANSEAR, Species.ROWLET]); const enemyPokemon = game.scene.getEnemyField(); const enemyHeldItemCt = enemyPokemon.map(p => p.getHeldItems.length); - game.doAttack(getMovePosition(game.scene, 0, Moves.POPULATION_BOMB)); - - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY); - - await game.phaseInterceptor.to(CommandPhase, false); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.POPULATION_BOMB, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEndPhase, false); diff --git a/src/test/items/leek.test.ts b/src/test/items/leek.test.ts index 1e46bda9f0f..7505b6374a0 100644 --- a/src/test/items/leek.test.ts +++ b/src/test/items/leek.test.ts @@ -1,11 +1,11 @@ import { BattlerIndex } from "#app/battle"; import { CritBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import * as Utils from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -27,21 +27,21 @@ describe("Items - Leek", () => { game = new GameManager(phaserGame); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); game.override.disableCrits(); game.override.battleType("single"); }); - it("LEEK activates in battle correctly", async() => { + it("LEEK activates in battle correctly", async () => { game.override.startingHeldItems([{ name: "LEEK" }]); - game.override.moveset([ Moves.POUND ]); + game.override.moveset([Moves.POUND]); const consoleSpy = vi.spyOn(console, "log"); await game.startBattle([ Species.FARFETCHD ]); - game.doAttack(0); + game.move.select(Moves.POUND); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); @@ -50,7 +50,7 @@ describe("Items - Leek", () => { expect(consoleSpy).toHaveBeenCalledWith("Applied", "Leek", ""); }, 20000); - it("LEEK held by FARFETCHD", async() => { + it("LEEK held by FARFETCHD", async () => { await game.startBattle([ Species.FARFETCHD ]); @@ -70,7 +70,7 @@ describe("Items - Leek", () => { expect(critLevel.value).toBe(2); }, 20000); - it("LEEK held by GALAR_FARFETCHD", async() => { + it("LEEK held by GALAR_FARFETCHD", async () => { await game.startBattle([ Species.GALAR_FARFETCHD ]); @@ -90,7 +90,7 @@ describe("Items - Leek", () => { expect(critLevel.value).toBe(2); }, 20000); - it("LEEK held by SIRFETCHD", async() => { + it("LEEK held by SIRFETCHD", async () => { await game.startBattle([ Species.SIRFETCHD ]); @@ -110,9 +110,9 @@ describe("Items - Leek", () => { expect(critLevel.value).toBe(2); }, 20000); - it("LEEK held by fused FARFETCHD line (base)", async() => { + it("LEEK held by fused FARFETCHD line (base)", async () => { // Randomly choose from the Farfetch'd line - const species = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; + const species = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD]; await game.startBattle([ species[Utils.randInt(species.length)], @@ -145,9 +145,9 @@ describe("Items - Leek", () => { expect(critLevel.value).toBe(2); }, 20000); - it("LEEK held by fused FARFETCHD line (part)", async() => { + it("LEEK held by fused FARFETCHD line (part)", async () => { // Randomly choose from the Farfetch'd line - const species = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; + const species = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD]; await game.startBattle([ Species.PIKACHU, @@ -180,7 +180,7 @@ describe("Items - Leek", () => { expect(critLevel.value).toBe(2); }, 20000); - it("LEEK not held by FARFETCHD line", async() => { + it("LEEK not held by FARFETCHD line", async () => { await game.startBattle([ Species.PIKACHU ]); diff --git a/src/test/items/leftovers.test.ts b/src/test/items/leftovers.test.ts index 1a1c95ad9e6..8e548542436 100644 --- a/src/test/items/leftovers.test.ts +++ b/src/test/items/leftovers.test.ts @@ -1,12 +1,11 @@ -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Items - Leftovers", () => { @@ -32,10 +31,10 @@ describe("Items - Leftovers", () => { game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.UNNERVE); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); - game.override.startingHeldItems([{name: "LEFTOVERS", count: 1}]); + game.override.startingHeldItems([{ name: "LEFTOVERS", count: 1 }]); }); - it("leftovers works", async() => { + it("leftovers works", async () => { await game.startBattle([Species.ARCANINE]); // Make sure leftovers are there @@ -46,7 +45,7 @@ describe("Items - Leftovers", () => { // We should have full hp expect(leadPokemon.isFullHp()).toBe(true); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); // We should have less hp after the attack await game.phaseInterceptor.to(DamagePhase, false); diff --git a/src/test/items/light_ball.test.ts b/src/test/items/light_ball.test.ts index ff7dfa4eba5..cf4f5c9e22f 100644 --- a/src/test/items/light_ball.test.ts +++ b/src/test/items/light_ball.test.ts @@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; import * as Utils from "#app/utils"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/src/test/items/lock_capsule.test.ts b/src/test/items/lock_capsule.test.ts index 0909e51ea2c..bc4ca1cb014 100644 --- a/src/test/items/lock_capsule.test.ts +++ b/src/test/items/lock_capsule.test.ts @@ -1,11 +1,10 @@ +import { Abilities } from "#app/enums/abilities"; +import { Moves } from "#app/enums/moves"; +import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type"; +import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { Abilities } from "#app/enums/abilities.js"; -import { Moves } from "#app/enums/moves.js"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type.js"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase.js"; describe("Items - Lock Capsule", () => { let phaserGame: Phaser.Game; @@ -29,13 +28,13 @@ describe("Items - Lock Capsule", () => { .startingLevel(200) .moveset([Moves.SURF]) .enemyAbility(Abilities.BALL_FETCH) - .startingModifier([{name: "LOCK_CAPSULE"}]); + .startingModifier([{ name: "LOCK_CAPSULE" }]); }); - it("doesn't set the cost of common tier items to 0", async() => { + it("doesn't set the cost of common tier items to 0", async () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); + game.move.select(Moves.SURF); await game.phaseInterceptor.to(SelectModifierPhase, false); const rewards = game.scene.getCurrentPhase() as SelectModifierPhase; diff --git a/src/test/items/metal_powder.test.ts b/src/test/items/metal_powder.test.ts index 966762e4175..a3a4936532f 100644 --- a/src/test/items/metal_powder.test.ts +++ b/src/test/items/metal_powder.test.ts @@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; import * as Utils from "#app/utils"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/src/test/items/quick_powder.test.ts b/src/test/items/quick_powder.test.ts index d2435dab431..53521ba78f1 100644 --- a/src/test/items/quick_powder.test.ts +++ b/src/test/items/quick_powder.test.ts @@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; import * as Utils from "#app/utils"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/src/test/items/scope_lens.test.ts b/src/test/items/scope_lens.test.ts index fa605ca7129..85673218762 100644 --- a/src/test/items/scope_lens.test.ts +++ b/src/test/items/scope_lens.test.ts @@ -1,11 +1,11 @@ import { BattlerIndex } from "#app/battle"; import { CritBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import * as Utils from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -27,30 +27,30 @@ describe("Items - Scope Lens", () => { game = new GameManager(phaserGame); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); game.override.disableCrits(); game.override.battleType("single"); }, 20000); - it("SCOPE_LENS activates in battle correctly", async() => { + it("SCOPE_LENS activates in battle correctly", async () => { game.override.startingHeldItems([{ name: "SCOPE_LENS" }]); - game.override.moveset([ Moves.POUND ]); + game.override.moveset([Moves.POUND]); const consoleSpy = vi.spyOn(console, "log"); await game.startBattle([ Species.GASTLY ]); - game.doAttack(0); + game.move.select(Moves.POUND); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); expect(consoleSpy).toHaveBeenCalledWith("Applied", "Scope Lens", ""); }, 20000); - it("SCOPE_LENS held by random pokemon", async() => { + it("SCOPE_LENS held by random pokemon", async () => { await game.startBattle([ Species.GASTLY ]); diff --git a/src/test/items/thick_club.test.ts b/src/test/items/thick_club.test.ts index 841cd7c90ac..347921446e6 100644 --- a/src/test/items/thick_club.test.ts +++ b/src/test/items/thick_club.test.ts @@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; import * as Utils from "#app/utils"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/src/test/items/toxic_orb.test.ts b/src/test/items/toxic_orb.test.ts index dc54a5a1c36..95336c0793e 100644 --- a/src/test/items/toxic_orb.test.ts +++ b/src/test/items/toxic_orb.test.ts @@ -1,18 +1,14 @@ import { StatusEffect } from "#app/data/status-effect"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import i18next, { initI18n } from "#app/plugins/i18n"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Items - Toxic orb", () => { @@ -45,7 +41,7 @@ describe("Items - Toxic orb", () => { }]); }); - it("TOXIC ORB", async() => { + it("TOXIC ORB", async () => { initI18n(); i18next.changeLanguage("en"); const moveToUse = Moves.GROWTH; @@ -55,15 +51,7 @@ describe("Items - Toxic orb", () => { ]); expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB"); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - // Select Attack - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - // Select Move Growth - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); // will run the 13 phase from enemyCommandPhase to TurnEndPhase await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); diff --git a/src/test/localization/battle-stat.test.ts b/src/test/localization/battle-stat.test.ts index b99ed2b7064..e8fc20ab5a4 100644 --- a/src/test/localization/battle-stat.test.ts +++ b/src/test/localization/battle-stat.test.ts @@ -1,26 +1,25 @@ -import { beforeAll, describe, expect, it } from "vitest"; -import { getBattleStatName, getBattleStatLevelChangeDescription } from "#app/data/battle-stat.js"; -import { BattleStat} from "#app/data/battle-stat.js"; -import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info.js"; -import { battle as enBattleStat } from "#app/locales/en/battle.js"; -import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info.js"; -import { battle as deBattleStat } from "#app/locales/de/battle.js"; -import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info.js"; -import { battle as esBattleStat } from "#app/locales/es/battle.js"; -import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info.js"; -import { battle as frBattleStat } from "#app/locales/fr/battle.js"; -import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info.js"; -import { battle as itBattleStat } from "#app/locales/it/battle.js"; -import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info.js"; -import { battle as koBattleStat } from "#app/locales/ko/battle.js"; -import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info.js"; -import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle.js"; -import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info.js"; -import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle.js"; -import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info.js"; -import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle.js"; +import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat"; +import { battle as deBattleStat } from "#app/locales/de/battle"; +import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info"; +import { battle as enBattleStat } from "#app/locales/en/battle"; +import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info"; +import { battle as esBattleStat } from "#app/locales/es/battle"; +import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info"; +import { battle as frBattleStat } from "#app/locales/fr/battle"; +import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info"; +import { battle as itBattleStat } from "#app/locales/it/battle"; +import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info"; +import { battle as koBattleStat } from "#app/locales/ko/battle"; +import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info"; +import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle"; +import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info"; +import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle"; +import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info"; +import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle"; +import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info"; import i18next, { initI18n } from "#app/plugins/i18n"; import { KoreanPostpositionProcessor } from "i18next-korean-postposition-processor"; +import { beforeAll, describe, expect, it } from "vitest"; interface BattleStatTestUnit { stat: BattleStat, diff --git a/src/test/localization/french.test.ts b/src/test/localization/french.test.ts index b03a8ee64e8..92b4c82d7cb 100644 --- a/src/test/localization/french.test.ts +++ b/src/test/localization/french.test.ts @@ -1,9 +1,9 @@ -import { afterEach, beforeAll, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; -import i18next from "i18next"; import { initI18n } from "#app/plugins/i18n"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import i18next from "i18next"; +import Phaser from "phaser"; +import { afterEach, beforeAll, describe, expect, it } from "vitest"; describe("Lokalization - french", () => { let phaserGame: Phaser.Game; diff --git a/src/test/localization/status-effect.test.ts b/src/test/localization/status-effect.test.ts index 8a9effe1672..9dcab5aeb5f 100644 --- a/src/test/localization/status-effect.test.ts +++ b/src/test/localization/status-effect.test.ts @@ -1,7 +1,7 @@ -import { beforeAll, describe, afterEach, expect, it, vi } from "vitest"; import { StatusEffect, getStatusEffectActivationText, getStatusEffectDescriptor, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "#app/data/status-effect"; -import i18next from "i18next"; import { mockI18next } from "#test/utils/testUtils"; +import i18next from "i18next"; +import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; const pokemonName = "PKM"; const sourceText = "SOURCE"; diff --git a/src/test/localization/terrain.test.ts b/src/test/localization/terrain.test.ts index c072f9cc9ab..ed280177a06 100644 --- a/src/test/localization/terrain.test.ts +++ b/src/test/localization/terrain.test.ts @@ -1,11 +1,11 @@ import { TerrainType, getTerrainName } from "#app/data/terrain"; import { getTerrainBlockMessage, getTerrainClearMessage, getTerrainStartMessage } from "#app/data/weather"; -import GameManager from "#test/utils/gameManager"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { mockI18next } from "#test/utils/testUtils"; import i18next from "i18next"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { mockI18next } from "#test/utils/testUtils"; describe("terrain", () => { let phaserGame: Phaser.Game; diff --git a/src/test/moves/astonish.test.ts b/src/test/moves/astonish.test.ts index 21a82f09d33..b21e2a06051 100644 --- a/src/test/moves/astonish.test.ts +++ b/src/test/moves/astonish.test.ts @@ -1,16 +1,15 @@ -import { allMoves } from "#app/data/move.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; +import { allMoves } from "#app/data/move"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -50,7 +49,7 @@ describe("Moves - Astonish", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.ASTONISH)); + game.move.select(Moves.ASTONISH); await game.phaseInterceptor.to(MoveEndPhase, false); @@ -63,7 +62,7 @@ describe("Moves - Astonish", () => { await game.phaseInterceptor.to(CommandPhase, false); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/aurora_veil.test.ts b/src/test/moves/aurora_veil.test.ts index 5429efec2bf..fec280debf4 100644 --- a/src/test/moves/aurora_veil.test.ts +++ b/src/test/moves/aurora_veil.test.ts @@ -1,15 +1,14 @@ -import { ArenaTagSide } from "#app/data/arena-tag.js"; -import Move, { allMoves } from "#app/data/move.js"; -import { WeatherType } from "#app/data/weather.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import Pokemon from "#app/field/pokemon.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { NumberHolder } from "#app/utils.js"; +import { ArenaTagSide } from "#app/data/arena-tag"; +import Move, { allMoves } from "#app/data/move"; +import { WeatherType } from "#app/data/weather"; +import { Abilities } from "#app/enums/abilities"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import Pokemon from "#app/field/pokemon"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { NumberHolder } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -18,7 +17,7 @@ describe("Moves - Aurora Veil", () => { let phaserGame: Phaser.Game; let game: GameManager; const singleBattleMultiplier = 0.5; - const doubleBattleMultiplier = 2732/4096; + const doubleBattleMultiplier = 2732 / 4096; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -42,11 +41,11 @@ describe("Moves - Aurora Veil", () => { game.override.weather(WeatherType.HAIL); }); - it("reduces damage of physical attacks by half in a single battle", async() => { + it("reduces damage of physical attacks by half in a single battle", async () => { const moveToUse = Moves.TACKLE; await game.startBattle([Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); @@ -54,14 +53,14 @@ describe("Moves - Aurora Veil", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); - it("reduces damage of physical attacks by a third in a double battle", async() => { + it("reduces damage of physical attacks by a third in a double battle", async () => { game.override.battleType("double"); const moveToUse = Moves.ROCK_SLIDE; await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); - game.doAttack(getMovePosition(game.scene, 1, moveToUse)); + game.move.select(moveToUse); + game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); @@ -69,11 +68,11 @@ describe("Moves - Aurora Veil", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); - it("reduces damage of special attacks by half in a single battle", async() => { + it("reduces damage of special attacks by half in a single battle", async () => { const moveToUse = Moves.ABSORB; await game.startBattle([Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); @@ -82,14 +81,14 @@ describe("Moves - Aurora Veil", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); - it("reduces damage of special attacks by a third in a double battle", async() => { + it("reduces damage of special attacks by a third in a double battle", async () => { game.override.battleType("double"); const moveToUse = Moves.DAZZLING_GLEAM; await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); - game.doAttack(getMovePosition(game.scene, 1, moveToUse)); + game.move.select(moveToUse); + game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); diff --git a/src/test/moves/baton_pass.test.ts b/src/test/moves/baton_pass.test.ts index 790eddbf45c..602da9e37f8 100644 --- a/src/test/moves/baton_pass.test.ts +++ b/src/test/moves/baton_pass.test.ts @@ -1,13 +1,12 @@ -import { BattleStat } from "#app/data/battle-stat.js"; +import { BattleStat } from "#app/data/battle-stat"; +import { PostSummonPhase } from "#app/phases/post-summon-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#app/test/utils/gameManager"; -import { getMovePosition } from "#app/test/utils/gameManagerUtils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { PostSummonPhase } from "#app/phases/post-summon-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - Baton Pass", () => { @@ -36,7 +35,7 @@ describe("Moves - Baton Pass", () => { .disableCrits(); }); - it("passes stat stage buffs when player uses it", async() => { + it("passes stat stage buffs when player uses it", async () => { // arrange await game.startBattle([ Species.RAICHU, @@ -44,12 +43,12 @@ describe("Moves - Baton Pass", () => { ]); // round 1 - buff - game.doAttack(getMovePosition(game.scene, 0, Moves.NASTY_PLOT)); + game.move.select(Moves.NASTY_PLOT); await game.toNextTurn(); expect(game.scene.getPlayerPokemon()!.summonData.battleStats[BattleStat.SPATK]).toEqual(2); // round 2 - baton pass - game.doAttack(getMovePosition(game.scene, 0, Moves.BATON_PASS)); + game.move.select(Moves.BATON_PASS); game.doSelectPartyPokemon(1); await game.phaseInterceptor.to(TurnEndPhase); @@ -59,7 +58,7 @@ describe("Moves - Baton Pass", () => { expect(playerPkm.summonData.battleStats[BattleStat.SPATK]).toEqual(2); }, 20000); - it("passes stat stage buffs when AI uses it", async() => { + it("passes stat stage buffs when AI uses it", async () => { // arrange game.override .startingWave(5) @@ -70,13 +69,13 @@ describe("Moves - Baton Pass", () => { ]); // round 1 - ai buffs - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.toNextTurn(); // round 2 - baton pass game.scene.getEnemyPokemon()!.hp = 100; game.override.enemyMoveset(new Array(4).fill(Moves.BATON_PASS)); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(PostSummonPhase, false); // assert diff --git a/src/test/moves/beak_blast.test.ts b/src/test/moves/beak_blast.test.ts index 8938b4c7af8..2a93dc00a54 100644 --- a/src/test/moves/beak_blast.test.ts +++ b/src/test/moves/beak_blast.test.ts @@ -1,15 +1,14 @@ -import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { StatusEffect } from "#app/enums/status-effect"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { MovePhase } from "#app/phases/move-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { StatusEffect } from "#app/enums/status-effect.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { MovePhase } from "#app/phases/move-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; const TIMEOUT = 20 * 1000; @@ -48,7 +47,7 @@ describe("Moves - Beak Blast", () => { const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); + game.move.select(Moves.BEAK_BLAST); await game.phaseInterceptor.to(MovePhase, false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); @@ -68,7 +67,7 @@ describe("Moves - Beak Blast", () => { const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); + game.move.select(Moves.BEAK_BLAST); await game.phaseInterceptor.to(MovePhase, false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); @@ -88,7 +87,7 @@ describe("Moves - Beak Blast", () => { const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); + game.move.select(Moves.BEAK_BLAST); await game.phaseInterceptor.to(MovePhase, false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); @@ -101,13 +100,13 @@ describe("Moves - Beak Blast", () => { it( "should only hit twice with Multi-Lens", async () => { - game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); await game.startBattle([Species.BLASTOISE]); const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); + game.move.select(Moves.BEAK_BLAST); await game.phaseInterceptor.to(BerryPhase, false); expect(leadPokemon.turnData.hitCount).toBe(2); @@ -124,7 +123,7 @@ describe("Moves - Beak Blast", () => { const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); + game.move.select(Moves.BEAK_BLAST); await game.phaseInterceptor.to(MovePhase, false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); diff --git a/src/test/moves/beat_up.test.ts b/src/test/moves/beat_up.test.ts index a0f168ea30f..ce1598a49b4 100644 --- a/src/test/moves/beat_up.test.ts +++ b/src/test/moves/beat_up.test.ts @@ -1,12 +1,11 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; +import { Abilities } from "#app/enums/abilities"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { StatusEffect } from "#app/enums/status-effect"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/utils/gameManager"; -import { Species } from "#app/enums/species.js"; -import { Moves } from "#app/enums/moves.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { StatusEffect } from "#app/enums/status-effect.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; const TIMEOUT = 20 * 1000; // 20 sec timeout @@ -46,7 +45,7 @@ describe("Moves - Beat Up", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; let enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP)); + game.move.select(Moves.BEAT_UP); await game.phaseInterceptor.to(MoveEffectPhase); @@ -70,7 +69,7 @@ describe("Moves - Beat Up", () => { game.scene.getParty()[1].trySetStatus(StatusEffect.BURN); - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP)); + game.move.select(Moves.BEAT_UP); await game.phaseInterceptor.to(MoveEffectPhase); @@ -81,14 +80,14 @@ describe("Moves - Beat Up", () => { it( "should hit twice for each player Pokemon if the user has Multi-Lens", async () => { - game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); await game.startBattle([Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; let enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP)); + game.move.select(Moves.BEAT_UP); await game.phaseInterceptor.to(MoveEffectPhase); diff --git a/src/test/moves/belly_drum.test.ts b/src/test/moves/belly_drum.test.ts index e579a4587ad..631de952a58 100644 --- a/src/test/moves/belly_drum.test.ts +++ b/src/test/moves/belly_drum.test.ts @@ -1,11 +1,11 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { toDmgValue } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; -import { BattleStat } from "#app/data/battle-stat"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; // RATIO : HP Cost of Move @@ -40,13 +40,13 @@ describe("Moves - BELLY DRUM", () => { // Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Belly_Drum_(move) test("Belly Drum raises the user's Attack to its max, at the cost of 1/2 of its maximum HP", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); + game.move.select(Moves.BELLY_DRUM); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); @@ -55,17 +55,17 @@ describe("Moves - BELLY DRUM", () => { ); test("Belly Drum will still take effect if an uninvolved stat is at max", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); // Here - BattleStat.ATK -> -3 and BattleStat.SPATK -> 6 leadPokemon.summonData.battleStats[BattleStat.ATK] = -3; leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6; - game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); + game.move.select(Moves.BELLY_DRUM); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); @@ -75,14 +75,14 @@ describe("Moves - BELLY DRUM", () => { ); test("Belly Drum fails if the pokemon's attack stat is at its maximum", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; leadPokemon.summonData.battleStats[BattleStat.ATK] = 6; - game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); + game.move.select(Moves.BELLY_DRUM); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); @@ -91,14 +91,14 @@ describe("Moves - BELLY DRUM", () => { ); test("Belly Drum fails if the user's health is less than 1/2", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); leadPokemon.hp = hpLost - PREDAMAGE; - game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); + game.move.select(Moves.BELLY_DRUM); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); diff --git a/src/test/moves/ceaseless_edge.test.ts b/src/test/moves/ceaseless_edge.test.ts index c8291a99b59..34ecf8f39f6 100644 --- a/src/test/moves/ceaseless_edge.test.ts +++ b/src/test/moves/ceaseless_edge.test.ts @@ -2,14 +2,13 @@ import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag"; import { allMoves } from "#app/data/move"; import { Abilities } from "#app/enums/abilities"; import { ArenaTagType } from "#app/enums/arena-tag-type"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -35,8 +34,8 @@ describe("Moves - Ceaseless Edge", () => { game.override.enemyPassiveAbility(Abilities.RUN_AWAY); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]); - game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]); + game.override.moveset([Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); }); @@ -44,13 +43,13 @@ describe("Moves - Ceaseless Edge", () => { test( "move should hit and apply spikes", async () => { - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE)); + game.move.select(Moves.CEASELESS_EDGE); await game.phaseInterceptor.to(MoveEffectPhase, false); // Spikes should not have any layers before move effect is applied @@ -68,14 +67,14 @@ describe("Moves - Ceaseless Edge", () => { test( "move should hit twice with multi lens and apply two layers of spikes", async () => { - game.override.startingHeldItems([{name: "MULTI_LENS"}]); - await game.startBattle([ Species.ILLUMISE ]); + game.override.startingHeldItems([{ name: "MULTI_LENS" }]); + await game.startBattle([Species.ILLUMISE]); const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE)); + game.move.select(Moves.CEASELESS_EDGE); await game.phaseInterceptor.to(MoveEffectPhase, false); // Spikes should not have any layers before move effect is applied @@ -93,12 +92,12 @@ describe("Moves - Ceaseless Edge", () => { test( "trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", async () => { - game.override.startingHeldItems([{name: "MULTI_LENS"}]); + game.override.startingHeldItems([{ name: "MULTI_LENS" }]); game.override.startingWave(5); - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); - game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE)); + game.move.select(Moves.CEASELESS_EDGE); await game.phaseInterceptor.to(MoveEffectPhase, false); // Spikes should not have any layers before move effect is applied const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; @@ -112,7 +111,7 @@ describe("Moves - Ceaseless Edge", () => { const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp; // Check HP of pokemon that WILL BE switched in (index 1) game.forceOpponentToSwitch(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase, false); expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes); }, TIMEOUT diff --git a/src/test/moves/clangorous_soul.test.ts b/src/test/moves/clangorous_soul.test.ts index 5b2e8b6e06d..9ea6da91595 100644 --- a/src/test/moves/clangorous_soul.test.ts +++ b/src/test/moves/clangorous_soul.test.ts @@ -1,12 +1,12 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { toDmgValue } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; -import { BattleStat } from "#app/data/battle-stat"; +import GameManager from "#test/utils/gameManager"; import { SPLASH_ONLY } from "#test/utils/testUtils"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; /** HP Cost of Move */ @@ -41,13 +41,13 @@ describe("Moves - CLANGOROUS_SOUL", () => { //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Clangorous_Soul_(move) test("Clangorous Soul raises the user's Attack, Defense, Special Attack, Special Defense and Speed by one stage each, at the cost of 1/3 of its maximum HP", - async() => { - await game.startBattle([Species.MAGIKARP]); + async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); + game.move.select(Moves.CLANGOROUS_SOUL); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); @@ -56,15 +56,15 @@ describe("Moves - CLANGOROUS_SOUL", () => { expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(1); expect(leadPokemon.summonData.battleStats[BattleStat.SPDEF]).toBe(1); expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(1); - }, TIMEOUT + }, TIMEOUT ); test("Clangorous Soul will still take effect if one or more of the involved stats are not at max", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); //Here - BattleStat.SPD -> 0 and BattleStat.SPDEF -> 4 leadPokemon.summonData.battleStats[BattleStat.ATK] = 6; @@ -72,7 +72,7 @@ describe("Moves - CLANGOROUS_SOUL", () => { leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6; leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 4; - game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); + game.move.select(Moves.CLANGOROUS_SOUL); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); @@ -85,7 +85,7 @@ describe("Moves - CLANGOROUS_SOUL", () => { ); test("Clangorous Soul fails if all stats involved are at max", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -96,7 +96,7 @@ describe("Moves - CLANGOROUS_SOUL", () => { leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 6; leadPokemon.summonData.battleStats[BattleStat.SPD] = 6; - game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); + game.move.select(Moves.CLANGOROUS_SOUL); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); @@ -109,14 +109,14 @@ describe("Moves - CLANGOROUS_SOUL", () => { ); test("Clangorous Soul fails if the user's health is less than 1/3", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); leadPokemon.hp = hpLost - PREDAMAGE; - game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); + game.move.select(Moves.CLANGOROUS_SOUL); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); diff --git a/src/test/moves/crafty_shield.test.ts b/src/test/moves/crafty_shield.test.ts index c3e50bc52c2..a341a50b0b9 100644 --- a/src/test/moves/crafty_shield.test.ts +++ b/src/test/moves/crafty_shield.test.ts @@ -1,14 +1,13 @@ +import { BattleStat } from "#app/data/battle-stat"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import GameManager from "../utils/gameManager"; -import { Species } from "#enums/species"; -import { Abilities } from "#enums/abilities"; -import { Moves } from "#enums/moves"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; const TIMEOUT = 20 * 1000; @@ -48,11 +47,11 @@ describe("Moves - Crafty Shield", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); + game.move.select(Moves.CRAFTY_SHIELD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -69,11 +68,11 @@ describe("Moves - Crafty Shield", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); + game.move.select(Moves.CRAFTY_SHIELD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -91,11 +90,11 @@ describe("Moves - Crafty Shield", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); + game.move.select(Moves.CRAFTY_SHIELD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -110,11 +109,11 @@ describe("Moves - Crafty Shield", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); + game.move.select(Moves.CRAFTY_SHIELD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SWORDS_DANCE)); + game.move.select(Moves.SWORDS_DANCE, 1); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/double_team.test.ts b/src/test/moves/double_team.test.ts index 1c89d5b6350..c45c8bd8516 100644 --- a/src/test/moves/double_team.test.ts +++ b/src/test/moves/double_team.test.ts @@ -1,10 +1,9 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { Abilities } from "#app/enums/abilities"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -42,7 +41,7 @@ describe("Moves - Double Team", () => { vi.spyOn(enemy, "getAccuracyMultiplier"); expect(ally.summonData.battleStats[BattleStat.EVA]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.DOUBLE_TEAM)); + game.move.select(Moves.DOUBLE_TEAM); await game.phaseInterceptor.to(TurnEndPhase); await game.toNextTurn(); diff --git a/src/test/moves/dragon_rage.test.ts b/src/test/moves/dragon_rage.test.ts index 8a27f4006f4..223635575ab 100644 --- a/src/test/moves/dragon_rage.test.ts +++ b/src/test/moves/dragon_rage.test.ts @@ -1,17 +1,16 @@ import { BattleStat } from "#app/data/battle-stat"; import { Type } from "#app/data/type"; -import { Species } from "#app/enums/species.js"; +import { Species } from "#app/enums/species"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import { modifierTypes } from "#app/modifier/modifier-type"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Moves - Dragon Rage", () => { let phaserGame: Phaser.Game; @@ -62,7 +61,7 @@ describe("Moves - Dragon Rage", () => { game.override.disableCrits(); vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([Type.DRAGON]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; @@ -73,7 +72,7 @@ describe("Moves - Dragon Rage", () => { game.override.disableCrits(); vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([Type.STEEL]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; @@ -84,7 +83,7 @@ describe("Moves - Dragon Rage", () => { game.override.disableCrits(); partyPokemon.summonData.battleStats[BattleStat.SPATK] = 2; - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; @@ -95,7 +94,7 @@ describe("Moves - Dragon Rage", () => { game.override.disableCrits(); vi.spyOn(partyPokemon, "getTypes").mockReturnValue([Type.DRAGON]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; @@ -105,7 +104,7 @@ describe("Moves - Dragon Rage", () => { it("ignores criticals", async () => { partyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 99); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; @@ -116,7 +115,7 @@ describe("Moves - Dragon Rage", () => { game.override.disableCrits(); game.override.enemyAbility(Abilities.ICE_SCALES); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; @@ -127,7 +126,7 @@ describe("Moves - Dragon Rage", () => { game.override.disableCrits(); game.scene.addModifier(modifierTypes.MULTI_LENS().newModifier(partyPokemon), false); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); + game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; diff --git a/src/test/moves/dragon_tail.test.ts b/src/test/moves/dragon_tail.test.ts index 28c47a83454..362383e2fe3 100644 --- a/src/test/moves/dragon_tail.test.ts +++ b/src/test/moves/dragon_tail.test.ts @@ -1,16 +1,15 @@ -import { allMoves } from "#app/data/move.js"; -import { SPLASH_ONLY } from "../utils/testUtils"; +import { BattlerIndex } from "#app/battle"; +import { allMoves } from "#app/data/move"; +import { BattleEndPhase } from "#app/phases/battle-end-phase"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import GameManager from "../utils/gameManager"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattlerIndex } from "#app/battle.js"; -import { BattleEndPhase } from "#app/phases/battle-end-phase.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { SPLASH_ONLY } from "../utils/testUtils"; const TIMEOUT = 20 * 1000; @@ -46,9 +45,8 @@ describe("Moves - Dragon Tail", () => { await game.startBattle([Species.DRATINI]); const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); + game.move.select(Moves.DRAGON_TAIL); await game.phaseInterceptor.to(BerryPhase); @@ -68,12 +66,9 @@ describe("Moves - Dragon Tail", () => { await game.startBattle([Species.DRATINI]); const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).toBeDefined(); - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); + game.move.select(Moves.DRAGON_TAIL); await game.phaseInterceptor.to(BerryPhase); @@ -85,7 +80,7 @@ describe("Moves - Dragon Tail", () => { ); test( - "Double battles should proceed without crashing" , + "Double battles should proceed without crashing", async () => { game.override.battleType("double").enemyMoveset(SPLASH_ONLY); game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]) @@ -93,19 +88,12 @@ describe("Moves - Dragon Tail", () => { await game.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]); const leadPokemon = game.scene.getParty()[0]!; - const secPokemon = game.scene.getParty()[1]!; - expect(leadPokemon).toBeDefined(); - expect(secPokemon).toBeDefined(); - const enemyLeadPokemon = game.scene.currentBattle.enemyParty[0]!; - const enemySecPokemon = game.scene.currentBattle.enemyParty[1]!; - expect(enemyLeadPokemon).toBeDefined(); - expect(enemySecPokemon).toBeDefined(); + const enemyLeadPokemon = game.scene.getEnemyParty()[0]!; + const enemySecPokemon = game.scene.getEnemyParty()[1]!; - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); - game.doSelectTarget(BattlerIndex.ENEMY); - - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.DRAGON_TAIL, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); @@ -117,10 +105,8 @@ describe("Moves - Dragon Tail", () => { expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); // second turn - - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); - game.doSelectTarget(BattlerIndex.ENEMY_2); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FLAMETHROWER, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase); expect(enemySecPokemon.hp).toBeLessThan(enemySecPokemon.getMaxHp()); @@ -128,7 +114,7 @@ describe("Moves - Dragon Tail", () => { ); test( - "Flee move redirection works" , + "Flee move redirection works", async () => { game.override.battleType("double").enemyMoveset(SPLASH_ONLY); game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]); @@ -137,20 +123,13 @@ describe("Moves - Dragon Tail", () => { const leadPokemon = game.scene.getParty()[0]!; const secPokemon = game.scene.getParty()[1]!; - expect(leadPokemon).toBeDefined(); - expect(secPokemon).toBeDefined(); - const enemyLeadPokemon = game.scene.currentBattle.enemyParty[0]!; - const enemySecPokemon = game.scene.currentBattle.enemyParty[1]!; - expect(enemyLeadPokemon).toBeDefined(); - expect(enemySecPokemon).toBeDefined(); - - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); - game.doSelectTarget(BattlerIndex.ENEMY); + const enemyLeadPokemon = game.scene.getEnemyParty()[0]!; + const enemySecPokemon = game.scene.getEnemyParty()[1]!; + game.move.select(Moves.DRAGON_TAIL, 0, BattlerIndex.ENEMY); // target the same pokemon, second move should be redirected after first flees - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); - game.doSelectTarget(BattlerIndex.ENEMY); + game.move.select(Moves.DRAGON_TAIL, 1, BattlerIndex.ENEMY); await game.phaseInterceptor.to(BerryPhase); diff --git a/src/test/moves/dynamax_cannon.test.ts b/src/test/moves/dynamax_cannon.test.ts index 6fbc2ef47f3..6ac0befdb36 100644 --- a/src/test/moves/dynamax_cannon.test.ts +++ b/src/test/moves/dynamax_cannon.test.ts @@ -1,14 +1,12 @@ import { BattlerIndex } from "#app/battle"; import { allMoves } from "#app/data/move"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; describe("Moves - Dynamax Cannon", () => { let phaserGame: Phaser.Game; @@ -29,7 +27,7 @@ describe("Moves - Dynamax Cannon", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ dynamaxCannon.id ]); + game.override.moveset([dynamaxCannon.id]); game.override.startingLevel(200); // Note that, for Waves 1-10, the level cap is 10 @@ -38,18 +36,18 @@ describe("Moves - Dynamax Cannon", () => { game.override.disableCrits(); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); vi.spyOn(dynamaxCannon, "calculateBattlePower"); }); - it("should return 100 power against an enemy below level cap", async() => { + it("should return 100 power against an enemy below level cap", async () => { game.override.enemyLevel(1); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); @@ -57,13 +55,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); }, 20000); - it("should return 100 power against an enemy at level cap", async() => { + it("should return 100 power against an enemy at level cap", async () => { game.override.enemyLevel(10); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); @@ -71,13 +69,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); }, 20000); - it("should return 120 power against an enemy 1% above level cap", async() => { + it("should return 120 power against an enemy 1% above level cap", async () => { game.override.enemyLevel(101); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); const phase = game.scene.getCurrentPhase() as MoveEffectPhase; @@ -88,13 +86,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120); }, 20000); - it("should return 140 power against an enemy 2% above level capp", async() => { + it("should return 140 power against an enemy 2% above level capp", async () => { game.override.enemyLevel(102); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); const phase = game.scene.getCurrentPhase() as MoveEffectPhase; @@ -105,13 +103,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140); }, 20000); - it("should return 160 power against an enemy 3% above level cap", async() => { + it("should return 160 power against an enemy 3% above level cap", async () => { game.override.enemyLevel(103); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); const phase = game.scene.getCurrentPhase() as MoveEffectPhase; @@ -122,13 +120,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160); }, 20000); - it("should return 180 power against an enemy 4% above level cap", async() => { + it("should return 180 power against an enemy 4% above level cap", async () => { game.override.enemyLevel(104); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); const phase = game.scene.getCurrentPhase() as MoveEffectPhase; @@ -139,13 +137,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180); }, 20000); - it("should return 200 power against an enemy 5% above level cap", async() => { + it("should return 200 power against an enemy 5% above level cap", async () => { game.override.enemyLevel(105); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); + game.move.select(dynamaxCannon.id); await game.phaseInterceptor.to(MoveEffectPhase, false); const phase = game.scene.getCurrentPhase() as MoveEffectPhase; @@ -156,16 +154,13 @@ describe("Moves - Dynamax Cannon", () => { expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200); }, 20000); - it("should return 200 power against an enemy way above level cap", async() => { + it("should return 200 power against an enemy way above level cap", async () => { game.override.enemyLevel(999); await game.startBattle([ Species.ETERNATUS, ]); - game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); - - await game.phaseInterceptor.to(TurnStartPhase, false); - // Force user to act before enemy + game.move.select(dynamaxCannon.id); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); diff --git a/src/test/moves/fillet_away.test.ts b/src/test/moves/fillet_away.test.ts index fcad704ef29..b2ff9e25dba 100644 --- a/src/test/moves/fillet_away.test.ts +++ b/src/test/moves/fillet_away.test.ts @@ -1,12 +1,12 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { toDmgValue } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; -import { BattleStat } from "#app/data/battle-stat"; +import GameManager from "#test/utils/gameManager"; import { SPLASH_ONLY } from "#test/utils/testUtils"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; const TIMEOUT = 20 * 1000; /** HP Cost of Move */ @@ -41,13 +41,13 @@ describe("Moves - FILLET AWAY", () => { //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/fillet_away_(move) test("Fillet Away raises the user's Attack, Special Attack, and Speed by two stages each, at the cost of 1/2 of its maximum HP", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); + game.move.select(Moves.FILLET_AWAY); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); @@ -58,17 +58,17 @@ describe("Moves - FILLET AWAY", () => { ); test("Fillet Away will still take effect if one or more of the involved stats are not at max", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); //Here - BattleStat.SPD -> 0 and BattleStat.SPATK -> 3 leadPokemon.summonData.battleStats[BattleStat.ATK] = 6; leadPokemon.summonData.battleStats[BattleStat.SPATK] = 3; - game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); + game.move.select(Moves.FILLET_AWAY); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); @@ -79,7 +79,7 @@ describe("Moves - FILLET AWAY", () => { ); test("Fillet Away fails if all stats involved are at max", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -88,7 +88,7 @@ describe("Moves - FILLET AWAY", () => { leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6; leadPokemon.summonData.battleStats[BattleStat.SPD] = 6; - game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); + game.move.select(Moves.FILLET_AWAY); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); @@ -99,14 +99,14 @@ describe("Moves - FILLET AWAY", () => { ); test("Fillet Away fails if the user's health is less than 1/2", - async() => { + async () => { await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); leadPokemon.hp = hpLost - PREDAMAGE; - game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); + game.move.select(Moves.FILLET_AWAY); await game.phaseInterceptor.to(TurnEndPhase); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); diff --git a/src/test/moves/fissure.test.ts b/src/test/moves/fissure.test.ts index 65d692a5cc1..51122b269b8 100644 --- a/src/test/moves/fissure.test.ts +++ b/src/test/moves/fissure.test.ts @@ -1,15 +1,14 @@ import { BattleStat } from "#app/data/battle-stat"; -import { Species } from "#app/enums/species.js"; +import { Species } from "#app/enums/species"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - Fissure", () => { let phaserGame: Phaser.Game; @@ -57,7 +56,7 @@ describe("Moves - Fissure", () => { game.override.ability(Abilities.NO_GUARD); game.override.enemyAbility(Abilities.FUR_COAT); - game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); + game.move.select(Moves.FISSURE); await game.phaseInterceptor.to(DamagePhase, true); expect(enemyPokemon.isFainted()).toBe(true); @@ -68,7 +67,7 @@ describe("Moves - Fissure", () => { enemyPokemon.summonData.battleStats[BattleStat.ACC] = -6; - game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); + game.move.select(Moves.FISSURE); // wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage await game.phaseInterceptor.to(TurnEndPhase); @@ -81,7 +80,7 @@ describe("Moves - Fissure", () => { enemyPokemon.summonData.battleStats[BattleStat.EVA] = 6; - game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); + game.move.select(Moves.FISSURE); // wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/moves/flame_burst.test.ts b/src/test/moves/flame_burst.test.ts index d6679f921df..2777b8178b8 100644 --- a/src/test/moves/flame_burst.test.ts +++ b/src/test/moves/flame_burst.test.ts @@ -1,14 +1,12 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; +import { allAbilities } from "#app/data/ability"; +import { Abilities } from "#app/enums/abilities"; +import Pokemon from "#app/field/pokemon"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Abilities } from "#app/enums/abilities.js"; -import { allAbilities } from "#app/data/ability.js"; -import Pokemon from "#app/field/pokemon.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; describe("Moves - Flame Burst", () => { let phaserGame: Phaser.Game; @@ -22,7 +20,7 @@ describe("Moves - Flame Burst", () => { * @returns Effect damage of Flame Burst */ const getEffectDamage = (pokemon: Pokemon): number => { - return Math.max(1, Math.floor(pokemon.getMaxHp() * 1/16)); + return Math.max(1, Math.floor(pokemon.getMaxHp() * 1 / 16)); }; beforeAll(() => { @@ -49,12 +47,10 @@ describe("Moves - Flame Burst", () => { it("inflicts damage to the target's ally equal to 1/16 of its max HP", async () => { await game.startBattle([Species.PIKACHU, Species.PIKACHU]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(leftEnemy.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp()); @@ -65,12 +61,10 @@ describe("Moves - Flame Burst", () => { game.override.enemyAbility(Abilities.FLASH_FIRE); await game.startBattle([Species.PIKACHU, Species.PIKACHU]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(leftEnemy.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); expect(leftEnemy.hp).toBe(leftEnemy.getMaxHp()); @@ -79,14 +73,12 @@ describe("Moves - Flame Burst", () => { it("does not interact with the target ally's abilities", async () => { await game.startBattle([Species.PIKACHU, Species.PIKACHU]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); vi.spyOn(rightEnemy, "getAbility").mockReturnValue(allAbilities[Abilities.FLASH_FIRE]); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(leftEnemy.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp()); @@ -95,14 +87,12 @@ describe("Moves - Flame Burst", () => { it("effect damage is prevented by Magic Guard", async () => { await game.startBattle([Species.PIKACHU, Species.PIKACHU]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); vi.spyOn(rightEnemy, "getAbility").mockReturnValue(allAbilities[Abilities.MAGIC_GUARD]); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(leftEnemy.getBattlerIndex()); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp()); diff --git a/src/test/moves/flower_shield.test.ts b/src/test/moves/flower_shield.test.ts index 9001e8ceacb..b3e50219aec 100644 --- a/src/test/moves/flower_shield.test.ts +++ b/src/test/moves/flower_shield.test.ts @@ -1,16 +1,15 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { SemiInvulnerableTag } from "#app/data/battler-tags.js"; -import { Type } from "#app/data/type.js"; -import { Biome } from "#app/enums/biome.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { SemiInvulnerableTag } from "#app/data/battler-tags"; +import { Type } from "#app/data/type"; +import { Biome } from "#app/enums/biome"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Moves - Flower Shield", () => { let phaserGame: Phaser.Game; @@ -45,7 +44,7 @@ describe("Moves - Flower Shield", () => { expect(magikarp.summonData.battleStats[BattleStat.DEF]).toBe(0); expect(cherrim.summonData.battleStats[BattleStat.DEF]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLOWER_SHIELD)); + game.move.select(Moves.FLOWER_SHIELD); await game.phaseInterceptor.to(TurnEndPhase); expect(magikarp.summonData.battleStats[BattleStat.DEF]).toBe(0); @@ -64,8 +63,8 @@ describe("Moves - Flower Shield", () => { grassPokemons.forEach(p => expect(p.summonData.battleStats[BattleStat.DEF]).toBe(0)); nonGrassPokemons.forEach(p => expect(p.summonData.battleStats[BattleStat.DEF]).toBe(0)); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLOWER_SHIELD)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FLOWER_SHIELD); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); grassPokemons.forEach(p => expect(p.summonData.battleStats[BattleStat.DEF]).toBe(1)); @@ -88,7 +87,7 @@ describe("Moves - Flower Shield", () => { expect(cherrim.summonData.battleStats[BattleStat.DEF]).toBe(0); expect(paras.getTag(SemiInvulnerableTag)).toBeUndefined; - game.doAttack(getMovePosition(game.scene, 0, Moves.FLOWER_SHIELD)); + game.move.select(Moves.FLOWER_SHIELD); await game.phaseInterceptor.to(TurnEndPhase); expect(paras.getTag(SemiInvulnerableTag)).toBeDefined(); @@ -106,7 +105,7 @@ describe("Moves - Flower Shield", () => { expect(enemy.summonData.battleStats[BattleStat.DEF]).toBe(0); expect(ally.summonData.battleStats[BattleStat.DEF]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.FLOWER_SHIELD)); + game.move.select(Moves.FLOWER_SHIELD); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.summonData.battleStats[BattleStat.DEF]).toBe(0); diff --git a/src/test/moves/focus_punch.test.ts b/src/test/moves/focus_punch.test.ts index 385234f0b71..99399623a1c 100644 --- a/src/test/moves/focus_punch.test.ts +++ b/src/test/moves/focus_punch.test.ts @@ -1,16 +1,15 @@ -import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import { MoveHeaderPhase } from "#app/phases/move-header-phase"; +import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; +import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; -import { MoveHeaderPhase } from "#app/phases/move-header-phase.js"; -import { SwitchSummonPhase } from "#app/phases/switch-summon-phase.js"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; const TIMEOUT = 20 * 1000; @@ -51,7 +50,7 @@ describe("Moves - Focus Punch", () => { const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.FOCUS_PUNCH)); + game.move.select(Moves.FOCUS_PUNCH); await game.phaseInterceptor.to(MessagePhase); @@ -78,7 +77,7 @@ describe("Moves - Focus Punch", () => { const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.FOCUS_PUNCH)); + game.move.select(Moves.FOCUS_PUNCH); await game.phaseInterceptor.to(MessagePhase); @@ -103,7 +102,7 @@ describe("Moves - Focus Punch", () => { const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.FOCUS_PUNCH)); + game.move.select(Moves.FOCUS_PUNCH); await game.phaseInterceptor.to(MessagePhase); // Header message @@ -125,7 +124,7 @@ describe("Moves - Focus Punch", () => { await game.startBattle([Species.CHARIZARD]); game.forceOpponentToSwitch(); - game.doAttack(getMovePosition(game.scene, 0, Moves.FOCUS_PUNCH)); + game.move.select(Moves.FOCUS_PUNCH); await game.phaseInterceptor.to(TurnStartPhase); diff --git a/src/test/moves/follow_me.test.ts b/src/test/moves/follow_me.test.ts index a0fff9afbf8..d7ef199df3e 100644 --- a/src/test/moves/follow_me.test.ts +++ b/src/test/moves/follow_me.test.ts @@ -1,15 +1,12 @@ -import { BattlerIndex } from "#app/battle.js"; +import { BattlerIndex } from "#app/battle"; import { Stat } from "#app/data/pokemon-stat"; -import { Abilities } from "#app/enums/abilities.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { Abilities } from "#app/enums/abilities"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -34,32 +31,21 @@ describe("Moves - Follow Me", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.moveset([Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); test( "move should redirect enemy attacks to the user", async () => { - await game.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + await game.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); - - const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const playerStartingHp = playerPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME)); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - - game.doSelectTarget(BattlerIndex.ENEMY); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY); await game.phaseInterceptor.to(TurnEndPhase, false); expect(playerPokemon[0].hp).toBeLessThan(playerStartingHp[0]); @@ -70,22 +56,14 @@ describe("Moves - Follow Me", () => { test( "move should redirect enemy attacks to the first ally that uses it", async () => { - await game.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + await game.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); - - const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const playerStartingHp = playerPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME)); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.FOLLOW_ME)); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.FOLLOW_ME, 1); await game.phaseInterceptor.to(TurnEndPhase, false); playerPokemon.sort((a, b) => a.getBattleStat(Stat.SPD) - b.getBattleStat(Stat.SPD)); @@ -99,29 +77,17 @@ describe("Moves - Follow Me", () => { "move effect should be bypassed by Stalwart", async () => { game.override.ability(Abilities.STALWART); - game.override.moveset([ Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([ Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME ]); + game.override.moveset([Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME]); - await game.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); - - const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); + await game.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY_2); + game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged @@ -133,29 +99,17 @@ describe("Moves - Follow Me", () => { test( "move effect should be bypassed by Snipe Shot", async () => { - game.override.moveset([ Moves.SNIPE_SHOT ]); - game.override.enemyMoveset([ Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME ]); + game.override.moveset([Moves.SNIPE_SHOT]); + game.override.enemyMoveset([Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME]); - await game.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); - - const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); + await game.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.SNIPE_SHOT)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.SNIPE_SHOT)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY_2); + game.move.select(Moves.SNIPE_SHOT, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SNIPE_SHOT, 1, BattlerIndex.ENEMY_2); await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged diff --git a/src/test/moves/foresight.test.ts b/src/test/moves/foresight.test.ts index 91d3e3c37e0..b856ec0f852 100644 --- a/src/test/moves/foresight.test.ts +++ b/src/test/moves/foresight.test.ts @@ -1,11 +1,10 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/utils/gameManager"; -import { Species } from "#app/enums/species.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { Moves } from "#app/enums/moves.js"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; describe("Moves - Foresight", () => { let phaserGame: Phaser.Game; @@ -37,19 +36,19 @@ describe("Moves - Foresight", () => { const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); + game.move.select(Moves.QUICK_ATTACK); await game.toNextTurn(); expect(enemy.hp).toBe(enemy.getMaxHp()); - game.doAttack(getMovePosition(game.scene, 0, Moves.FORESIGHT)); + game.move.select(Moves.FORESIGHT); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); + game.move.select(Moves.QUICK_ATTACK); await game.toNextTurn(); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); enemy.hp = enemy.getMaxHp(); - game.doAttack(getMovePosition(game.scene, 0, Moves.MACH_PUNCH)); + game.move.select(Moves.MACH_PUNCH); await game.phaseInterceptor.to(MoveEffectPhase); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); @@ -62,9 +61,9 @@ describe("Moves - Foresight", () => { const pokemon = game.scene.getPlayerPokemon()!; vi.spyOn(pokemon, "getAccuracyMultiplier"); - game.doAttack(getMovePosition(game.scene, 0, Moves.FORESIGHT)); + game.move.select(Moves.FORESIGHT); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); + game.move.select(Moves.QUICK_ATTACK); await game.phaseInterceptor.to(MoveEffectPhase); expect(pokemon.getAccuracyMultiplier).toHaveReturnedWith(1); diff --git a/src/test/moves/freezy_frost.test.ts b/src/test/moves/freezy_frost.test.ts index b4c30279c21..00d7104d373 100644 --- a/src/test/moves/freezy_frost.test.ts +++ b/src/test/moves/freezy_frost.test.ts @@ -1,15 +1,14 @@ import { BattleStat } from "#app/data/battle-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { allMoves } from "#app/data/move.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Freezy Frost", () => { describe("integration tests", () => { @@ -47,17 +46,17 @@ describe("Moves - Freezy Frost", () => { expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(enemy.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE)); + game.move.select(Moves.SWORDS_DANCE); await game.phaseInterceptor.to(TurnInitPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); + game.move.select(Moves.CHARM); await game.phaseInterceptor.to(TurnInitPhase); const userAtkBefore = user.summonData.battleStats[BattleStat.ATK]; const enemyAtkBefore = enemy.summonData.battleStats[BattleStat.ATK]; expect(userAtkBefore).toBe(2); expect(enemyAtkBefore).toBe(-2); - game.doAttack(getMovePosition(game.scene, 0, Moves.FREEZY_FROST)); + game.move.select(Moves.FREEZY_FROST); await game.phaseInterceptor.to(TurnInitPhase); expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(enemy.summonData.battleStats[BattleStat.ATK]).toBe(0); @@ -69,13 +68,13 @@ describe("Moves - Freezy Frost", () => { const user = game.scene.getPlayerPokemon()!; expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE)); + game.move.select(Moves.SWORDS_DANCE); await game.phaseInterceptor.to(TurnInitPhase); const userAtkBefore = user.summonData.battleStats[BattleStat.ATK]; expect(userAtkBefore).toBe(2); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(MoveEndPhase); expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); }); diff --git a/src/test/moves/fusion_bolt.test.ts b/src/test/moves/fusion_bolt.test.ts index c7a21e2c736..db31863ad03 100644 --- a/src/test/moves/fusion_bolt.test.ts +++ b/src/test/moves/fusion_bolt.test.ts @@ -1,10 +1,9 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Species } from "#enums/species"; -import { Moves } from "#enums/moves"; import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Moves - Fusion Bolt", () => { let phaserGame: Phaser.Game; @@ -24,19 +23,19 @@ describe("Moves - Fusion Bolt", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ fusionBolt ]); + game.override.moveset([fusionBolt]); game.override.startingLevel(1); game.override.enemySpecies(Species.RESHIRAM); game.override.enemyAbility(Abilities.ROUGH_SKIN); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); game.override.battleType("single"); game.override.startingWave(97); game.override.disableCrits(); }); - it("should not make contact", async() => { + it("should not make contact", async () => { await game.startBattle([ Species.ZEKROM, ]); @@ -44,7 +43,7 @@ describe("Moves - Fusion Bolt", () => { const partyMember = game.scene.getPlayerPokemon()!; const initialHp = partyMember.hp; - game.doAttack(getMovePosition(game.scene, 0, fusionBolt)); + game.move.select(fusionBolt); await game.toNextTurn(); diff --git a/src/test/moves/fusion_flare.test.ts b/src/test/moves/fusion_flare.test.ts index aa38357ddd3..471f6a2ac7b 100644 --- a/src/test/moves/fusion_flare.test.ts +++ b/src/test/moves/fusion_flare.test.ts @@ -1,11 +1,10 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { StatusEffect } from "#app/data/status-effect"; -import { Species } from "#enums/species"; +import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { Moves } from "#enums/moves"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Moves - Fusion Flare", () => { let phaserGame: Phaser.Game; @@ -25,25 +24,25 @@ describe("Moves - Fusion Flare", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ fusionFlare ]); + game.override.moveset([fusionFlare]); game.override.startingLevel(1); game.override.enemySpecies(Species.RESHIRAM); - game.override.enemyMoveset([ Moves.REST, Moves.REST, Moves.REST, Moves.REST ]); + game.override.enemyMoveset([Moves.REST, Moves.REST, Moves.REST, Moves.REST]); game.override.battleType("single"); game.override.startingWave(97); game.override.disableCrits(); }); - it("should thaw freeze status condition", async() => { + it("should thaw freeze status condition", async () => { await game.startBattle([ Species.RESHIRAM, ]); const partyMember = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, fusionFlare)); + game.move.select(fusionFlare); await game.phaseInterceptor.to(TurnStartPhase, false); diff --git a/src/test/moves/fusion_flare_bolt.test.ts b/src/test/moves/fusion_flare_bolt.test.ts index 1b95062ee81..ebef5148778 100644 --- a/src/test/moves/fusion_flare_bolt.test.ts +++ b/src/test/moves/fusion_flare_bolt.test.ts @@ -1,16 +1,15 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Stat } from "#app/data/pokemon-stat"; -import { allMoves } from "#app/data/move"; import { BattlerIndex } from "#app/battle"; -import { Species } from "#enums/species"; +import { allMoves } from "#app/data/move"; +import { Stat } from "#app/data/pokemon-stat"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { MovePhase } from "#app/phases/move-phase"; import { Moves } from "#enums/moves"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { MovePhase } from "#app/phases/move-phase.js"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; describe("Moves - Fusion Flare and Fusion Bolt", () => { let phaserGame: Phaser.Game; @@ -31,11 +30,11 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ fusionFlare.id, fusionBolt.id ]); + game.override.moveset([fusionFlare.id, fusionBolt.id]); game.override.startingLevel(1); game.override.enemySpecies(Species.RESHIRAM); - game.override.enemyMoveset([ Moves.REST, Moves.REST, Moves.REST, Moves.REST ]); + game.override.enemyMoveset([Moves.REST, Moves.REST, Moves.REST, Moves.REST]); game.override.battleType("double"); game.override.startingWave(97); @@ -45,20 +44,17 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { vi.spyOn(fusionBolt, "calculateBattlePower"); }); - it("FUSION_FLARE should double power of subsequent FUSION_BOLT", async() => { + it("FUSION_FLARE should double power of subsequent FUSION_BOLT", async () => { await game.startBattle([ Species.ZEKROM, Species.ZEKROM ]); - game.doAttack(getMovePosition(game.scene, 0, fusionFlare.id)); - game.doSelectTarget(BattlerIndex.ENEMY); - - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.ENEMY); + game.move.select(fusionFlare.id, 0, BattlerIndex.ENEMY); + game.move.select(fusionBolt.id, 1, BattlerIndex.ENEMY); // Force user party to act before enemy party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); @@ -71,20 +67,17 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); }, 20000); - it("FUSION_BOLT should double power of subsequent FUSION_FLARE", async() => { + it("FUSION_BOLT should double power of subsequent FUSION_FLARE", async () => { await game.startBattle([ Species.ZEKROM, Species.ZEKROM ]); - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.ENEMY); - - game.doAttack(getMovePosition(game.scene, 0, fusionFlare.id)); - game.doSelectTarget(BattlerIndex.ENEMY); + game.move.select(fusionBolt.id, 0, BattlerIndex.ENEMY); + game.move.select(fusionFlare.id, 1, BattlerIndex.ENEMY); // Force user party to act before enemy party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); @@ -97,20 +90,17 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }, 20000); - it("FUSION_FLARE should double power of subsequent FUSION_BOLT if a move failed in between", async() => { + it("FUSION_FLARE should double power of subsequent FUSION_BOLT if a move failed in between", async () => { await game.startBattle([ Species.ZEKROM, Species.ZEKROM ]); - game.doAttack(getMovePosition(game.scene, 0, fusionFlare.id)); - game.doSelectTarget(0); - - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(0); + game.move.select(fusionFlare.id, 0, BattlerIndex.PLAYER); + game.move.select(fusionBolt.id, 1, BattlerIndex.PLAYER); // Force first enemy to act (and fail) in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); @@ -128,21 +118,18 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); }, 20000); - it("FUSION_FLARE should not double power of subsequent FUSION_BOLT if a move succeeded in between", async() => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + it("FUSION_FLARE should not double power of subsequent FUSION_BOLT if a move succeeded in between", async () => { + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); await game.startBattle([ Species.ZEKROM, Species.ZEKROM ]); - game.doAttack(getMovePosition(game.scene, 0, fusionFlare.id)); - game.doSelectTarget(BattlerIndex.ENEMY); - - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.ENEMY); + game.move.select(fusionFlare.id, 0, BattlerIndex.ENEMY); + game.move.select(fusionBolt.id, 1, BattlerIndex.ENEMY); // Force first enemy to act in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); @@ -159,20 +146,17 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); }, 20000); - it("FUSION_FLARE should double power of subsequent FUSION_BOLT if moves are aimed at allies", async() => { + it("FUSION_FLARE should double power of subsequent FUSION_BOLT if moves are aimed at allies", async () => { await game.startBattle([ Species.ZEKROM, Species.RESHIRAM ]); - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.PLAYER_2); - - game.doAttack(getMovePosition(game.scene, 0, fusionFlare.id)); - game.doSelectTarget(BattlerIndex.PLAYER); + game.move.select(fusionBolt.id, 0, BattlerIndex.PLAYER_2); + game.move.select(fusionFlare.id, 1, BattlerIndex.PLAYER); // Force user party to act before enemy party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); @@ -185,8 +169,8 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }, 20000); - it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves", async() => { - game.override.enemyMoveset([ fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id ]); + it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves", async () => { + game.override.enemyMoveset([fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id]); await game.startBattle([ Species.ZEKROM, Species.ZEKROM @@ -217,14 +201,11 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[0].map((val, i) => (i === Stat.SPDEF ? 250 : val))); vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[1].map((val, i) => (i === Stat.SPDEF ? 250 : val))); - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.ENEMY); - - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.ENEMY); + game.move.select(fusionBolt.id, 0, BattlerIndex.ENEMY); + game.move.select(fusionBolt.id, 1, BattlerIndex.ENEMY); // Force first enemy to act in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); @@ -247,8 +228,8 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }, 20000); - it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves if moves are aimed at allies", async() => { - game.override.enemyMoveset([ fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id ]); + it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves if moves are aimed at allies", async () => { + game.override.enemyMoveset([fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id]); await game.startBattle([ Species.ZEKROM, Species.ZEKROM @@ -279,14 +260,11 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[0].map((val, i) => (i === Stat.SPDEF ? 250 : val))); vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[1].map((val, i) => (i === Stat.SPDEF ? 250 : val))); - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.PLAYER_2); - - game.doAttack(getMovePosition(game.scene, 0, fusionBolt.id)); - game.doSelectTarget(BattlerIndex.PLAYER); + game.move.select(fusionBolt.id, 0, BattlerIndex.PLAYER_2); + game.move.select(fusionBolt.id, 1, BattlerIndex.PLAYER); // Force first enemy to act in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); diff --git a/src/test/moves/gastro_acid.test.ts b/src/test/moves/gastro_acid.test.ts index cc247890754..67fd3464cf9 100644 --- a/src/test/moves/gastro_acid.test.ts +++ b/src/test/moves/gastro_acid.test.ts @@ -1,12 +1,11 @@ -import { BattlerIndex } from "#app/battle.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; -import { MoveResult } from "#app/field/pokemon.js"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { BattlerIndex } from "#app/battle"; +import { Abilities } from "#app/enums/abilities"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { MoveResult } from "#app/field/pokemon"; import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; const TIMEOUT = 20 * 1000; @@ -46,10 +45,8 @@ describe("Moves - Gastro Acid", () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.GASTRO_ACID)); - game.doSelectTarget(BattlerIndex.ENEMY); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doSelectTarget(BattlerIndex.PLAYER_2); + game.move.select(Moves.GASTRO_ACID, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to("TurnInitPhase"); @@ -57,10 +54,8 @@ describe("Moves - Gastro Acid", () => { expect(enemyField[0].summonData.abilitySuppressed).toBe(true); expect(enemyField[1].summonData.abilitySuppressed).toBe(false); - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); - game.doSelectTarget(BattlerIndex.ENEMY); - game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); - game.doSelectTarget(BattlerIndex.ENEMY_2); + game.move.select(Moves.WATER_GUN, 0, BattlerIndex.ENEMY); + game.move.select(Moves.WATER_GUN, 1, BattlerIndex.ENEMY_2); await game.phaseInterceptor.to("TurnEndPhase"); @@ -73,13 +68,13 @@ describe("Moves - Gastro Acid", () => { await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CORE_ENFORCER)); + game.move.select(Moves.CORE_ENFORCER); // Force player to be slower to enable Core Enforcer to proc its suppression effect await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnInitPhase"); - game.doAttack(getMovePosition(game.scene, 0, Moves.GASTRO_ACID)); + game.move.select(Moves.GASTRO_ACID); await game.phaseInterceptor.to("TurnInitPhase"); diff --git a/src/test/moves/glaive_rush.test.ts b/src/test/moves/glaive_rush.test.ts index f97ba1f0367..1eac3c32bb4 100644 --- a/src/test/moves/glaive_rush.test.ts +++ b/src/test/moves/glaive_rush.test.ts @@ -1,13 +1,12 @@ -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - Glaive Rush", () => { @@ -37,36 +36,36 @@ describe("Moves - Glaive Rush", () => { game.override.moveset([Moves.SHADOW_SNEAK, Moves.AVALANCHE, Moves.SPLASH, Moves.GLAIVE_RUSH]); }); - it("takes double damage from attacks", async() => { + it("takes double damage from attacks", async () => { await game.startBattle(); const enemy = game.scene.getEnemyPokemon()!; enemy.hp = 1000; vi.spyOn(game.scene, "randBattleSeedInt").mockReturnValue(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to(DamagePhase); const damageDealt = 1000 - enemy.hp; await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to(DamagePhase); expect(enemy.hp).toBeLessThanOrEqual(1001 - (damageDealt * 3)); }, 5000); // TODO: revert back to 20s - it("always gets hit by attacks", async() => { + it("always gets hit by attacks", async () => { await game.startBattle(); const enemy = game.scene.getEnemyPokemon()!; enemy.hp = 1000; allMoves[Moves.AVALANCHE].accuracy = 0; - game.doAttack(getMovePosition(game.scene, 0, Moves.AVALANCHE)); + game.move.select(Moves.AVALANCHE); await game.phaseInterceptor.to(TurnEndPhase); expect(enemy.hp).toBeLessThan(1000); }, 20000); - it("interacts properly with multi-lens", async() => { - game.override.startingHeldItems([{name: "MULTI_LENS", count: 2}]); + it("interacts properly with multi-lens", async () => { + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]); game.override.enemyMoveset(Array(4).fill(Moves.AVALANCHE)); await game.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -75,17 +74,17 @@ describe("Moves - Glaive Rush", () => { player.hp = 1000; allMoves[Moves.AVALANCHE].accuracy = 0; - game.doAttack(getMovePosition(game.scene, 0, Moves.GLAIVE_RUSH)); + game.move.select(Moves.GLAIVE_RUSH); await game.phaseInterceptor.to(TurnEndPhase); expect(player.hp).toBeLessThan(1000); player.hp = 1000; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(player.hp).toBe(1000); }, 20000); - it("secondary effects only last until next move", async() => { + it("secondary effects only last until next move", async () => { game.override.enemyMoveset(Array(4).fill(Moves.SHADOW_SNEAK)); await game.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -94,22 +93,22 @@ describe("Moves - Glaive Rush", () => { player.hp = 1000; allMoves[Moves.SHADOW_SNEAK].accuracy = 0; - game.doAttack(getMovePosition(game.scene, 0, Moves.GLAIVE_RUSH)); + game.move.select(Moves.GLAIVE_RUSH); await game.phaseInterceptor.to(TurnEndPhase); expect(player.hp).toBe(1000); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); const damagedHp = player.hp; expect(player.hp).toBeLessThan(1000); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); expect(player.hp).toBe(damagedHp); }, 20000); - it("secondary effects are removed upon switching", async() => { + it("secondary effects are removed upon switching", async () => { game.override.enemyMoveset(Array(4).fill(Moves.SHADOW_SNEAK)); game.override.starterSpecies(0); await game.startBattle([Species.KLINK, Species.FEEBAS]); @@ -118,7 +117,7 @@ describe("Moves - Glaive Rush", () => { enemy.hp = 1000; allMoves[Moves.SHADOW_SNEAK].accuracy = 0; - game.doAttack(getMovePosition(game.scene, 0, Moves.GLAIVE_RUSH)); + game.move.select(Moves.GLAIVE_RUSH); await game.phaseInterceptor.to(TurnEndPhase); expect(player.hp).toBe(player.getMaxHp()); @@ -130,7 +129,7 @@ describe("Moves - Glaive Rush", () => { }, 20000); - it("secondary effects don't activate if move fails", async() => { + it("secondary effects don't activate if move fails", async () => { game.override.moveset([Moves.SHADOW_SNEAK, Moves.PROTECT, Moves.SPLASH, Moves.GLAIVE_RUSH]); await game.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -138,16 +137,16 @@ describe("Moves - Glaive Rush", () => { enemy.hp = 1000; player.hp = 1000; - game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); + game.move.select(Moves.PROTECT); await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to(TurnEndPhase); game.override.enemyMoveset(Array(4).fill(Moves.SPLASH)); const damagedHP1 = 1000 - enemy.hp; enemy.hp = 1000; - game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to(TurnEndPhase); const damagedHP2 = 1000 - enemy.hp; diff --git a/src/test/moves/growth.test.ts b/src/test/moves/growth.test.ts index 0c60bb723f4..dfbf5406351 100644 --- a/src/test/moves/growth.test.ts +++ b/src/test/moves/growth.test.ts @@ -1,17 +1,13 @@ import { BattleStat } from "#app/data/battle-stat"; import { Stat } from "#app/data/pokemon-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Growth", () => { @@ -37,10 +33,10 @@ describe("Moves - Growth", () => { game.override.ability(Abilities.INSOMNIA); game.override.startingLevel(2000); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("GROWTH", async() => { + it("GROWTH", async () => { const moveToUse = Moves.GROWTH; await game.startBattle([ Species.MIGHTYENA, @@ -52,13 +48,7 @@ describe("Moves - Growth", () => { const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; expect(battleStatsOpponent[BattleStat.SPATK]).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.SPATK]).toBe(1); diff --git a/src/test/moves/hard_press.test.ts b/src/test/moves/hard_press.test.ts index 255b9f1f4b1..70c78490269 100644 --- a/src/test/moves/hard_press.test.ts +++ b/src/test/moves/hard_press.test.ts @@ -1,13 +1,12 @@ -import { allMoves } from "#app/data/move.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Moves - Hard Press", () => { let phaserGame: Phaser.Game; @@ -39,7 +38,7 @@ describe("Moves - Hard Press", () => { it("should return 100 power if target HP ratio is at 100%", async () => { await game.startBattle([Species.PIKACHU]); - game.doAttack(getMovePosition(game.scene, 0, Moves.HARD_PRESS)); + game.move.select(Moves.HARD_PRESS); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(100); @@ -52,7 +51,7 @@ describe("Moves - Hard Press", () => { vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); - game.doAttack(getMovePosition(game.scene, 0, Moves.HARD_PRESS)); + game.move.select(Moves.HARD_PRESS); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(50); @@ -65,7 +64,7 @@ describe("Moves - Hard Press", () => { vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); - game.doAttack(getMovePosition(game.scene, 0, Moves.HARD_PRESS)); + game.move.select(Moves.HARD_PRESS); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(1); @@ -78,7 +77,7 @@ describe("Moves - Hard Press", () => { vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); - game.doAttack(getMovePosition(game.scene, 0, Moves.HARD_PRESS)); + game.move.select(Moves.HARD_PRESS); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(1); diff --git a/src/test/moves/haze.test.ts b/src/test/moves/haze.test.ts index d5e3efcbd9d..8a32a40cb32 100644 --- a/src/test/moves/haze.test.ts +++ b/src/test/moves/haze.test.ts @@ -1,14 +1,13 @@ import { BattleStat } from "#app/data/battle-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Haze", () => { describe("integration tests", () => { @@ -45,17 +44,17 @@ describe("Moves - Haze", () => { expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(enemy.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE)); + game.move.select(Moves.SWORDS_DANCE); await game.phaseInterceptor.to(TurnInitPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); + game.move.select(Moves.CHARM); await game.phaseInterceptor.to(TurnInitPhase); const userAtkBefore = user.summonData.battleStats[BattleStat.ATK]; const enemyAtkBefore = enemy.summonData.battleStats[BattleStat.ATK]; expect(userAtkBefore).toBe(2); expect(enemyAtkBefore).toBe(-2); - game.doAttack(getMovePosition(game.scene, 0, Moves.HAZE)); + game.move.select(Moves.HAZE); await game.phaseInterceptor.to(TurnInitPhase); expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(enemy.summonData.battleStats[BattleStat.ATK]).toBe(0); @@ -67,13 +66,13 @@ describe("Moves - Haze", () => { const user = game.scene.getPlayerPokemon()!; expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE)); + game.move.select(Moves.SWORDS_DANCE); await game.phaseInterceptor.to(TurnInitPhase); const userAtkBefore = user.summonData.battleStats[BattleStat.ATK]; expect(userAtkBefore).toBe(2); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(MoveEndPhase); expect(user.summonData.battleStats[BattleStat.ATK]).toBe(0); }); diff --git a/src/test/moves/hyper_beam.test.ts b/src/test/moves/hyper_beam.test.ts index ac8075081fb..1280d8b429a 100644 --- a/src/test/moves/hyper_beam.test.ts +++ b/src/test/moves/hyper_beam.test.ts @@ -1,14 +1,13 @@ -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; // 20 sec timeout for all tests @@ -48,7 +47,7 @@ describe("Moves - Hyper Beam", () => { const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.HYPER_BEAM)); + game.move.select(Moves.HYPER_BEAM); await game.phaseInterceptor.to(TurnEndPhase); @@ -63,7 +62,7 @@ describe("Moves - Hyper Beam", () => { expect(enemyPokemon.hp).toBe(enemyPostAttackHp); expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); + game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/jaw_lock.test.ts b/src/test/moves/jaw_lock.test.ts new file mode 100644 index 00000000000..42f7a244977 --- /dev/null +++ b/src/test/moves/jaw_lock.test.ts @@ -0,0 +1,171 @@ +import { BattlerIndex } from "#app/battle"; +import { Abilities } from "#app/enums/abilities"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { FaintPhase } from "#app/phases/faint-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import GameManager from "#app/test/utils/gameManager"; +import { SPLASH_ONLY } from "#app/test/utils/testUtils"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +const TIMEOUT = 20 * 1000; + +describe("Moves - Jaw Lock", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + + game.override + .battleType("single") + .enemySpecies(Species.SNORLAX) + .enemyAbility(Abilities.INSOMNIA) + .enemyMoveset(SPLASH_ONLY) + .moveset([Moves.JAW_LOCK, Moves.SPLASH]) + .startingLevel(100) + .enemyLevel(100) + .disableCrits(); + }); + + it( + "should trap the move's user and target", + async () => { + await game.startBattle([Species.BULBASAUR]); + + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.JAW_LOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + + await game.phaseInterceptor.to(MoveEffectPhase, false); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + + await game.phaseInterceptor.to(TurnEndPhase); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + }, TIMEOUT + ); + + it( + "should not trap either pokemon if the target faints", + async () => { + game.override.enemyLevel(1); + await game.startBattle([Species.BULBASAUR]); + + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.JAW_LOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + + await game.phaseInterceptor.to(MoveEffectPhase, false); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + + await game.phaseInterceptor.to(MoveEffectPhase); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + + await game.phaseInterceptor.to(FaintPhase); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + }, TIMEOUT + ); + + it( + "should only trap the user until the target faints", + async () => { + await game.startBattle([Species.BULBASAUR]); + + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.JAW_LOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + + await game.phaseInterceptor.to(MoveEffectPhase); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + + await game.phaseInterceptor.to(TurnEndPhase); + + await game.doKillOpponents(); + + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + }, TIMEOUT + ); + + it( + "should not trap other targets after the first target is trapped", + async () => { + game.override.battleType("double"); + + await game.startBattle([Species.CHARMANDER, Species.BULBASAUR]); + + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); + + game.move.select(Moves.JAW_LOCK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + + await game.phaseInterceptor.to(MoveEffectPhase); + + expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(enemyPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + + await game.toNextTurn(); + + game.move.select(Moves.JAW_LOCK, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPLASH, 1); + + await game.phaseInterceptor.to(MoveEffectPhase); + + expect(enemyPokemon[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)?.sourceId).toBe(enemyPokemon[0].id); + }, TIMEOUT + ); + + it( + "should not trap either pokemon if the target is protected", + async () => { + game.override.enemyMoveset(Array(4).fill(Moves.PROTECT)); + + await game.startBattle([Species.BULBASAUR]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.JAW_LOCK); + + await game.phaseInterceptor.to(BerryPhase, false); + + expect(playerPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + }, TIMEOUT + ); +}); diff --git a/src/test/moves/light_screen.test.ts b/src/test/moves/light_screen.test.ts index 4577ffc574a..e94dc4a299e 100644 --- a/src/test/moves/light_screen.test.ts +++ b/src/test/moves/light_screen.test.ts @@ -1,14 +1,13 @@ -import { ArenaTagSide } from "#app/data/arena-tag.js"; -import Move, { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import Pokemon from "#app/field/pokemon.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { NumberHolder } from "#app/utils.js"; +import { ArenaTagSide } from "#app/data/arena-tag"; +import Move, { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import Pokemon from "#app/field/pokemon"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { NumberHolder } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -17,7 +16,7 @@ describe("Moves - Light Screen", () => { let phaserGame: Phaser.Game; let game: GameManager; const singleBattleMultiplier = 0.5; - const doubleBattleMultiplier = 2732/4096; + const doubleBattleMultiplier = 2732 / 4096; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -40,11 +39,11 @@ describe("Moves - Light Screen", () => { game.override.disableCrits(); }); - it("reduces damage of special attacks by half in a single battle", async() => { + it("reduces damage of special attacks by half in a single battle", async () => { const moveToUse = Moves.ABSORB; await game.startBattle([Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); @@ -53,14 +52,14 @@ describe("Moves - Light Screen", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); - it("reduces damage of special attacks by a third in a double battle", async() => { + it("reduces damage of special attacks by a third in a double battle", async () => { game.override.battleType("double"); const moveToUse = Moves.DAZZLING_GLEAM; await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); - game.doAttack(getMovePosition(game.scene, 1, moveToUse)); + game.move.select(moveToUse); + game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); @@ -68,11 +67,11 @@ describe("Moves - Light Screen", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); - it("does not affect physical attacks", async() => { + it("does not affect physical attacks", async () => { const moveToUse = Moves.TACKLE; await game.startBattle([Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); diff --git a/src/test/moves/lucky_chant.test.ts b/src/test/moves/lucky_chant.test.ts index 643a5eddb00..7d5bfe02476 100644 --- a/src/test/moves/lucky_chant.test.ts +++ b/src/test/moves/lucky_chant.test.ts @@ -1,12 +1,11 @@ +import { Abilities } from "#app/enums/abilities"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "../utils/gameManager"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -44,13 +43,13 @@ describe("Moves - Lucky Chant", () => { const playerPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); const firstTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.LUCKY_CHANT)); + game.move.select(Moves.LUCKY_CHANT); await game.phaseInterceptor.to(BerryPhase, false); @@ -68,15 +67,15 @@ describe("Moves - Lucky Chant", () => { const playerPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); const firstTurnDamage = playerPokemon[0].getMaxHp() - playerPokemon[0].hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.FOLLOW_ME)); - game.doAttack(getMovePosition(game.scene, 1, Moves.LUCKY_CHANT)); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.LUCKY_CHANT, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -97,13 +96,13 @@ describe("Moves - Lucky Chant", () => { enemyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 2, Moves.NONE, 0); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); const firstTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.LUCKY_CHANT)); + game.move.select(Moves.LUCKY_CHANT); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/magnet_rise.test.ts b/src/test/moves/magnet_rise.test.ts index 4ab32b5d048..9037e377090 100644 --- a/src/test/moves/magnet_rise.test.ts +++ b/src/test/moves/magnet_rise.test.ts @@ -1,14 +1,15 @@ -import GameManager from "#test/utils/gameManager"; +import { CommandPhase } from "#app/phases/command-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - Magnet Rise", () => { let phaserGame: Phaser.Game; let game: GameManager; + const moveToUse = Moves.MAGNET_RISE; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -22,7 +23,6 @@ describe("Moves - Magnet Rise", () => { beforeEach(() => { game = new GameManager(phaserGame); - const moveToUse = Moves.MAGNET_RISE; game.override.battleType("single"); game.override.starterSpecies(Species.MAGNEZONE); game.override.enemySpecies(Species.RATTATA); @@ -36,7 +36,7 @@ describe("Moves - Magnet Rise", () => { await game.startBattle(); const startingHp = game.scene.getParty()[0].hp; - game.doAttack(0); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); const finalHp = game.scene.getParty()[0].hp; const hpLost = finalHp - startingHp; @@ -47,12 +47,12 @@ describe("Moves - Magnet Rise", () => { await game.startBattle(); const startingHp = game.scene.getParty()[0].hp; - game.doAttack(0); + game.move.select(moveToUse); await game.phaseInterceptor.to(CommandPhase); let finalHp = game.scene.getParty()[0].hp; let hpLost = finalHp - startingHp; expect(hpLost).toBe(0); - game.doAttack(2); + game.move.select(Moves.GRAVITY); await game.phaseInterceptor.to(TurnEndPhase); finalHp = game.scene.getParty()[0].hp; hpLost = finalHp - startingHp; diff --git a/src/test/moves/make_it_rain.test.ts b/src/test/moves/make_it_rain.test.ts index 5b0a8c6d62a..0af7763f175 100644 --- a/src/test/moves/make_it_rain.test.ts +++ b/src/test/moves/make_it_rain.test.ts @@ -1,14 +1,13 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { StatChangePhase } from "#app/phases/stat-change-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { StatChangePhase } from "#app/phases/stat-change-phase.js"; const TIMEOUT = 20 * 1000; @@ -42,8 +41,8 @@ describe("Moves - Make It Rain", () => { const playerPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.MAKE_IT_RAIN); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEndPhase); @@ -59,7 +58,7 @@ describe("Moves - Make It Rain", () => { const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN)); + game.move.select(Moves.MAKE_IT_RAIN); await game.phaseInterceptor.to(StatChangePhase); @@ -75,8 +74,8 @@ describe("Moves - Make It Rain", () => { const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.MAKE_IT_RAIN); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(StatChangePhase); @@ -89,8 +88,8 @@ describe("Moves - Make It Rain", () => { const playerPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.MAKE_IT_RAIN); + game.move.select(Moves.SPLASH, 1); // Make Make It Rain miss the first target await game.move.forceMiss(true); diff --git a/src/test/moves/mat_block.test.ts b/src/test/moves/mat_block.test.ts index 27a55cab289..29a97806242 100644 --- a/src/test/moves/mat_block.test.ts +++ b/src/test/moves/mat_block.test.ts @@ -1,14 +1,13 @@ +import { BattleStat } from "#app/data/battle-stat"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import GameManager from "../utils/gameManager"; -import { Species } from "#enums/species"; -import { Abilities } from "#enums/abilities"; -import { Moves } from "#enums/moves"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -48,11 +47,11 @@ describe("Moves - Mat Block", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.MAT_BLOCK)); + game.move.select(Moves.MAT_BLOCK); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -69,11 +68,11 @@ describe("Moves - Mat Block", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.MAT_BLOCK)); + game.move.select(Moves.MAT_BLOCK); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -88,18 +87,18 @@ describe("Moves - Mat Block", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); const leadStartingHp = leadPokemon.map(p => p.hp); await game.phaseInterceptor.to(CommandPhase, false); - game.doAttack(getMovePosition(game.scene, 0, Moves.MAT_BLOCK)); + game.move.select(Moves.MAT_BLOCK); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.MAT_BLOCK)); + game.move.select(Moves.MAT_BLOCK, 1); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/miracle_eye.test.ts b/src/test/moves/miracle_eye.test.ts index 3e1e151e7d4..f47e4ce0c16 100644 --- a/src/test/moves/miracle_eye.test.ts +++ b/src/test/moves/miracle_eye.test.ts @@ -1,12 +1,11 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; +import { BattlerIndex } from "#app/battle"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/utils/gameManager"; -import { Species } from "#app/enums/species.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { Moves } from "#app/enums/moves.js"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattlerIndex } from "#app/battle.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; describe("Moves - Miracle Eye", () => { let phaserGame: Phaser.Game; @@ -38,14 +37,14 @@ describe("Moves - Miracle Eye", () => { const enemy = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.CONFUSION)); + game.move.select(Moves.CONFUSION); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); expect(enemy.hp).toBe(enemy.getMaxHp()); - game.doAttack(getMovePosition(game.scene, 0, Moves.MIRACLE_EYE)); + game.move.select(Moves.MIRACLE_EYE); await game.toNextTurn(); - game.doAttack(getMovePosition(game.scene, 0, Moves.CONFUSION)); + game.move.select(Moves.CONFUSION); await game.phaseInterceptor.to(MoveEffectPhase); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); diff --git a/src/test/moves/multi_target.test.ts b/src/test/moves/multi_target.test.ts index 6e8a7c99e9b..b8c1f67b3df 100644 --- a/src/test/moves/multi_target.test.ts +++ b/src/test/moves/multi_target.test.ts @@ -1,13 +1,12 @@ -import { getMoveTargets } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { Species } from "#app/enums/species.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; +import { getMoveTargets } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { Species } from "#app/enums/species"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; const TIMEOUT = 20 * 1000; @@ -95,8 +94,8 @@ async function checkDamageDecrease(game: GameManager, attackMove: Moves, killAll game.scene.getEnemyField()[1].abilityIndex = ability; } - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); @@ -105,9 +104,9 @@ async function checkDamageDecrease(game: GameManager, attackMove: Moves, killAll await game.toNextTurn(); const initialHp = game.scene.getEnemyField()[0].hp; - game.doAttack(getMovePosition(game.scene, 0, attackMove)); + game.move.select(attackMove); if (!killAlly) { - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); } await game.phaseInterceptor.to(TurnEndPhase); @@ -119,7 +118,7 @@ async function checkDamageDecrease(game: GameManager, attackMove: Moves, killAll game.scene.getEnemyField()[0].hp = initialHp; const initialHp1v1 = game.scene.getEnemyField()[0].hp; - game.doAttack(getMovePosition(game.scene, 0, attackMove)); + game.move.select(attackMove); await game.phaseInterceptor.to(TurnEndPhase); const afterHp1v1 = game.scene.getEnemyField()[0].hp; diff --git a/src/test/moves/octolock.test.ts b/src/test/moves/octolock.test.ts index fcd68446eff..389e4a4c4cf 100644 --- a/src/test/moves/octolock.test.ts +++ b/src/test/moves/octolock.test.ts @@ -1,16 +1,15 @@ import { BattleStat } from "#app/data/battle-stat"; -import { TrappedTag } from "#app/data/battler-tags.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { TrappedTag } from "#app/data/battler-tags"; +import { CommandPhase } from "#app/phases/command-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Octolock", () => { describe("integration tests", () => { @@ -47,7 +46,7 @@ describe("Moves - Octolock", () => { const enemyPokemon = game.scene.getEnemyField(); // use Octolock and advance to init phase of next turn to check for stat changes - game.doAttack(getMovePosition(game.scene, 0, Moves.OCTOLOCK)); + game.move.select(Moves.OCTOLOCK); await game.phaseInterceptor.to(TurnInitPhase); expect(enemyPokemon[0].summonData.battleStats[BattleStat.DEF]).toBe(-1); @@ -55,7 +54,7 @@ describe("Moves - Octolock", () => { // take a second turn to make sure stat changes occur again await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnInitPhase); expect(enemyPokemon[0].summonData.battleStats[BattleStat.DEF]).toBe(-2); @@ -70,7 +69,7 @@ describe("Moves - Octolock", () => { // before Octolock - enemy should not be trapped expect(enemyPokemon[0].findTag(t => t instanceof TrappedTag)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.OCTOLOCK)); + game.move.select(Moves.OCTOLOCK); // after Octolock - enemy should be trapped await game.phaseInterceptor.to(MoveEndPhase); diff --git a/src/test/moves/parting_shot.test.ts b/src/test/moves/parting_shot.test.ts index 32995d2d563..7c2ca3f334c 100644 --- a/src/test/moves/parting_shot.test.ts +++ b/src/test/moves/parting_shot.test.ts @@ -1,16 +1,15 @@ -import { SPLASH_ONLY } from "../utils/testUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { FaintPhase } from "#app/phases/faint-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, test, it } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, test } from "vitest"; import GameManager from "../utils/gameManager"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattleStat } from "#app/data/battle-stat"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { FaintPhase } from "#app/phases/faint-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; +import { SPLASH_ONLY } from "../utils/testUtils"; const TIMEOUT = 20 * 1000; @@ -49,7 +48,7 @@ describe("Moves - Parting Shot", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); const battleStatsOpponent = enemyPokemon.summonData.battleStats; @@ -70,7 +69,7 @@ describe("Moves - Parting Shot", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); const battleStatsOpponent = enemyPokemon.summonData.battleStats; @@ -87,19 +86,19 @@ describe("Moves - Parting Shot", () => { await game.startBattle([Species.MEOWTH, Species.MEOWTH, Species.MEOWTH, Species.MURKROW, Species.ABRA]); // use Memento 3 times to debuff enemy - game.doAttack(getMovePosition(game.scene, 0, Moves.MEMENTO)); + game.move.select(Moves.MEMENTO); await game.phaseInterceptor.to(FaintPhase); expect(game.scene.getParty()[0].isFainted()).toBe(true); game.doSelectPartyPokemon(1); await game.phaseInterceptor.to(TurnInitPhase, false); - game.doAttack(getMovePosition(game.scene, 0, Moves.MEMENTO)); + game.move.select(Moves.MEMENTO); await game.phaseInterceptor.to(FaintPhase); expect(game.scene.getParty()[0].isFainted()).toBe(true); game.doSelectPartyPokemon(2); await game.phaseInterceptor.to(TurnInitPhase, false); - game.doAttack(getMovePosition(game.scene, 0, Moves.MEMENTO)); + game.move.select(Moves.MEMENTO); await game.phaseInterceptor.to(FaintPhase); expect(game.scene.getParty()[0].isFainted()).toBe(true); game.doSelectPartyPokemon(3); @@ -114,7 +113,7 @@ describe("Moves - Parting Shot", () => { expect(battleStatsOpponent[BattleStat.SPATK]).toBe(-6); // now parting shot should fail - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-6); @@ -135,7 +134,7 @@ describe("Moves - Parting Shot", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); const battleStatsOpponent = enemyPokemon.summonData.battleStats; @@ -156,7 +155,7 @@ describe("Moves - Parting Shot", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); const battleStatsOpponent = enemyPokemon.summonData.battleStats; @@ -174,7 +173,7 @@ describe("Moves - Parting Shot", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); const battleStatsOpponent = enemyPokemon.summonData.battleStats; @@ -188,7 +187,7 @@ describe("Moves - Parting Shot", () => { "Parting shot regularly not fail if no party available to switch - party fainted", async () => { await game.startBattle([Species.MURKROW, Species.MEOWTH]); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); // intentionally kill party pokemon, switch to second slot (now 1 party mon is fainted) await game.killPokemon(game.scene.getParty()[0]); @@ -197,7 +196,7 @@ describe("Moves - Parting Shot", () => { game.doSelectPartyPokemon(1); await game.phaseInterceptor.to(TurnInitPhase, false); - game.doAttack(getMovePosition(game.scene, 0, Moves.PARTING_SHOT)); + game.move.select(Moves.PARTING_SHOT); await game.phaseInterceptor.to(BerryPhase, false); const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; diff --git a/src/test/moves/protect.test.ts b/src/test/moves/protect.test.ts index 4d97ef5ce82..3fd51f4bc93 100644 --- a/src/test/moves/protect.test.ts +++ b/src/test/moves/protect.test.ts @@ -1,14 +1,13 @@ +import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag"; +import { BattleStat } from "#app/data/battle-stat"; +import { allMoves } from "#app/data/move"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import GameManager from "../utils/gameManager"; -import { Species } from "#enums/species"; -import { Abilities } from "#enums/abilities"; -import { Moves } from "#enums/moves"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { allMoves } from "#app/data/move.js"; -import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; const TIMEOUT = 20 * 1000; @@ -48,7 +47,7 @@ describe("Moves - Protect", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); + game.move.select(Moves.PROTECT); await game.phaseInterceptor.to(BerryPhase, false); @@ -66,7 +65,7 @@ describe("Moves - Protect", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); + game.move.select(Moves.PROTECT); await game.phaseInterceptor.to(BerryPhase, false); @@ -84,7 +83,7 @@ describe("Moves - Protect", () => { const leadPokemon = game.scene.getPlayerPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); + game.move.select(Moves.PROTECT); await game.phaseInterceptor.to(BerryPhase, false); @@ -103,7 +102,7 @@ describe("Moves - Protect", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); + game.move.select(Moves.PROTECT); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/purify.test.ts b/src/test/moves/purify.test.ts index 3020e4b47ac..15d684b2d60 100644 --- a/src/test/moves/purify.test.ts +++ b/src/test/moves/purify.test.ts @@ -1,13 +1,12 @@ -import { Status, StatusEffect } from "#app/data/status-effect.js"; -import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattlerIndex } from "#app/battle"; +import { Status, StatusEffect } from "#app/data/status-effect"; +import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { BattlerIndex } from "#app/battle.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -49,7 +48,7 @@ describe("Moves - Purify", () => { playerPokemon.hp = playerPokemon.getMaxHp() - 1; enemyPokemon.status = new Status(StatusEffect.BURN); - game.doAttack(getMovePosition(game.scene, 0, Moves.PURIFY)); + game.move.select(Moves.PURIFY); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEndPhase); @@ -69,7 +68,7 @@ describe("Moves - Purify", () => { playerPokemon.hp = playerPokemon.getMaxHp() - 1; const playerInitialHp = playerPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.PURIFY)); + game.move.select(Moves.PURIFY); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEndPhase); diff --git a/src/test/moves/quick_guard.test.ts b/src/test/moves/quick_guard.test.ts index 8bf647f2027..26d9a74e9fd 100644 --- a/src/test/moves/quick_guard.test.ts +++ b/src/test/moves/quick_guard.test.ts @@ -1,13 +1,12 @@ +import { BattleStat } from "#app/data/battle-stat"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import GameManager from "../utils/gameManager"; -import { Species } from "#enums/species"; -import { Abilities } from "#enums/abilities"; -import { Moves } from "#enums/moves"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; const TIMEOUT = 20 * 1000; @@ -47,11 +46,11 @@ describe("Moves - Quick Guard", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_GUARD)); + game.move.select(Moves.QUICK_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -69,11 +68,11 @@ describe("Moves - Quick Guard", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_GUARD)); + game.move.select(Moves.QUICK_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -91,11 +90,11 @@ describe("Moves - Quick Guard", () => { const leadPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_GUARD)); + game.move.select(Moves.QUICK_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.FOLLOW_ME)); + game.move.select(Moves.FOLLOW_ME, 1); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/rage_powder.test.ts b/src/test/moves/rage_powder.test.ts index 17b687feead..3e78c6fe0c9 100644 --- a/src/test/moves/rage_powder.test.ts +++ b/src/test/moves/rage_powder.test.ts @@ -1,14 +1,11 @@ -import { BattlerIndex } from "#app/battle.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattlerIndex } from "#app/battle"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -33,35 +30,23 @@ describe("Moves - Rage Powder", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.moveset([Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); test( "move effect should be bypassed by Grass type", async () => { - game.override.enemyMoveset([ Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER ]); + game.override.enemyMoveset([Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER]); - await game.startBattle([ Species.AMOONGUSS, Species.VENUSAUR ]); - - const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); + await game.startBattle([Species.AMOONGUSS, Species.VENUSAUR]); const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY_2); + game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged @@ -74,29 +59,17 @@ describe("Moves - Rage Powder", () => { "move effect should be bypassed by Overcoat", async () => { game.override.ability(Abilities.OVERCOAT); - game.override.enemyMoveset([ Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER ]); + game.override.enemyMoveset([Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER]); // Test with two non-Grass type player Pokemon - await game.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); - - const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY_2); + game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); await game.phaseInterceptor.to(TurnEndPhase, false); // If redirection was bypassed, both enemies should be damaged diff --git a/src/test/moves/reflect.test.ts b/src/test/moves/reflect.test.ts index 79dd4f8202b..9780ede3c55 100644 --- a/src/test/moves/reflect.test.ts +++ b/src/test/moves/reflect.test.ts @@ -1,14 +1,13 @@ -import { ArenaTagSide } from "#app/data/arena-tag.js"; -import Move, { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import Pokemon from "#app/field/pokemon.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { NumberHolder } from "#app/utils.js"; +import { ArenaTagSide } from "#app/data/arena-tag"; +import Move, { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import Pokemon from "#app/field/pokemon"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { NumberHolder } from "#app/utils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -17,7 +16,7 @@ describe("Moves - Reflect", () => { let phaserGame: Phaser.Game; let game: GameManager; const singleBattleMultiplier = 0.5; - const doubleBattleMultiplier = 2732/4096; + const doubleBattleMultiplier = 2732 / 4096; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -40,11 +39,11 @@ describe("Moves - Reflect", () => { game.override.disableCrits(); }); - it("reduces damage of physical attacks by half in a single battle", async() => { + it("reduces damage of physical attacks by half in a single battle", async () => { const moveToUse = Moves.TACKLE; await game.startBattle([Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); @@ -52,14 +51,14 @@ describe("Moves - Reflect", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); - it("reduces damage of physical attacks by a third in a double battle", async() => { + it("reduces damage of physical attacks by a third in a double battle", async () => { game.override.battleType("double"); const moveToUse = Moves.ROCK_SLIDE; await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); - game.doAttack(getMovePosition(game.scene, 1, moveToUse)); + game.move.select(moveToUse); + game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); @@ -67,11 +66,11 @@ describe("Moves - Reflect", () => { expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); - it("does not affect special attacks", async() => { + it("does not affect special attacks", async () => { const moveToUse = Moves.ABSORB; await game.startBattle([Species.SHUCKLE]); - game.doAttack(getMovePosition(game.scene, 0, moveToUse)); + game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/moves/rollout.test.ts b/src/test/moves/rollout.test.ts index 1fc208c6724..ddb0b22e642 100644 --- a/src/test/moves/rollout.test.ts +++ b/src/test/moves/rollout.test.ts @@ -1,18 +1,16 @@ -import { allMoves } from "#app/data/move.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { allMoves } from "#app/data/move"; +import { CommandPhase } from "#app/phases/command-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Moves - Rollout", () => { let phaserGame: Phaser.Game; let game: GameManager; - const TIMEOUT = 20 * 1000; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -29,9 +27,9 @@ describe("Moves - Rollout", () => { game.override.disableCrits(); game.override.battleType("single"); game.override.starterSpecies(Species.RATTATA); - game.override.ability(Abilities.NONE); + game.override.ability(Abilities.BALL_FETCH); game.override.enemySpecies(Species.BIDOOF); - game.override.enemyAbility(Abilities.NONE); + game.override.enemyAbility(Abilities.BALL_FETCH); game.override.startingLevel(100); game.override.enemyLevel(100); game.override.enemyMoveset(SPLASH_ONLY); @@ -58,7 +56,7 @@ describe("Moves - Rollout", () => { let previousHp = enemyPkm.hp; for (let i = 0; i < turns; i++) { - game.doAttack(getMovePosition(game.scene, 0, Moves.ROLLOUT)); + game.move.select(Moves.ROLLOUT); await game.phaseInterceptor.to(CommandPhase); dmgHistory.push(previousHp - enemyPkm.hp); @@ -78,5 +76,5 @@ describe("Moves - Rollout", () => { // reset expect(turn6Dmg).toBeGreaterThanOrEqual(turn1Dmg - variance); expect(turn6Dmg).toBeLessThanOrEqual(turn1Dmg + variance); - }, TIMEOUT); + }); }); diff --git a/src/test/moves/roost.test.ts b/src/test/moves/roost.test.ts index c40bb18cdb1..cf07a3485e7 100644 --- a/src/test/moves/roost.test.ts +++ b/src/test/moves/roost.test.ts @@ -1,13 +1,12 @@ -import { Abilities } from "#app/enums/abilities.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; +import { Abilities } from "#app/enums/abilities"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -32,8 +31,8 @@ describe("Moves - Roost", () => { game.override.enemyAbility(Abilities.INSOMNIA); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.STOMPING_TANTRUM ]); - game.override.enemyMoveset([Moves.ROOST,Moves.ROOST,Moves.ROOST,Moves.ROOST]); + game.override.moveset([Moves.STOMPING_TANTRUM]); + game.override.enemyMoveset([Moves.ROOST, Moves.ROOST, Moves.ROOST, Moves.ROOST]); }); test( @@ -45,7 +44,7 @@ describe("Moves - Roost", () => { const enemyStartingHp = enemyPokemon.hp; - game.doAttack(getMovePosition(game.scene, 0, Moves.STOMPING_TANTRUM)); + game.move.select(Moves.STOMPING_TANTRUM); await game.phaseInterceptor.to(MoveEffectPhase); diff --git a/src/test/moves/shell_trap.test.ts b/src/test/moves/shell_trap.test.ts index c600b1ee1cc..4549a8b2b73 100644 --- a/src/test/moves/shell_trap.test.ts +++ b/src/test/moves/shell_trap.test.ts @@ -1,16 +1,15 @@ +import { BattlerIndex } from "#app/battle"; +import { allMoves } from "#app/data/move"; +import { Moves } from "#app/enums/moves"; +import { Species } from "#app/enums/species"; +import { MoveResult } from "#app/field/pokemon"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { MovePhase } from "#app/phases/move-phase"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import GameManager from "#test/utils/gameManager"; -import { Moves } from "#app/enums/moves.js"; -import { Species } from "#app/enums/species.js"; -import { allMoves } from "#app/data/move.js"; -import { BattlerIndex } from "#app/battle.js"; -import { getMovePosition } from "../utils/gameManagerUtils"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { MoveResult } from "#app/field/pokemon.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { MovePhase } from "#app/phases/move-phase.js"; const TIMEOUT = 20 * 1000; @@ -49,8 +48,8 @@ describe("Moves - Shell Trap", () => { const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SHELL_TRAP)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SHELL_TRAP, 1); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); @@ -75,8 +74,8 @@ describe("Moves - Shell Trap", () => { const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SHELL_TRAP)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SHELL_TRAP, 1); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); @@ -101,8 +100,8 @@ describe("Moves - Shell Trap", () => { const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SHELL_TRAP)); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SHELL_TRAP, 1); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); @@ -127,8 +126,8 @@ describe("Moves - Shell Trap", () => { const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SHELL_TRAP)); - game.doAttack(getMovePosition(game.scene, 1, Moves.BULLDOZE)); + game.move.select(Moves.SHELL_TRAP); + game.move.select(Moves.BULLDOZE, 1); await game.phaseInterceptor.to(MoveEndPhase); @@ -154,7 +153,7 @@ describe("Moves - Shell Trap", () => { const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.SHELL_TRAP)); + game.move.select(Moves.SHELL_TRAP); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/spikes.test.ts b/src/test/moves/spikes.test.ts index ae3c676b893..c4096111c6f 100644 --- a/src/test/moves/spikes.test.ts +++ b/src/test/moves/spikes.test.ts @@ -1,8 +1,8 @@ -import { CommandPhase } from "#app/phases/command-phase.js"; -import GameManager from "#test/utils/gameManager"; +import { CommandPhase } from "#app/phases/command-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -31,14 +31,11 @@ describe("Moves - Spikes", () => { game.override.ability(Abilities.HYDRATION); game.override.passiveAbility(Abilities.HYDRATION); game.override.startingWave(3); - game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]); - game.override.moveset([Moves.SPIKES,Moves.SPLASH, Moves.ROAR]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); + game.override.moveset([Moves.SPIKES, Moves.SPLASH, Moves.ROAR]); }); - it("single - wild - stay on field - no damage", async() => { - // player set spikes on the field and do splash for 3 turns - // opponent do splash for 4 turns - // nobody should take damage + it("single - wild - stay on field - no damage", async () => { await game.classicMode.runToSummon([ Species.MIGHTYENA, Species.POOCHYENA, @@ -46,21 +43,14 @@ describe("Moves - Spikes", () => { await game.phaseInterceptor.to(CommandPhase, true); const initialHp = game.scene.getParty()[0].hp; expect(game.scene.getParty()[0].hp).toBe(initialHp); - game.doAttack(0); + game.move.select(Moves.SPIKES); await game.toNextTurn(); - game.doAttack(1); - await game.toNextTurn(); - game.doAttack(1); - await game.toNextTurn(); - game.doAttack(1); - await game.toNextTurn(); - game.doAttack(1); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(game.scene.getParty()[0].hp).toBe(initialHp); - console.log(game.textInterceptor.logs); }, 20000); - it("single - wild - take some damage", async() => { + it("single - wild - take some damage", async () => { // player set spikes on the field and switch back to back // opponent do splash for 2 turns // nobody should take damage @@ -82,7 +72,7 @@ describe("Moves - Spikes", () => { expect(game.scene.getParty()[0].hp).toBe(initialHp); }, 20000); - it("trainer - wild - force switch opponent - should take damage", async() => { + it("trainer - wild - force switch opponent - should take damage", async () => { game.override.startingWave(5); // player set spikes on the field and do splash for 3 turns // opponent do splash for 4 turns @@ -93,14 +83,14 @@ describe("Moves - Spikes", () => { ]); await game.phaseInterceptor.to(CommandPhase, true); const initialHpOpponent = game.scene.currentBattle.enemyParty[1].hp; - game.doAttack(0); + game.move.select(Moves.SPIKES); await game.toNextTurn(); - game.doAttack(2); + game.move.select(Moves.ROAR); await game.toNextTurn(); expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(initialHpOpponent); }, 20000); - it("trainer - wild - force switch by himself opponent - should take damage", async() => { + it("trainer - wild - force switch by himself opponent - should take damage", async () => { game.override.startingWave(5); game.override.startingLevel(5000); game.override.enemySpecies(0); @@ -113,11 +103,11 @@ describe("Moves - Spikes", () => { ]); await game.phaseInterceptor.to(CommandPhase, true); const initialHpOpponent = game.scene.currentBattle.enemyParty[1].hp; - game.doAttack(0); + game.move.select(Moves.SPIKES); await game.toNextTurn(); game.forceOpponentToSwitch(); - game.doAttack(1); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(initialHpOpponent); }, 20000); diff --git a/src/test/moves/spit_up.test.ts b/src/test/moves/spit_up.test.ts index 51d84a5e151..ab47e65d653 100644 --- a/src/test/moves/spit_up.test.ts +++ b/src/test/moves/spit_up.test.ts @@ -1,17 +1,17 @@ import { BattleStat } from "#app/data/battle-stat"; -import { StockpilingTag } from "#app/data/battler-tags.js"; -import { allMoves } from "#app/data/move.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { MoveResult, TurnMove } from "#app/field/pokemon.js"; -import GameManager from "#test/utils/gameManager"; +import { StockpilingTag } from "#app/data/battler-tags"; +import { allMoves } from "#app/data/move"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { MoveResult, TurnMove } from "#app/field/pokemon"; +import { MovePhase } from "#app/phases/move-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MovePhase } from "#app/phases/move-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Spit Up", () => { let phaserGame: Phaser.Game; @@ -55,7 +55,7 @@ describe("Moves - Spit Up", () => { vi.spyOn(allMoves[Moves.SPIT_UP], "calculateBattlePower"); - game.doAttack(0); + game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); expect(allMoves[Moves.SPIT_UP].calculateBattlePower).toHaveBeenCalledOnce(); @@ -80,7 +80,7 @@ describe("Moves - Spit Up", () => { vi.spyOn(allMoves[Moves.SPIT_UP], "calculateBattlePower"); - game.doAttack(0); + game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); expect(allMoves[Moves.SPIT_UP].calculateBattlePower).toHaveBeenCalledOnce(); @@ -106,7 +106,7 @@ describe("Moves - Spit Up", () => { vi.spyOn(allMoves[Moves.SPIT_UP], "calculateBattlePower"); - game.doAttack(0); + game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); expect(allMoves[Moves.SPIT_UP].calculateBattlePower).toHaveBeenCalledOnce(); @@ -126,7 +126,7 @@ describe("Moves - Spit Up", () => { vi.spyOn(allMoves[Moves.SPIT_UP], "calculateBattlePower"); - game.doAttack(0); + game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.FAIL }); @@ -146,7 +146,7 @@ describe("Moves - Spit Up", () => { vi.spyOn(allMoves[Moves.SPIT_UP], "calculateBattlePower"); - game.doAttack(0); + game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(MovePhase); expect(pokemon.summonData.battleStats[BattleStat.DEF]).toBe(1); @@ -186,7 +186,7 @@ describe("Moves - Spit Up", () => { vi.spyOn(allMoves[Moves.SPIT_UP], "calculateBattlePower"); - game.doAttack(0); + game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS }); diff --git a/src/test/moves/spotlight.test.ts b/src/test/moves/spotlight.test.ts index 40ab78471ae..e5f4719d1d3 100644 --- a/src/test/moves/spotlight.test.ts +++ b/src/test/moves/spotlight.test.ts @@ -1,14 +1,11 @@ -import { BattlerIndex } from "#app/battle.js"; +import { BattlerIndex } from "#app/battle"; import { Stat } from "#app/data/pokemon-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; const TIMEOUT = 20 * 1000; @@ -33,33 +30,21 @@ describe("Moves - Spotlight", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.moveset([Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); test( "move should redirect attacks to the target", async () => { - await game.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); - - const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); + await game.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(BattlerIndex.ENEMY_2); + game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); await game.phaseInterceptor.to(TurnEndPhase, false); expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); @@ -70,17 +55,11 @@ describe("Moves - Spotlight", () => { test( "move should cause other redirection moves to fail", async () => { - game.override.enemyMoveset([ Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME ]); + game.override.enemyMoveset([Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME, Moves.FOLLOW_ME]); - await game.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); - - const playerPokemon = game.scene.getPlayerField(); - expect(playerPokemon.length).toBe(2); - playerPokemon.forEach(p => expect(p).not.toBe(undefined)); + await game.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon.length).toBe(2); - enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); /** * Spotlight will target the slower enemy. In this situation without Spotlight being used, @@ -92,14 +71,8 @@ describe("Moves - Spotlight", () => { const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPOTLIGHT)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(spotTarget); - await game.phaseInterceptor.to(CommandPhase); - - game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK)); - await game.phaseInterceptor.to(SelectTargetPhase, false); - game.doSelectTarget(attackTarget); + game.move.select(Moves.SPOTLIGHT, 0, spotTarget); + game.move.select(Moves.QUICK_ATTACK, 1, attackTarget); await game.phaseInterceptor.to(TurnEndPhase, false); expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); diff --git a/src/test/moves/stockpile.test.ts b/src/test/moves/stockpile.test.ts index 0b208e20f81..b1941b9f9b3 100644 --- a/src/test/moves/stockpile.test.ts +++ b/src/test/moves/stockpile.test.ts @@ -1,16 +1,15 @@ import { BattleStat } from "#app/data/battle-stat"; -import { StockpilingTag } from "#app/data/battler-tags.js"; -import { MoveResult, TurnMove } from "#app/field/pokemon.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { StockpilingTag } from "#app/data/battler-tags"; +import { MoveResult, TurnMove } from "#app/field/pokemon"; +import { CommandPhase } from "#app/phases/command-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Stockpile", () => { describe("integration tests", () => { @@ -57,7 +56,7 @@ describe("Moves - Stockpile", () => { await game.phaseInterceptor.to(CommandPhase); } - game.doAttack(getMovePosition(game.scene, 0, Moves.STOCKPILE)); + game.move.select(Moves.STOCKPILE); await game.phaseInterceptor.to(TurnInitPhase); const stockpilingTag = user.getTag(StockpilingTag)!; @@ -92,7 +91,7 @@ describe("Moves - Stockpile", () => { expect(user.summonData.battleStats[BattleStat.DEF]).toBe(6); expect(user.summonData.battleStats[BattleStat.SPDEF]).toBe(6); - game.doAttack(getMovePosition(game.scene, 0, Moves.STOCKPILE)); + game.move.select(Moves.STOCKPILE); await game.phaseInterceptor.to(TurnInitPhase); const stockpilingTag = user.getTag(StockpilingTag)!; @@ -104,7 +103,7 @@ describe("Moves - Stockpile", () => { // do it again, just for good measure await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.STOCKPILE)); + game.move.select(Moves.STOCKPILE); await game.phaseInterceptor.to(TurnInitPhase); const stockpilingTagAgain = user.getTag(StockpilingTag)!; diff --git a/src/test/moves/swallow.test.ts b/src/test/moves/swallow.test.ts index 6a054393acc..202f25fee74 100644 --- a/src/test/moves/swallow.test.ts +++ b/src/test/moves/swallow.test.ts @@ -1,16 +1,16 @@ import { BattleStat } from "#app/data/battle-stat"; -import { StockpilingTag } from "#app/data/battler-tags.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import { MoveResult, TurnMove } from "#app/field/pokemon.js"; -import GameManager from "#test/utils/gameManager"; +import { StockpilingTag } from "#app/data/battler-tags"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { MoveResult, TurnMove } from "#app/field/pokemon"; +import { MovePhase } from "#app/phases/move-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MovePhase } from "#app/phases/move-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Swallow", () => { let phaserGame: Phaser.Game; @@ -57,7 +57,7 @@ describe("Moves - Swallow", () => { vi.spyOn(pokemon, "heal"); - game.doAttack(0); + game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.heal).toHaveBeenCalledOnce(); @@ -85,7 +85,7 @@ describe("Moves - Swallow", () => { vi.spyOn(pokemon, "heal"); - game.doAttack(0); + game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.heal).toHaveBeenCalledOnce(); @@ -114,7 +114,7 @@ describe("Moves - Swallow", () => { vi.spyOn(pokemon, "heal"); - game.doAttack(0); + game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.heal).toHaveBeenCalledOnce(); @@ -132,7 +132,7 @@ describe("Moves - Swallow", () => { const stockpilingTag = pokemon.getTag(StockpilingTag)!; expect(stockpilingTag).toBeUndefined(); - game.doAttack(0); + game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.FAIL }); @@ -148,7 +148,7 @@ describe("Moves - Swallow", () => { const stockpilingTag = pokemon.getTag(StockpilingTag)!; expect(stockpilingTag).toBeDefined(); - game.doAttack(0); + game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(MovePhase); expect(pokemon.summonData.battleStats[BattleStat.DEF]).toBe(1); @@ -184,7 +184,7 @@ describe("Moves - Swallow", () => { [BattleStat.SPDEF]: 2, }); - game.doAttack(0); + game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS }); diff --git a/src/test/moves/tackle.test.ts b/src/test/moves/tackle.test.ts index f442645baa9..5eca9e344c8 100644 --- a/src/test/moves/tackle.test.ts +++ b/src/test/moves/tackle.test.ts @@ -1,15 +1,11 @@ import { Stat } from "#app/data/pokemon-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - Tackle", () => { @@ -34,30 +30,24 @@ describe("Moves - Tackle", () => { game.override.startingLevel(1); game.override.startingWave(97); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.GROWTH,Moves.GROWTH,Moves.GROWTH,Moves.GROWTH]); + game.override.enemyMoveset([Moves.GROWTH, Moves.GROWTH, Moves.GROWTH, Moves.GROWTH]); game.override.disableCrits(); }); - it("TACKLE against ghost", async() => { + it("TACKLE against ghost", async () => { const moveToUse = Moves.TACKLE; game.override.enemySpecies(Species.GENGAR); await game.startBattle([ Species.MIGHTYENA, ]); const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp; expect(hpLost).toBe(0); }, 20000); - it("TACKLE against not resistant", async() => { + it("TACKLE against not resistant", async () => { const moveToUse = Moves.TACKLE; await game.startBattle([ Species.MIGHTYENA, @@ -68,16 +58,10 @@ describe("Moves - Tackle", () => { const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp; expect(hpLost).toBeGreaterThan(0); - expect(hpLost).toBe(4); + expect(hpLost).toBeLessThan(4); }, 20000); }); diff --git a/src/test/moves/tail_whip.test.ts b/src/test/moves/tail_whip.test.ts index ba4a7459094..0a999fe1920 100644 --- a/src/test/moves/tail_whip.test.ts +++ b/src/test/moves/tail_whip.test.ts @@ -1,16 +1,12 @@ import { BattleStat } from "#app/data/battle-stat"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; describe("Moves - Tail whip", () => { @@ -36,10 +32,10 @@ describe("Moves - Tail whip", () => { game.override.ability(Abilities.INSOMNIA); game.override.startingLevel(2000); game.override.moveset([moveToUse]); - game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("TAIL_WHIP", async() => { + it("TAIL_WHIP", async () => { const moveToUse = Moves.TAIL_WHIP; await game.startBattle([ Species.MIGHTYENA, @@ -49,13 +45,7 @@ describe("Moves - Tail whip", () => { let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; expect(battleStatsOpponent[BattleStat.DEF]).toBe(0); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - const movePosition = getMovePosition(game.scene, 0, moveToUse); - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); + game.move.select(moveToUse); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase); battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; expect(battleStatsOpponent[BattleStat.DEF]).toBe(-1); diff --git a/src/test/moves/tailwind.test.ts b/src/test/moves/tailwind.test.ts index 115a97f3be4..6b70122d08d 100644 --- a/src/test/moves/tailwind.test.ts +++ b/src/test/moves/tailwind.test.ts @@ -1,14 +1,13 @@ -import { ArenaTagSide } from "#app/data/arena-tag.js"; -import { Stat } from "#app/data/pokemon-stat.js"; -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { ArenaTagSide } from "#app/data/arena-tag"; +import { Stat } from "#app/data/pokemon-stat"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; describe("Moves - Tailwind", () => { let phaserGame: Phaser.Game; @@ -42,8 +41,8 @@ describe("Moves - Tailwind", () => { expect(magikarp.getBattleStat(Stat.SPD)).equal(magikarpSpd); expect(meowth.getBattleStat(Stat.SPD)).equal(meowthSpd); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.TAILWIND); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); @@ -57,19 +56,19 @@ describe("Moves - Tailwind", () => { await game.startBattle([Species.MAGIKARP]); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.toNextTurn(); expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.PLAYER)).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.PLAYER)).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.PLAYER)).toBeDefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.PLAYER)).toBeUndefined(); @@ -92,7 +91,7 @@ describe("Moves - Tailwind", () => { expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.PLAYER)).toBeUndefined(); expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.ENEMY)).toBeUndefined(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); + game.move.select(Moves.TAILWIND); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/src/test/moves/tera_blast.test.ts b/src/test/moves/tera_blast.test.ts new file mode 100644 index 00000000000..d261d4b856b --- /dev/null +++ b/src/test/moves/tera_blast.test.ts @@ -0,0 +1,105 @@ +import { BattlerIndex } from "#app/battle"; +import { BattleStat } from "#app/data/battle-stat"; +import { allMoves } from "#app/data/move"; +import { Type } from "#app/data/type"; +import { Abilities } from "#app/enums/abilities"; +import { Stat } from "#app/enums/stat"; +import { HitResult } from "#app/field/pokemon"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import { SPLASH_ONLY } from "../utils/testUtils"; + +describe("Moves - Tera Blast", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + const moveToCheck = allMoves[Moves.TERA_BLAST]; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + + game.override + .battleType("single") + .disableCrits() + .starterSpecies(Species.FEEBAS) + .moveset([Moves.TERA_BLAST]) + .ability(Abilities.BALL_FETCH) + .startingHeldItems([{ name: "TERA_SHARD", type: Type.FIRE }]) + .enemySpecies(Species.MAGIKARP) + .enemyMoveset(SPLASH_ONLY) + .enemyAbility(Abilities.BALL_FETCH) + .enemyLevel(20); + + vi.spyOn(moveToCheck, "calculateBattlePower"); + }); + + it("changes type to match user's tera type", async () => { + game.override + .enemySpecies(Species.FURRET) + .startingHeldItems([{ name: "TERA_SHARD", type: Type.FIGHTING }]); + await game.startBattle(); + const enemyPokemon = game.scene.getEnemyPokemon()!; + vi.spyOn(enemyPokemon, "apply"); + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEffectPhase"); + + expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE); + }, 20000); + + it("increases power if user is Stellar tera type", async () => { + game.override.startingHeldItems([{ name: "TERA_SHARD", type: Type.STELLAR }]); + const stellarTypeMultiplier = 2; + const stellarTypeDmgBonus = 20; + const basePower = moveToCheck.power; + + await game.startBattle(); + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEffectPhase"); + + expect(moveToCheck.calculateBattlePower).toHaveReturnedWith((basePower + stellarTypeDmgBonus) * stellarTypeMultiplier); + }, 20000); + + // Currently abilities are bugged and can't see when a move's category is changed + it.skip("uses the higher stat of the user's Atk and SpAtk for damage calculation", async () => { + game.override.enemyAbility(Abilities.TOXIC_DEBRIS); + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.stats[Stat.ATK] = 100; + playerPokemon.stats[Stat.SPATK] = 1; + + game.move.select(Moves.TERA_BLAST); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); + }, 20000); + + it("causes stat drops if user is Stellar tera type", async () => { + game.override.startingHeldItems([{ name: "TERA_SHARD", type: Type.STELLAR }]); + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEndPhase"); + + expect(playerPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(-1); + expect(playerPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-1); + }, 20000); +}); diff --git a/src/test/moves/thousand_arrows.test.ts b/src/test/moves/thousand_arrows.test.ts index d72f3ed3fac..8d1d6ee5f4a 100644 --- a/src/test/moves/thousand_arrows.test.ts +++ b/src/test/moves/thousand_arrows.test.ts @@ -1,13 +1,12 @@ -import { Abilities } from "#app/enums/abilities.js"; -import { BattlerTagType } from "#app/enums/battler-tag-type.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { Abilities } from "#app/enums/abilities"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; const TIMEOUT = 20 * 1000; @@ -31,18 +30,18 @@ describe("Moves - Thousand Arrows", () => { game.override.enemySpecies(Species.TOGETIC); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.THOUSAND_ARROWS ]); - game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]); + game.override.moveset([Moves.THOUSAND_ARROWS]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); }); it( "move should hit and ground Flying-type targets", async () => { - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.THOUSAND_ARROWS)); + game.move.select(Moves.THOUSAND_ARROWS); await game.phaseInterceptor.to(MoveEffectPhase, false); // Enemy should not be grounded before move effect is applied @@ -61,11 +60,11 @@ describe("Moves - Thousand Arrows", () => { game.override.enemySpecies(Species.SNORLAX); game.override.enemyAbility(Abilities.LEVITATE); - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); const enemyPokemon = game.scene.getEnemyPokemon()!; - game.doAttack(getMovePosition(game.scene, 0, Moves.THOUSAND_ARROWS)); + game.move.select(Moves.THOUSAND_ARROWS); await game.phaseInterceptor.to(MoveEffectPhase, false); // Enemy should not be grounded before move effect is applied @@ -83,13 +82,13 @@ describe("Moves - Thousand Arrows", () => { async () => { game.override.enemySpecies(Species.SNORLAX); - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); const enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon.addTag(BattlerTagType.MAGNET_RISEN, undefined, Moves.MAGNET_RISE); - game.doAttack(getMovePosition(game.scene, 0, Moves.THOUSAND_ARROWS)); + game.move.select(Moves.THOUSAND_ARROWS); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/moves/tidy_up.test.ts b/src/test/moves/tidy_up.test.ts index 64a63df08df..1ef7933c114 100644 --- a/src/test/moves/tidy_up.test.ts +++ b/src/test/moves/tidy_up.test.ts @@ -1,15 +1,14 @@ -import { BattleStat } from "#app/data/battle-stat.js"; -import { ArenaTagType } from "#app/enums/arena-tag-type.js"; -import GameManager from "#test/utils/gameManager"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; +import { BattleStat } from "#app/data/battle-stat"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - Tidy Up", () => { @@ -38,81 +37,81 @@ describe("Moves - Tidy Up", () => { game.override.startingLevel(50); }); - it("spikes are cleared", async() => { + it("spikes are cleared", async () => { game.override.moveset([Moves.SPIKES, Moves.TIDY_UP]); game.override.enemyMoveset([Moves.SPIKES, Moves.SPIKES, Moves.SPIKES, Moves.SPIKES]); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SPIKES)); + game.move.select(Moves.SPIKES); await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.TIDY_UP)); + game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.arena.getTag(ArenaTagType.SPIKES)).toBeUndefined(); }, 20000); - it("stealth rocks are cleared", async() => { + it("stealth rocks are cleared", async () => { game.override.moveset([Moves.STEALTH_ROCK, Moves.TIDY_UP]); game.override.enemyMoveset([Moves.STEALTH_ROCK, Moves.STEALTH_ROCK, Moves.STEALTH_ROCK, Moves.STEALTH_ROCK]); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.STEALTH_ROCK)); + game.move.select(Moves.STEALTH_ROCK); await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.TIDY_UP)); + game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.arena.getTag(ArenaTagType.STEALTH_ROCK)).toBeUndefined(); }, 20000); - it("toxic spikes are cleared", async() => { + it("toxic spikes are cleared", async () => { game.override.moveset([Moves.TOXIC_SPIKES, Moves.TIDY_UP]); game.override.enemyMoveset([Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES]); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC_SPIKES)); + game.move.select(Moves.TOXIC_SPIKES); await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.TIDY_UP)); + game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.arena.getTag(ArenaTagType.TOXIC_SPIKES)).toBeUndefined(); }, 20000); - it("sticky webs are cleared", async() => { + it("sticky webs are cleared", async () => { game.override.moveset([Moves.STICKY_WEB, Moves.TIDY_UP]); game.override.enemyMoveset([Moves.STICKY_WEB, Moves.STICKY_WEB, Moves.STICKY_WEB, Moves.STICKY_WEB]); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.STICKY_WEB)); + game.move.select(Moves.STICKY_WEB); await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.TIDY_UP)); + game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.arena.getTag(ArenaTagType.STICKY_WEB)).toBeUndefined(); }, 20000); - it.skip("substitutes are cleared", async() => { + it.skip("substitutes are cleared", async () => { game.override.moveset([Moves.SUBSTITUTE, Moves.TIDY_UP]); game.override.enemyMoveset([Moves.SUBSTITUTE, Moves.SUBSTITUTE, Moves.SUBSTITUTE, Moves.SUBSTITUTE]); await game.startBattle(); - game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE)); + game.move.select(Moves.SUBSTITUTE); await game.phaseInterceptor.to(TurnEndPhase); - game.doAttack(getMovePosition(game.scene, 0, Moves.TIDY_UP)); + game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); // TODO: check for subs here once the move is implemented }, 20000); - it("user's stats are raised with no traps set", async() => { + it("user's stats are raised with no traps set", async () => { await game.startBattle(); const player = game.scene.getPlayerPokemon()!.summonData.battleStats; expect(player[BattleStat.ATK]).toBe(0); expect(player[BattleStat.SPD]).toBe(0); - game.doAttack(getMovePosition(game.scene, 0, Moves.TIDY_UP)); + game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(TurnEndPhase); expect(player[BattleStat.ATK]).toBe(+1); diff --git a/src/test/moves/u_turn.test.ts b/src/test/moves/u_turn.test.ts index b93f997c487..ae55302bb42 100644 --- a/src/test/moves/u_turn.test.ts +++ b/src/test/moves/u_turn.test.ts @@ -1,14 +1,13 @@ -import { Abilities } from "#app/enums/abilities.js"; +import { Abilities } from "#app/enums/abilities"; +import { StatusEffect } from "#app/enums/status-effect"; +import { SwitchPhase } from "#app/phases/switch-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#app/test/utils/gameManager"; -import { getMovePosition } from "#app/test/utils/gameManagerUtils"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { StatusEffect } from "#app/enums/status-effect.js"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { SwitchPhase } from "#app/phases/switch-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; describe("Moves - U-turn", () => { let phaserGame: Phaser.Game; @@ -36,7 +35,7 @@ describe("Moves - U-turn", () => { .disableCrits(); }); - it("triggers regenerator a single time when a regenerator user switches out with u-turn", async() => { + it("triggers regenerator a single time when a regenerator user switches out with u-turn", async () => { // arrange const playerHp = 1; game.override.ability(Abilities.REGENERATOR); @@ -47,7 +46,7 @@ describe("Moves - U-turn", () => { game.scene.getPlayerPokemon()!.hp = playerHp; // act - game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN)); + game.move.select(Moves.U_TURN); game.doSelectPartyPokemon(1); await game.phaseInterceptor.to(TurnEndPhase); @@ -57,7 +56,7 @@ describe("Moves - U-turn", () => { expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.SHUCKLE); }, 20000); - it("triggers rough skin on the u-turn user before a new pokemon is switched in", async() => { + it("triggers rough skin on the u-turn user before a new pokemon is switched in", async () => { // arrange game.override.enemyAbility(Abilities.ROUGH_SKIN); await game.startBattle([ @@ -66,7 +65,7 @@ describe("Moves - U-turn", () => { ]); // act - game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN)); + game.move.select(Moves.U_TURN); game.doSelectPartyPokemon(1); await game.phaseInterceptor.to(SwitchPhase, false); @@ -78,7 +77,7 @@ describe("Moves - U-turn", () => { expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase"); }, 20000); - it("triggers contact abilities on the u-turn user (eg poison point) before a new pokemon is switched in", async() => { + it("triggers contact abilities on the u-turn user (eg poison point) before a new pokemon is switched in", async () => { // arrange game.override.enemyAbility(Abilities.POISON_POINT); await game.startBattle([ @@ -88,7 +87,7 @@ describe("Moves - U-turn", () => { vi.spyOn(game.scene.getEnemyPokemon()!, "randSeedInt").mockReturnValue(0); // act - game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN)); + game.move.select(Moves.U_TURN); await game.phaseInterceptor.to(SwitchPhase, false); // assert diff --git a/src/test/moves/wide_guard.test.ts b/src/test/moves/wide_guard.test.ts index 1f22428de4b..616972de01b 100644 --- a/src/test/moves/wide_guard.test.ts +++ b/src/test/moves/wide_guard.test.ts @@ -1,13 +1,12 @@ +import { BattleStat } from "#app/data/battle-stat"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import GameManager from "../utils/gameManager"; -import { Species } from "#enums/species"; -import { Abilities } from "#enums/abilities"; -import { Moves } from "#enums/moves"; -import { getMovePosition } from "../utils/gameManagerUtils"; -import { BattleStat } from "#app/data/battle-stat.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; const TIMEOUT = 20 * 1000; @@ -47,11 +46,11 @@ describe("Moves - Wide Guard", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.WIDE_GUARD)); + game.move.select(Moves.WIDE_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -68,11 +67,11 @@ describe("Moves - Wide Guard", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.WIDE_GUARD)); + game.move.select(Moves.WIDE_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -89,11 +88,11 @@ describe("Moves - Wide Guard", () => { const leadPokemon = game.scene.getPlayerField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.WIDE_GUARD)); + game.move.select(Moves.WIDE_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); + game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(BerryPhase, false); @@ -111,11 +110,11 @@ describe("Moves - Wide Guard", () => { const leadPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - game.doAttack(getMovePosition(game.scene, 0, Moves.WIDE_GUARD)); + game.move.select(Moves.WIDE_GUARD); await game.phaseInterceptor.to(CommandPhase); - game.doAttack(getMovePosition(game.scene, 1, Moves.SURF)); + game.move.select(Moves.SURF, 1); await game.phaseInterceptor.to(BerryPhase, false); diff --git a/src/test/phases/phases.test.ts b/src/test/phases/phases.test.ts index 2ed1e48c706..5ef25361a3f 100644 --- a/src/test/phases/phases.test.ts +++ b/src/test/phases/phases.test.ts @@ -1,11 +1,11 @@ -import BattleScene from "#app/battle-scene.js"; -import { Mode } from "#app/ui/ui.js"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; +import BattleScene from "#app/battle-scene"; +import { LoginPhase } from "#app/phases/login-phase"; +import { TitlePhase } from "#app/phases/title-phase"; +import { UnavailablePhase } from "#app/phases/unavailable-phase"; +import { Mode } from "#app/ui/ui"; import GameManager from "#test/utils/gameManager"; -import { LoginPhase } from "#app/phases/login-phase.js"; -import { TitlePhase } from "#app/phases/title-phase.js"; -import { UnavailablePhase } from "#app/phases/unavailable-phase.js"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("Phases", () => { let phaserGame: Phaser.Game; diff --git a/src/test/settingMenu/helpers/inGameManip.ts b/src/test/settingMenu/helpers/inGameManip.ts index e18a82ca571..b81e577f5b9 100644 --- a/src/test/settingMenu/helpers/inGameManip.ts +++ b/src/test/settingMenu/helpers/inGameManip.ts @@ -1,6 +1,6 @@ import { getIconForLatestInput, getSettingNameWithKeycode } from "#app/configs/inputs/configHandler"; -import { expect } from "vitest"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; +import { expect } from "vitest"; export class InGameManip { private config; diff --git a/src/test/settingMenu/helpers/menuManip.ts b/src/test/settingMenu/helpers/menuManip.ts index 4fd5f526897..90b3f1e96e6 100644 --- a/src/test/settingMenu/helpers/menuManip.ts +++ b/src/test/settingMenu/helpers/menuManip.ts @@ -1,6 +1,6 @@ -import { expect } from "vitest"; -import { deleteBind, getIconWithKeycode, getIconWithSettingName, getKeyWithKeycode, getKeyWithSettingName, assign, getSettingNameWithKeycode, canIAssignThisKey, canIDeleteThisKey, canIOverrideThisSetting } from "#app/configs/inputs/configHandler"; +import { assign, canIAssignThisKey, canIDeleteThisKey, canIOverrideThisSetting, deleteBind, getIconWithKeycode, getIconWithSettingName, getKeyWithKeycode, getKeyWithSettingName, getSettingNameWithKeycode } from "#app/configs/inputs/configHandler"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; +import { expect } from "vitest"; export class MenuManip { private config; diff --git a/src/test/settingMenu/rebinding_setting.test.ts b/src/test/settingMenu/rebinding_setting.test.ts index eead23972c2..ec2343cfb41 100644 --- a/src/test/settingMenu/rebinding_setting.test.ts +++ b/src/test/settingMenu/rebinding_setting.test.ts @@ -1,13 +1,13 @@ -import { beforeEach, describe, expect, it } from "vitest"; -import { deepCopy } from "#app/utils"; -import { getKeyWithKeycode, getKeyWithSettingName } from "#app/configs/inputs/configHandler"; -import { MenuManip } from "#test/settingMenu/helpers/menuManip"; -import { InGameManip } from "#test/settingMenu/helpers/inGameManip"; -import { InterfaceConfig } from "#app/inputs-controller"; import cfg_keyboard_qwerty from "#app/configs/inputs/cfg_keyboard_qwerty"; +import { getKeyWithKeycode, getKeyWithSettingName } from "#app/configs/inputs/configHandler"; +import { InterfaceConfig } from "#app/inputs-controller"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; -import { Device } from "#enums/devices"; +import { deepCopy } from "#app/utils"; import { Button } from "#enums/buttons"; +import { Device } from "#enums/devices"; +import { InGameManip } from "#test/settingMenu/helpers/inGameManip"; +import { MenuManip } from "#test/settingMenu/helpers/menuManip"; +import { beforeEach, describe, expect, it } from "vitest"; describe("Test Rebinding", () => { diff --git a/src/test/sprites/pokemonSprite.test.ts b/src/test/sprites/pokemonSprite.test.ts index deb5844d677..faf0626b365 100644 --- a/src/test/sprites/pokemonSprite.test.ts +++ b/src/test/sprites/pokemonSprite.test.ts @@ -1,8 +1,8 @@ -import { beforeAll, describe, expect, it } from "vitest"; -import _masterlist from "../../../public/images/pokemon/variant/_masterlist.json"; +import { getAppRootDir } from "#test/sprites/spritesUtils"; import fs from "fs"; import path from "path"; -import { getAppRootDir } from "#test/sprites/spritesUtils"; +import { beforeAll, describe, expect, it } from "vitest"; +import _masterlist from "../../../public/images/pokemon/variant/_masterlist.json"; type PokemonVariantMasterlist = typeof _masterlist; diff --git a/src/test/ui/starter-select.test.ts b/src/test/ui/starter-select.test.ts index dbbdb1999b9..8ef1ea16b4a 100644 --- a/src/test/ui/starter-select.test.ts +++ b/src/test/ui/starter-select.test.ts @@ -1,21 +1,21 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Mode } from "#app/ui/ui"; -import { GameModes } from "#app/game-mode"; -import StarterSelectUiHandler from "#app/ui/starter-select-ui-handler"; -import OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler"; -import SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; -import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { Gender } from "#app/data/gender"; +import { Nature } from "#app/data/nature"; import { allSpecies } from "#app/data/pokemon-species"; -import { Nature} from "#app/data/nature"; -import { Button } from "#enums/buttons"; +import { GameModes } from "#app/game-mode"; +import { EncounterPhase } from "#app/phases/encounter-phase"; +import { SelectStarterPhase } from "#app/phases/select-starter-phase"; +import { TitlePhase } from "#app/phases/title-phase"; +import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; +import SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; +import OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler"; +import StarterSelectUiHandler from "#app/ui/starter-select-ui-handler"; +import { Mode } from "#app/ui/ui"; import { Abilities } from "#enums/abilities"; +import { Button } from "#enums/buttons"; import { Species } from "#enums/species"; -import { EncounterPhase } from "#app/phases/encounter-phase.js"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase.js"; -import { TitlePhase } from "#app/phases/title-phase.js"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("UI - Starter select", () => { diff --git a/src/test/ui/transfer-item.test.ts b/src/test/ui/transfer-item.test.ts index 21aed9b5b87..f7dea463574 100644 --- a/src/test/ui/transfer-item.test.ts +++ b/src/test/ui/transfer-item.test.ts @@ -2,16 +2,15 @@ import { BerryType } from "#app/enums/berry-type"; import { Button } from "#app/enums/buttons"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; -import GameManager from "#test/utils/gameManager"; +import { BattleEndPhase } from "#app/phases/battle-end-phase"; +import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler"; import { Mode } from "#app/ui/ui"; +import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { getMovePosition } from "#test/utils/gameManagerUtils"; -import { BattleEndPhase } from "#app/phases/battle-end-phase.js"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase.js"; describe("UI - Transfer Items", () => { @@ -44,7 +43,7 @@ describe("UI - Transfer Items", () => { await game.startBattle([Species.RAYQUAZA, Species.RAYQUAZA, Species.RAYQUAZA]); - game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_CLAW)); + game.move.select(Moves.DRAGON_CLAW); game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); @@ -88,6 +87,7 @@ describe("UI - Transfer Items", () => { handler.processInput(Button.ACTION); // select Pokemon expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Transfer"))).toBe(true); + game.phaseInterceptor.unlock(); }); diff --git a/src/test/ui/type-hints.test.ts b/src/test/ui/type-hints.test.ts index f93260f15b7..ccab02b82bf 100644 --- a/src/test/ui/type-hints.test.ts +++ b/src/test/ui/type-hints.test.ts @@ -1,14 +1,14 @@ -import { Button } from "#app/enums/buttons.js"; +import { Button } from "#app/enums/buttons"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; -import FightUiHandler from "#app/ui/fight-ui-handler.js"; -import { Mode } from "#app/ui/ui.js"; +import { CommandPhase } from "#app/phases/command-phase"; +import FightUiHandler from "#app/ui/fight-ui-handler"; +import { Mode } from "#app/ui/ui"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import MockText from "../utils/mocks/mocksContainer/mockText"; import { SPLASH_ONLY } from "../utils/testUtils"; -import { CommandPhase } from "#app/phases/command-phase.js"; describe("UI - Type Hints", () => { let phaserGame: Phaser.Game; diff --git a/src/test/utils/gameManager.ts b/src/test/utils/gameManager.ts index 54c6d0968ba..a6ae93d2e32 100644 --- a/src/test/utils/gameManager.ts +++ b/src/test/utils/gameManager.ts @@ -1,35 +1,10 @@ -import GameWrapper from "#test/utils/gameWrapper"; -import { Mode } from "#app/ui/ui"; -import { generateStarter, waitUntil } from "#test/utils/gameManagerUtils"; -import BattleScene from "#app/battle-scene.js"; -import PhaseInterceptor from "#test/utils/phaseInterceptor"; -import TextInterceptor from "#test/utils/TextInterceptor"; -import { GameModes, getGameMode } from "#app/game-mode"; -import fs from "fs"; -import { AES, enc } from "crypto-js"; import { updateUserInfo } from "#app/account"; -import InputsHandler from "#app/test/utils/inputsHandler"; -import ErrorInterceptor from "#app/test/utils/errorInterceptor"; -import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; -import { MockClock } from "#app/test/utils/mocks/mockClock"; -import PartyUiHandler from "#app/ui/party-ui-handler"; -import CommandUiHandler, { Command } from "#app/ui/command-ui-handler"; -import Trainer from "#app/field/trainer"; -import { ExpNotification } from "#enums/exp-notification"; -import { GameDataType } from "#enums/game-data-type"; -import { PlayerGender } from "#enums/player-gender"; -import { Species } from "#enums/species"; -import { Button } from "#enums/buttons"; import { BattlerIndex } from "#app/battle"; -import TargetSelectUiHandler from "#app/ui/target-select-ui-handler"; -import { OverridesHelper } from "./helpers/overridesHelper"; +import BattleScene from "#app/battle-scene"; +import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; +import Trainer from "#app/field/trainer"; +import { GameModes, getGameMode } from "#app/game-mode"; import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type"; -import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; -import { MoveHelper } from "./helpers/moveHelper"; -import { vi } from "vitest"; -import { ClassicModeHelper } from "./helpers/classicModeHelper"; -import { DailyModeHelper } from "./helpers/dailyModeHelper"; -import { SettingsHelper } from "./helpers/settingsHelper"; import { CommandPhase } from "#app/phases/command-phase"; import { EncounterPhase } from "#app/phases/encounter-phase"; import { FaintPhase } from "#app/phases/faint-phase"; @@ -42,6 +17,31 @@ import { TitlePhase } from "#app/phases/title-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { TurnStartPhase } from "#app/phases/turn-start-phase"; +import ErrorInterceptor from "#app/test/utils/errorInterceptor"; +import InputsHandler from "#app/test/utils/inputsHandler"; +import { MockClock } from "#app/test/utils/mocks/mockClock"; +import CommandUiHandler from "#app/ui/command-ui-handler"; +import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; +import PartyUiHandler from "#app/ui/party-ui-handler"; +import TargetSelectUiHandler from "#app/ui/target-select-ui-handler"; +import { Mode } from "#app/ui/ui"; +import { Button } from "#enums/buttons"; +import { ExpNotification } from "#enums/exp-notification"; +import { GameDataType } from "#enums/game-data-type"; +import { PlayerGender } from "#enums/player-gender"; +import { Species } from "#enums/species"; +import { generateStarter, waitUntil } from "#test/utils/gameManagerUtils"; +import GameWrapper from "#test/utils/gameWrapper"; +import PhaseInterceptor from "#test/utils/phaseInterceptor"; +import TextInterceptor from "#test/utils/TextInterceptor"; +import { AES, enc } from "crypto-js"; +import fs from "fs"; +import { vi } from "vitest"; +import { ClassicModeHelper } from "./helpers/classicModeHelper"; +import { DailyModeHelper } from "./helpers/dailyModeHelper"; +import { MoveHelper } from "./helpers/moveHelper"; +import { OverridesHelper } from "./helpers/overridesHelper"; +import { SettingsHelper } from "./helpers/settingsHelper"; /** * Class to manage the game state and transitions between phases. @@ -192,38 +192,23 @@ export default class GameManager { } /** - * Emulate a player attack - * @param movePosition the index of the move in the pokemon's moveset array + * Emulate a player's target selection after a move is chosen, usually called automatically by {@linkcode MoveHelper.select}. + * Will trigger during the next {@linkcode SelectTargetPhase} + * @param {BattlerIndex} targetIndex The index of the attack target, or `undefined` for multi-target attacks + * @param movePosition The index of the move in the pokemon's moveset array */ - doAttack(movePosition: integer) { - this.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - this.scene.ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); - }); - this.onNextPrompt("CommandPhase", Mode.FIGHT, () => { - (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); - }); - - // Confirm target selection if move is multi-target + selectTarget(movePosition: integer, targetIndex?: BattlerIndex) { this.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { const handler = this.scene.ui.getHandler() as TargetSelectUiHandler; const move = (this.scene.getCurrentPhase() as SelectTargetPhase).getPokemon().getMoveset()[movePosition]!.getMove(); // TODO: is the bang correct? - if (move.isMultiTarget()) { - handler.processInput(Button.ACTION); + if (!move.isMultiTarget()) { + handler.setCursor(targetIndex !== undefined ? targetIndex : BattlerIndex.ENEMY); + } + if (move.isMultiTarget() && targetIndex !== undefined) { + throw new Error(`targetIndex was passed to selectMove() but move ("${move.name}") is not targetted`); } - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(MovePhase) || this.isCurrentPhase(TurnEndPhase)); - } - - /** - * Emulate a player's target selection after an attack is chosen, - * usually called after {@linkcode doAttack} in a double battle. - * @param {BattlerIndex} targetIndex the index of the attack target - */ - doSelectTarget(targetIndex: BattlerIndex) { - this.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = this.scene.ui.getHandler() as TargetSelectUiHandler; - handler.setCursor(targetIndex); handler.processInput(Button.ACTION); - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnStartPhase)); + }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(MovePhase) || this.isCurrentPhase(TurnStartPhase) || this.isCurrentPhase(TurnEndPhase)); } /** Faint all opponents currently on the field */ @@ -321,7 +306,7 @@ export default class GameManager { */ async importData(path): Promise<[boolean, integer]> { const saveKey = "x0i2O7WRiANTqPmZ"; - const dataRaw = fs.readFileSync(path, {encoding: "utf8", flag: "r"}); + const dataRaw = fs.readFileSync(path, { encoding: "utf8", flag: "r" }); let dataStr = AES.decrypt(dataRaw, saveKey).toString(enc.Utf8); dataStr = this.scene.gameData.convertSystemDataStr(dataStr); const systemData = this.scene.gameData.parseSystemData(dataStr); @@ -335,7 +320,7 @@ export default class GameManager { async killPokemon(pokemon: PlayerPokemon | EnemyPokemon) { (this.scene.time as MockClock).overrideDelay = 0.01; - return new Promise(async(resolve, reject) => { + return new Promise(async (resolve, reject) => { pokemon.hp = 0; this.scene.pushPhase(new FaintPhase(this.scene, pokemon.getBattlerIndex(), true)); await this.phaseInterceptor.to(FaintPhase).catch((e) => reject(e)); diff --git a/src/test/utils/gameManagerUtils.ts b/src/test/utils/gameManagerUtils.ts index dfba55fc75c..20a3fd179fd 100644 --- a/src/test/utils/gameManagerUtils.ts +++ b/src/test/utils/gameManagerUtils.ts @@ -1,12 +1,12 @@ +import BattleScene from "#app/battle-scene"; import { getDailyRunStarters } from "#app/data/daily-run"; import { Gender } from "#app/data/gender"; -import { Species } from "#enums/species"; -import { Starter } from "#app/ui/starter-select-ui-handler"; -import { GameModes, getGameMode } from "#app/game-mode"; import { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; -import { PlayerPokemon } from "#app/field/pokemon"; import { Moves } from "#app/enums/moves"; -import BattleScene from "#app/battle-scene"; +import { PlayerPokemon } from "#app/field/pokemon"; +import { GameModes, getGameMode } from "#app/game-mode"; +import { Starter } from "#app/ui/starter-select-ui-handler"; +import { Species } from "#enums/species"; /** Function to convert Blob to string */ export function blobToString(blob) { diff --git a/src/test/utils/gameWrapper.ts b/src/test/utils/gameWrapper.ts index 49044c260fa..f3098fa9b71 100644 --- a/src/test/utils/gameWrapper.ts +++ b/src/test/utils/gameWrapper.ts @@ -1,31 +1,28 @@ /* eslint-disable */ // @ts-nocheck -import * as main from "#app/main"; +import BattleScene, * as battleScene from "#app/battle-scene"; +import { MoveAnim } from "#app/data/battle-anims"; +import Pokemon from "#app/field/pokemon"; +import * as Utils from "#app/utils"; +import { blobToString } from "#test/utils/gameManagerUtils"; +import { MockClock } from "#test/utils/mocks/mockClock"; +import mockConsoleLog from "#test/utils/mocks/mockConsoleLog"; +import { MockFetch } from "#test/utils/mocks/mockFetch"; +import MockLoader from "#test/utils/mocks/mockLoader"; +import mockLocalStorage from "#test/utils/mocks/mockLocalStorage"; +import MockImage from "#test/utils/mocks/mocksContainer/mockImage"; +import MockTextureManager from "#test/utils/mocks/mockTextureManager"; import fs from "fs"; +import Phaser from "phaser"; +import InputText from "phaser3-rex-plugins/plugins/inputtext"; +import { vi } from "vitest"; +import { MockGameObjectCreator } from "./mocks/mockGameObjectCreator"; import InputManager = Phaser.Input.InputManager; import KeyboardManager = Phaser.Input.Keyboard.KeyboardManager; import KeyboardPlugin = Phaser.Input.Keyboard.KeyboardPlugin; import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin; import EventEmitter = Phaser.Events.EventEmitter; import UpdateList = Phaser.GameObjects.UpdateList; -import MockGraphics from "#test/utils/mocks/mocksContainer/mockGraphics"; -import MockTextureManager from "#test/utils/mocks/mockTextureManager"; -import Phaser from "phaser"; -import { blobToString } from "#test/utils/gameManagerUtils"; -import { vi } from "vitest"; -import mockLocalStorage from "#test/utils/mocks/mockLocalStorage"; -import mockConsoleLog from "#test/utils/mocks/mockConsoleLog"; -import MockLoader from "#test/utils/mocks/mockLoader"; -import { MockFetch } from "#test/utils/mocks/mockFetch"; -import * as Utils from "#app/utils"; -import InputText from "phaser3-rex-plugins/plugins/inputtext"; -import { MockClock } from "#test/utils/mocks/mockClock"; -import BattleScene from "#app/battle-scene.js"; -import { MoveAnim } from "#app/data/battle-anims"; -import Pokemon from "#app/field/pokemon"; -import * as battleScene from "#app/battle-scene"; -import MockImage from "#test/utils/mocks/mocksContainer/mockImage.js"; -import { MockGameObjectCreator } from "./mocks/mockGameObjectCreator"; Object.defineProperty(window, "localStorage", { value: mockLocalStorage(), diff --git a/src/test/utils/helpers/classicModeHelper.ts b/src/test/utils/helpers/classicModeHelper.ts index cf59dd81183..f41472303b4 100644 --- a/src/test/utils/helpers/classicModeHelper.ts +++ b/src/test/utils/helpers/classicModeHelper.ts @@ -1,9 +1,9 @@ -import { Species } from "#app/enums/species.js"; -import { GameModes, getGameMode } from "#app/game-mode.js"; -import overrides from "#app/overrides.js"; -import { EncounterPhase } from "#app/phases/encounter-phase.js"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase.js"; -import { Mode } from "#app/ui/ui.js"; +import { Species } from "#app/enums/species"; +import { GameModes, getGameMode } from "#app/game-mode"; +import overrides from "#app/overrides"; +import { EncounterPhase } from "#app/phases/encounter-phase"; +import { SelectStarterPhase } from "#app/phases/select-starter-phase"; +import { Mode } from "#app/ui/ui"; import { generateStarter } from "../gameManagerUtils"; import { GameManagerHelper } from "./gameManagerHelper"; diff --git a/src/test/utils/helpers/dailyModeHelper.ts b/src/test/utils/helpers/dailyModeHelper.ts index a143e212fcb..8f60981f4d8 100644 --- a/src/test/utils/helpers/dailyModeHelper.ts +++ b/src/test/utils/helpers/dailyModeHelper.ts @@ -1,9 +1,9 @@ -import { Button } from "#app/enums/buttons.js"; -import overrides from "#app/overrides.js"; -import { EncounterPhase } from "#app/phases/encounter-phase.js"; -import { TitlePhase } from "#app/phases/title-phase.js"; -import SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler.js"; -import { Mode } from "#app/ui/ui.js"; +import { Button } from "#app/enums/buttons"; +import overrides from "#app/overrides"; +import { EncounterPhase } from "#app/phases/encounter-phase"; +import { TitlePhase } from "#app/phases/title-phase"; +import SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; +import { Mode } from "#app/ui/ui"; import { GameManagerHelper } from "./gameManagerHelper"; /** diff --git a/src/test/utils/helpers/moveHelper.ts b/src/test/utils/helpers/moveHelper.ts index 3179e63a6d0..a53fa521785 100644 --- a/src/test/utils/helpers/moveHelper.ts +++ b/src/test/utils/helpers/moveHelper.ts @@ -1,6 +1,12 @@ +import { BattlerIndex } from "#app/battle"; +import { Moves } from "#app/enums/moves"; +import { CommandPhase } from "#app/phases/command-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { Command } from "#app/ui/command-ui-handler"; +import { Mode } from "#app/ui/ui"; import { vi } from "vitest"; +import { getMovePosition } from "../gameManagerUtils"; import { GameManagerHelper } from "./gameManagerHelper"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; /** * Helper to handle a Pokemon's move @@ -32,4 +38,25 @@ export class MoveHelper extends GameManagerHelper { hitCheck.mockReturnValue(false); } } + + /** + * Select the move to be used by the given Pokemon(-index). Triggers during the next {@linkcode CommandPhase} + * @param move the move to use + * @param pkmIndex the pokemon index. Relevant for double-battles only (defaults to 0) + * @param targetIndex The {@linkcode BattlerIndex} of the Pokemon to target for single-target moves, or `null` if a manual call to `selectTarget()` is required + */ + select(move: Moves, pkmIndex: 0 | 1 = 0, targetIndex?: BattlerIndex | null) { + const movePosition = getMovePosition(this.game.scene, pkmIndex, move); + + this.game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + this.game.scene.ui.setMode(Mode.FIGHT, (this.game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); + }); + this.game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { + (this.game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); + }); + + if (targetIndex !== null) { + this.game.selectTarget(movePosition, targetIndex); + } + } } diff --git a/src/test/utils/inputsHandler.ts b/src/test/utils/inputsHandler.ts index 148329ada32..30dd101f43d 100644 --- a/src/test/utils/inputsHandler.ts +++ b/src/test/utils/inputsHandler.ts @@ -1,11 +1,11 @@ import BattleScene from "#app/battle-scene"; -import Phaser from "phaser"; -import { InputsController } from "#app/inputs-controller"; import pad_xbox360 from "#app/configs/inputs/pad_xbox360"; -import { holdOn } from "#test/utils/gameManagerUtils"; +import { InputsController } from "#app/inputs-controller"; import TouchControl from "#app/touch-controls"; -import { JSDOM } from "jsdom"; +import { holdOn } from "#test/utils/gameManagerUtils"; import fs from "fs"; +import { JSDOM } from "jsdom"; +import Phaser from "phaser"; interface LogEntry { type: string; diff --git a/src/test/utils/misc.test.ts b/src/test/utils/misc.test.ts index c1947dbe8a2..a49b2894ca2 100644 --- a/src/test/utils/misc.test.ts +++ b/src/test/utils/misc.test.ts @@ -1,8 +1,8 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; import { apiFetch } from "#app/utils"; +import GameManager from "#test/utils/gameManager"; import { waitUntil } from "#test/utils/gameManagerUtils"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; describe("Test misc", () => { let phaserGame: Phaser.Game; diff --git a/src/test/utils/mocks/mockTextureManager.ts b/src/test/utils/mocks/mockTextureManager.ts index 330409e9776..16d94da28ad 100644 --- a/src/test/utils/mocks/mockTextureManager.ts +++ b/src/test/utils/mocks/mockTextureManager.ts @@ -1,12 +1,12 @@ import MockContainer from "#test/utils/mocks/mocksContainer/mockContainer"; -import MockSprite from "#test/utils/mocks/mocksContainer/mockSprite"; -import MockRectangle from "#test/utils/mocks/mocksContainer/mockRectangle"; -import MockNineslice from "#test/utils/mocks/mocksContainer/mockNineslice"; import MockImage from "#test/utils/mocks/mocksContainer/mockImage"; -import MockText from "#test/utils/mocks/mocksContainer/mockText"; +import MockNineslice from "#test/utils/mocks/mocksContainer/mockNineslice"; import MockPolygon from "#test/utils/mocks/mocksContainer/mockPolygon"; -import { MockGameObject } from "./mockGameObject"; +import MockRectangle from "#test/utils/mocks/mocksContainer/mockRectangle"; +import MockSprite from "#test/utils/mocks/mocksContainer/mockSprite"; +import MockText from "#test/utils/mocks/mocksContainer/mockText"; import MockTexture from "#test/utils/mocks/mocksContainer/mockTexture"; +import { MockGameObject } from "./mockGameObject"; /** * Stub class for Phaser.Textures.TextureManager diff --git a/src/test/utils/mocks/mocksContainer/mockSprite.ts b/src/test/utils/mocks/mocksContainer/mockSprite.ts index 9c566fc4bcb..35cd2d5faab 100644 --- a/src/test/utils/mocks/mocksContainer/mockSprite.ts +++ b/src/test/utils/mocks/mocksContainer/mockSprite.ts @@ -1,7 +1,7 @@ +import Phaser from "phaser"; import { MockGameObject } from "../mockGameObject"; import Sprite = Phaser.GameObjects.Sprite; import Frame = Phaser.Textures.Frame; -import Phaser from "phaser"; export default class MockSprite implements MockGameObject { diff --git a/src/test/utils/mocks/mocksContainer/mockTexture.ts b/src/test/utils/mocks/mocksContainer/mockTexture.ts index 03bedb4751b..cb31480cc60 100644 --- a/src/test/utils/mocks/mocksContainer/mockTexture.ts +++ b/src/test/utils/mocks/mocksContainer/mockTexture.ts @@ -1,5 +1,5 @@ -import { MockGameObject } from "../mockGameObject"; import MockTextureManager from "#test/utils/mocks/mockTextureManager"; +import { MockGameObject } from "../mockGameObject"; /** diff --git a/src/test/utils/phaseInterceptor.ts b/src/test/utils/phaseInterceptor.ts index 2304d726757..ca3d55137fa 100644 --- a/src/test/utils/phaseInterceptor.ts +++ b/src/test/utils/phaseInterceptor.ts @@ -1,42 +1,42 @@ -import UI, { Mode } from "#app/ui/ui"; import { Phase } from "#app/phase"; +import { BattleEndPhase } from "#app/phases/battle-end-phase"; +import { BerryPhase } from "#app/phases/berry-phase"; +import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; +import { CommandPhase } from "#app/phases/command-phase"; +import { DamagePhase } from "#app/phases/damage-phase"; +import { EggLapsePhase } from "#app/phases/egg-lapse-phase"; +import { EncounterPhase } from "#app/phases/encounter-phase"; +import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; +import { FaintPhase } from "#app/phases/faint-phase"; +import { LoginPhase } from "#app/phases/login-phase"; +import { MessagePhase } from "#app/phases/message-phase"; +import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import { MoveEndPhase } from "#app/phases/move-end-phase"; +import { MovePhase } from "#app/phases/move-phase"; +import { NewBattlePhase } from "#app/phases/new-battle-phase"; +import { NextEncounterPhase } from "#app/phases/next-encounter-phase"; +import { PartyHealPhase } from "#app/phases/party-heal-phase"; +import { PostSummonPhase } from "#app/phases/post-summon-phase"; +import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; +import { SelectGenderPhase } from "#app/phases/select-gender-phase"; +import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; +import { SelectStarterPhase } from "#app/phases/select-starter-phase"; +import { SelectTargetPhase } from "#app/phases/select-target-phase"; +import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase"; +import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; +import { StatChangePhase } from "#app/phases/stat-change-phase"; +import { SummonPhase } from "#app/phases/summon-phase"; +import { SwitchPhase } from "#app/phases/switch-phase"; +import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; +import { TitlePhase } from "#app/phases/title-phase"; +import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; +import { TurnInitPhase } from "#app/phases/turn-init-phase"; +import { TurnStartPhase } from "#app/phases/turn-start-phase"; +import { UnavailablePhase } from "#app/phases/unavailable-phase"; +import { VictoryPhase } from "#app/phases/victory-phase"; import ErrorInterceptor from "#app/test/utils/errorInterceptor"; -import { BattleEndPhase } from "#app/phases/battle-end-phase.js"; -import { BerryPhase } from "#app/phases/berry-phase.js"; -import { CheckSwitchPhase } from "#app/phases/check-switch-phase.js"; -import { CommandPhase } from "#app/phases/command-phase.js"; -import { DamagePhase } from "#app/phases/damage-phase.js"; -import { EggLapsePhase } from "#app/phases/egg-lapse-phase.js"; -import { EncounterPhase } from "#app/phases/encounter-phase.js"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js"; -import { FaintPhase } from "#app/phases/faint-phase.js"; -import { LoginPhase } from "#app/phases/login-phase.js"; -import { MessagePhase } from "#app/phases/message-phase.js"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; -import { MoveEndPhase } from "#app/phases/move-end-phase.js"; -import { MovePhase } from "#app/phases/move-phase.js"; -import { NewBattlePhase } from "#app/phases/new-battle-phase.js"; -import { NextEncounterPhase } from "#app/phases/next-encounter-phase.js"; -import { PostSummonPhase } from "#app/phases/post-summon-phase.js"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; -import { SelectGenderPhase } from "#app/phases/select-gender-phase.js"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase.js"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase.js"; -import { SelectTargetPhase } from "#app/phases/select-target-phase.js"; -import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase.js"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase.js"; -import { StatChangePhase } from "#app/phases/stat-change-phase.js"; -import { SummonPhase } from "#app/phases/summon-phase.js"; -import { SwitchPhase } from "#app/phases/switch-phase.js"; -import { SwitchSummonPhase } from "#app/phases/switch-summon-phase.js"; -import { TitlePhase } from "#app/phases/title-phase.js"; -import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase.js"; -import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; -import { TurnInitPhase } from "#app/phases/turn-init-phase.js"; -import { TurnStartPhase } from "#app/phases/turn-start-phase.js"; -import { UnavailablePhase } from "#app/phases/unavailable-phase.js"; -import { VictoryPhase } from "#app/phases/victory-phase.js"; -import { PartyHealPhase } from "#app/phases/party-heal-phase.js"; +import UI, { Mode } from "#app/ui/ui"; export default class PhaseInterceptor { public scene; diff --git a/src/test/vitest.setup.ts b/src/test/vitest.setup.ts index b2861b7071c..eaa987c1a66 100644 --- a/src/test/vitest.setup.ts +++ b/src/test/vitest.setup.ts @@ -9,8 +9,8 @@ import { initMoves } from "#app/data/move"; import { initPokemonPrevolutions } from "#app/data/pokemon-evolutions"; import { initPokemonForms } from "#app/data/pokemon-forms"; import { initSpecies } from "#app/data/pokemon-species"; -import { initAchievements } from "#app/system/achv.js"; -import { initVouchers } from "#app/system/voucher.js"; +import { initAchievements } from "#app/system/achv"; +import { initVouchers } from "#app/system/voucher"; import { initStatsKeys } from "#app/ui/game-stats-ui-handler"; import { beforeAll, vi } from "vitest"; diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 016708027ca..bb1f970fe1c 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -12,6 +12,7 @@ import { allMoves } from "../data/move"; import * as Utils from "./../utils"; import Overrides from "#app/overrides"; import i18next from "i18next"; +import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; export const SHOP_OPTIONS_ROW_LIMIT = 6; @@ -249,11 +250,22 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { duration: 250 }); - this.setCursor(0); - this.setRowCursor(1); + const updateCursorTarget = () => { + if (this.scene.shopCursorTarget === ShopCursorTarget.CHECK_TEAM) { + this.setRowCursor(0); + this.setCursor(2); + } else { + this.setRowCursor(this.scene.shopCursorTarget); + this.setCursor(0); + } + }; - handleTutorial(this.scene, Tutorial.Select_Item).then(() => { - this.setCursor(0); + updateCursorTarget(); + + handleTutorial(this.scene, Tutorial.Select_Item).then((res) => { + if (res) { + updateCursorTarget(); + } this.awaitingActionInput = true; this.onActionInput = args[2]; }); diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 67e870838a2..bc809d8c686 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -13,7 +13,7 @@ import { allMoves } from "../data/move"; import { Nature, getNatureName } from "../data/nature"; import { pokemonFormChanges } from "../data/pokemon-forms"; import { LevelMoves, pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "../data/pokemon-level-moves"; -import PokemonSpecies, { allSpecies, getPokemonSpecies, getPokemonSpeciesForm, getStarterValueFriendshipCap, speciesStarters, starterPassiveAbilities } from "../data/pokemon-species"; +import PokemonSpecies, { allSpecies, getPokemonSpeciesForm, getStarterValueFriendshipCap, speciesStarters, starterPassiveAbilities, getPokerusStarters } from "../data/pokemon-species"; import { Type } from "../data/type"; import { GameModes } from "../game-mode"; import { AbilityAttr, DexAttr, DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences, StarterPrefs } from "../system/game-data"; @@ -872,38 +872,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.message.setOrigin(0, 0); this.starterSelectMessageBoxContainer.add(this.message); - const date = new Date(); - date.setUTCHours(0, 0, 0, 0); - - this.scene.executeWithSeedOffset(() => { - for (let c = 0; c < 3; c++) { - let randomSpeciesId: Species; - let species: PokemonSpecies | undefined; - - const generateSpecies = () => { - randomSpeciesId = Utils.randSeedItem(starterSpecies); - species = getPokemonSpecies(randomSpeciesId); - }; - - let dupe = false; - - do { - dupe = false; - - generateSpecies(); - - for (let ps = 0; ps < c; ps++) { - if (this.pokerusSpecies[ps] === species) { - dupe = true; - break; - } - } - } while (dupe); - - this.pokerusSpecies.push(species!); // TODO: is the bang correct? - } - }, 0, date.getTime().toString()); - this.statsContainer = new StatsContainer(this.scene, 6, 16); this.scene.add.existing(this.statsContainer); @@ -934,6 +902,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterPreferences = StarterPrefs.load(); } this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers + this.pokerusSpecies = getPokerusStarters(this.scene); + if (args.length >= 1 && args[0] instanceof Function) { super.show(args); this.starterSelectCallback = args[0] as StarterSelectCallback; diff --git a/src/ui/target-select-ui-handler.ts b/src/ui/target-select-ui-handler.ts index 42c7fef5660..6ca580dc2b2 100644 --- a/src/ui/target-select-ui-handler.ts +++ b/src/ui/target-select-ui-handler.ts @@ -118,7 +118,7 @@ export default class TargetSelectUiHandler extends UiHandler { this.targetFlashTween = this.scene.tweens.add({ targets: this.targetsHighlighted, - key: { start: 0.55, to: 1 }, + key: { start: 1, to: 0.25 }, loop: -1, loopDelay: 150, duration: Utils.fixedInt(450), diff --git a/src/utils.ts b/src/utils.ts index c51ac2b5b0b..a9bbc93d684 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -560,3 +560,17 @@ export function capitalizeString(str: string, sep: string, lowerFirstChar: boole export function isNullOrUndefined(object: any): boolean { return null === object || undefined === object; } + +/** + * This function is used in the context of a Pokémon battle game to calculate the actual integer damage value from a float result. + * Many damage calculation formulas involve various parameters and result in float values. + * The actual damage applied to a Pokémon's HP must be an integer. + * This function helps in ensuring that by flooring the float value and enforcing a minimum damage value. + * + * @param value - The float value to convert. + * @param minValue - The minimum integer value to return. Defaults to 1. + * @returns The converted value as an integer. + */ +export function toDmgValue(value: number, minValue: number = 1) { + return Math.max(Math.floor(value), minValue); +}