This commit is contained in:
Benjamin 2024-10-25 04:22:07 -04:00
parent 0fe57b44b5
commit 05fcf58139
7 changed files with 134 additions and 2 deletions

View File

@ -3343,6 +3343,7 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr {
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName })); scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }));
pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER); pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER);
pokemon.turnData.lastDmgSrc = WeatherType.HARSH_SUN;
} }
return true; return true;

View File

@ -1352,6 +1352,7 @@ export class RecoilAttr extends MoveEffectAttr {
user.damageAndUpdate(recoilDamage, HitResult.OTHER, false, true, true); user.damageAndUpdate(recoilDamage, HitResult.OTHER, false, true, true);
user.scene.queueMessage(i18next.t("moveTriggers:hitWithRecoil", { pokemonName: getPokemonNameWithAffix(user) })); user.scene.queueMessage(i18next.t("moveTriggers:hitWithRecoil", { pokemonName: getPokemonNameWithAffix(user) }));
user.turnData.damageTaken += recoilDamage; user.turnData.damageTaken += recoilDamage;
user.turnData.lastDmgSrc = user.id;
return true; return true;
} }

View File

@ -2796,6 +2796,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.battleData.hitCount++; this.battleData.hitCount++;
const attackResult = { move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() }; const attackResult = { move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() };
this.turnData.attacksReceived.unshift(attackResult); this.turnData.attacksReceived.unshift(attackResult);
this.turnData.lastDmgSrc = source;
if (source.isPlayer() && !this.isPlayer()) { if (source.isPlayer() && !this.isPlayer()) {
this.scene.applyModifiers(DamageMoneyRewardModifier, true, source, new Utils.NumberHolder(damage)); this.scene.applyModifiers(DamageMoneyRewardModifier, true, source, new Utils.NumberHolder(damage));
} }
@ -5125,6 +5126,7 @@ export class PokemonTurnData {
public statStagesDecreased: boolean = false; public statStagesDecreased: boolean = false;
public moveEffectiveness: TypeDamageMultiplier | null = null; public moveEffectiveness: TypeDamageMultiplier | null = null;
public combiningPledge?: Moves; public combiningPledge?: Moves;
public lastDmgSrc: Pokemon | WeatherType | StatusEffect;
} }
export enum AiType { export enum AiType {

View File

@ -96,8 +96,9 @@ export class FaintPhase extends PokemonPhase {
const alivePlayField = this.scene.getField(true); const alivePlayField = this.scene.getField(true);
alivePlayField.forEach(p => applyPostKnockOutAbAttrs(PostKnockOutAbAttr, p, pokemon)); alivePlayField.forEach(p => applyPostKnockOutAbAttrs(PostKnockOutAbAttr, p, pokemon));
if (pokemon.turnData?.attacksReceived?.length) { if (pokemon.turnData?.attacksReceived?.length) {
const defeatSource = this.scene.getPokemonById(pokemon.turnData.attacksReceived[0].sourceId); const defeatSource = pokemon.turnData.lastDmgSrc;
if (defeatSource?.isOnField()) {
if (defeatSource instanceof Pokemon && defeatSource?.isOnField()) {
applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource); applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource);
const pvmove = allMoves[pokemon.turnData.attacksReceived[0].move]; const pvmove = allMoves[pokemon.turnData.attacksReceived[0].move];
const pvattrs = pvmove.getAttrs(PostVictoryStatStageChangeAttr); const pvattrs = pvmove.getAttrs(PostVictoryStatStageChangeAttr);

View File

@ -28,13 +28,16 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
switch (pokemon.status.effect) { switch (pokemon.status.effect) {
case StatusEffect.POISON: case StatusEffect.POISON:
damage.value = Math.max(pokemon.getMaxHp() >> 3, 1); damage.value = Math.max(pokemon.getMaxHp() >> 3, 1);
pokemon.turnData.lastDmgSrc = StatusEffect.POISON;
break; break;
case StatusEffect.TOXIC: case StatusEffect.TOXIC:
damage.value = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.toxicTurnCount), 1); damage.value = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.toxicTurnCount), 1);
pokemon.turnData.lastDmgSrc = StatusEffect.TOXIC;
break; break;
case StatusEffect.BURN: case StatusEffect.BURN:
damage.value = Math.max(pokemon.getMaxHp() >> 4, 1); damage.value = Math.max(pokemon.getMaxHp() >> 4, 1);
applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage); applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage);
pokemon.turnData.lastDmgSrc = StatusEffect.BURN;
break; break;
} }
if (damage.value) { if (damage.value) {

View File

@ -54,6 +54,9 @@ export class WeatherEffectPhase extends CommonAnimPhase {
const immune = !pokemon || !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length; const immune = !pokemon || !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length;
if (!immune) { if (!immune) {
inflictDamage(pokemon); inflictDamage(pokemon);
if (this.weather?.weatherType) {
pokemon.turnData.lastDmgSrc = this.weather.weatherType;
}
} }
}); });
} }

