[Bug] Fixed Super Fang interaction with Multi Lens (#4914)
Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
3bf2059aaf
commit
5fed690187
|
@ -1385,14 +1385,38 @@ export class UserHpDamageAttr extends FixedDamageAttr {
|
|||
}
|
||||
|
||||
export class TargetHalfHpDamageAttr extends FixedDamageAttr {
|
||||
// the initial amount of hp the target had before the first hit
|
||||
// used for multi lens
|
||||
private initialHp: number;
|
||||
constructor() {
|
||||
super(0);
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
(args[0] as Utils.IntegerHolder).value = Utils.toDmgValue(target.hp / 2);
|
||||
// first, determine if the hit is coming from multi lens or not
|
||||
const lensCount = user.getHeldItems().find(i => i instanceof PokemonMultiHitModifier)?.getStackCount() ?? 0;
|
||||
if (lensCount <= 0) {
|
||||
// no multi lenses; we can just halve the target's hp and call it a day
|
||||
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(target.hp / 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
// figure out what hit # we're on
|
||||
switch (user.turnData.hitCount - user.turnData.hitsLeft) {
|
||||
case 0:
|
||||
// first hit of move; update initialHp tracker
|
||||
this.initialHp = target.hp;
|
||||
default:
|
||||
// multi lens added hit; use initialHp tracker to ensure correct damage
|
||||
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(this.initialHp / 2);
|
||||
return true;
|
||||
break;
|
||||
case lensCount + 1:
|
||||
// parental bond added hit; calc damage as normal
|
||||
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(target.hp / 2);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
|
||||
|
|
|
@ -2618,8 +2618,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
};
|
||||
}
|
||||
|
||||
// If the attack deals fixed damaged, return a result with that much damage
|
||||
const fixedDamage = new Utils.IntegerHolder(0);
|
||||
// If the attack deals fixed damage, return a result with that much damage
|
||||
const fixedDamage = new Utils.NumberHolder(0);
|
||||
applyMoveAttrs(FixedDamageAttr, source, this, move, fixedDamage);
|
||||
if (fixedDamage.value) {
|
||||
const multiLensMultiplier = new Utils.NumberHolder(1);
|
||||
|
|
|
@ -135,4 +135,57 @@ describe("Items - Multi Lens", () => {
|
|||
expect(damageResults[0]).toBe(Math.floor(playerPokemon.level * 0.75));
|
||||
expect(damageResults[1]).toBe(Math.floor(playerPokemon.level * 0.25));
|
||||
});
|
||||
|
||||
it("should result in correct damage for hp% attacks with 1 lens", async () => {
|
||||
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }])
|
||||
.moveset(Moves.SUPER_FANG)
|
||||
.ability(Abilities.COMPOUND_EYES)
|
||||
.enemyLevel(1000)
|
||||
.enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy
|
||||
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.SUPER_FANG);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 5);
|
||||
});
|
||||
|
||||
it("should result in correct damage for hp% attacks with 2 lenses", async () => {
|
||||
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }])
|
||||
.moveset(Moves.SUPER_FANG)
|
||||
.ability(Abilities.COMPOUND_EYES)
|
||||
.enemyMoveset(Moves.SPLASH)
|
||||
.enemyLevel(1000)
|
||||
.enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy
|
||||
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.SUPER_FANG);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 5);
|
||||
});
|
||||
it("should result in correct damage for hp% attacks with 2 lenses + Parental Bond", async () => {
|
||||
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }])
|
||||
.moveset(Moves.SUPER_FANG)
|
||||
.ability(Abilities.PARENTAL_BOND)
|
||||
.passiveAbility(Abilities.COMPOUND_EYES)
|
||||
.enemyMoveset(Moves.SPLASH)
|
||||
.enemyLevel(1000)
|
||||
.enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy
|
||||
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.SUPER_FANG);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.25, 5);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue