Fixed embarassing bug thing

This commit is contained in:
Bertie690 2024-11-18 22:46:35 -05:00
parent 6605ffc2aa
commit 52c9e4717c
2 changed files with 7 additions and 24 deletions

View File

@ -2624,13 +2624,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (fixedDamage.value) { if (fixedDamage.value) {
const lensCount = source.getHeldItems().find(i => i instanceof PokemonMultiHitModifier)?.getStackCount() ?? 0; const lensCount = source.getHeldItems().find(i => i instanceof PokemonMultiHitModifier)?.getStackCount() ?? 0;
// Apply damage fixing for hp cutting moves on multi lens hits (NOT PARENTAL BOND) // Apply damage fixing for hp cutting moves on multi lens hits (NOT PARENTAL BOND)
if (move.hasAttr(TargetHalfHpDamageAttr) if (lensCount > 0
&& move.hasAttr(TargetHalfHpDamageAttr)
&& (source.turnData.hitCount === source.turnData.hitsLeft && (source.turnData.hitCount === source.turnData.hitsLeft
|| source.turnData.hitCount - source.turnData.hitsLeft !== lensCount + 1)) { || source.turnData.hitCount - source.turnData.hitsLeft !== lensCount + 1)) {
// Do some unholy math to make the moves' damage values add up to 50% // Do some unholy math to make the moves' damage values add up to 50%
// Values obtained courtesy of WolframAlpha and Desmos Graphing Calculator // Values obtained courtesy of WolframAlpha and Desmos Graphing Calculator
// (https://www.desmos.com/calculator/wdngrksdfz) // (https://www.desmos.com/calculator/wdngrksdfz)
let damageMulti = 0; let damageMulti = 1;
// NOTE: If multi lens ever gets updated (again) this switch case will NEED to be updated alongside it! // NOTE: If multi lens ever gets updated (again) this switch case will NEED to be updated alongside it!
switch (lensCount) { switch (lensCount) {
case 1: case 1:
@ -2639,8 +2640,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
case 2: case 2:
damageMulti = 0.60875846088; damageMulti = 0.60875846088;
break; break;
case 3: default:
damageMulti = 0.636414338985; damageMulti = 0.5;
break; break;
} }

View File

@ -170,26 +170,8 @@ describe("Items - Multi Lens", () => {
await game.phaseInterceptor.to("MoveEndPhase"); await game.phaseInterceptor.to("MoveEndPhase");
expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 8); // unrealistically high level of precision expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 8); // unrealistically high level of precision
}); });
it("should result in correct damage for hp% attacks with 2 lenses + Parental Bond", async () => {
it("should result in correct damage for hp% attacks with 3 lenses", async () => { game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 },
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 3 }])
.moveset(Moves.SUPER_FANG)
.ability(Abilities.COMPOUND_EYES)
.enemyMoveset(Moves.SPLASH)
.enemyLevel(100000)
.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, 8);
});
it("should result in correct damage for hp% attacks with 3 lenses + Parental Bond", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 3 },
{ name: "WIDE_LENS", count: 2 }]) // ensures move always hits { name: "WIDE_LENS", count: 2 }]) // ensures move always hits
.moveset(Moves.SUPER_FANG) .moveset(Moves.SUPER_FANG)
.ability(Abilities.PARENTAL_BOND) .ability(Abilities.PARENTAL_BOND)