View File

@ -0,0 +1,121 @@
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "../utils/gameManager";
import { Species } from "#enums/species";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Stat } from "#enums/stat";
import { StatusEffect } from "#app/enums/status-effect";
import { WeatherType } from "#app/enums/weather-type";
describe("Moves - Fell Stinger", () => {
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")
.moveset([ Moves.FELL_STINGER ])
.startingLevel(50);
game.override.enemyAbility(Abilities.STURDY)
.enemySpecies(Species.HYPNO)
.enemyLevel(5)
.enemyHeldItems([]);
game.override.weather(WeatherType.NONE);
});
it("should not grant stat boost when opponent gets KO'd by recoil", async () => {
game.override.enemyMoveset([ Moves.DOUBLE_EDGE ]);
await game.classicMode.startBattle([ Species.LEAVANNY ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.FELL_STINGER);
await game.phaseInterceptor.to("VictoryPhase");
expect(leadPokemon.getStatStage(Stat.ATK) === 0); // Attack stage should still be at 0
});
it("should not grant stat boost when enemy is KO'd by status effect", async () => {
game.override
.enemyMoveset(Moves.SPLASH)
.enemyStatusEffect(StatusEffect.BURN);
await game.classicMode.startBattle([ Species.LEAVANNY ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.FELL_STINGER);
await game.phaseInterceptor.to("VictoryPhase");
expect(leadPokemon.getStatStage(Stat.ATK) === 0); // Attack stage should still be at 0
});
it("should not grant stat boost when enemy is KO'd by damaging weather", async () => {
game.override.weather(WeatherType.HAIL);
await game.classicMode.startBattle([ Species.LEAVANNY ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.FELL_STINGER);
await game.phaseInterceptor.to("VictoryPhase");
expect(leadPokemon.getStatStage(Stat.ATK) === 0); // Attack stage should still be at 0
});
it("should not grant stat boost when enemy is KO'd by Dry Skin + Harsh Sunlight", async () => {
game.override
.enemyPassiveAbility(Abilities.STURDY)
.enemyAbility(Abilities.DRY_SKIN)
.weather(WeatherType.HARSH_SUN);
await game.challengeMode.startBattle([ Species.LEAVANNY ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.FELL_STINGER);
await game.phaseInterceptor.to("VictoryPhase");
expect(leadPokemon.getStatStage(Stat.ATK) === 0); // Attack stage should still be at 0
});
it("should not grant stat boost if enemy is saved by Reviver Seed", async () => {
game.override
.enemyAbility(Abilities.KLUTZ)
.enemyHeldItems([{ name: "REVIVER_SEED" }]);
await game.classicMode.startBattle([ Species.LEAVANNY ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.FELL_STINGER);
await game.phaseInterceptor.to("TurnEndPhase");
expect(leadPokemon.getStatStage(Stat.ATK) === 0); // Attack stage should still be at 0
});
it("should grant stat boost when enemy dies directly to hit", async () => {
game.override.enemyAbility(Abilities.KLUTZ);
await game.challengeMode.startBattle([ Species.LEAVANNY ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.FELL_STINGER);
await game.phaseInterceptor.to("VictoryPhase");
expect(leadPokemon.getStatStage(Stat.ATK) === 3); // Attack stage should have risen to 3
});
});