Assurance effect implementation

Theoretically implemented for all use cases but only tested for regular damage so far.
pull/301/head
InfernoVulpix 2024-04-25 20:51:04 -04:00 committed by Samuel H
parent 0eabfd56e3
commit d4c265443f
4 changed files with 12 additions and 1 deletions

View File

@ -453,6 +453,7 @@ export class PostDefendDisguiseAbAttr extends PostDefendAbAttr {
if (!recoilDamage) if (!recoilDamage)
return false; return false;
pokemon.damageAndUpdate(recoilDamage, HitResult.OTHER); pokemon.damageAndUpdate(recoilDamage, HitResult.OTHER);
pokemon.turnData.damageTaken += recoilDamage;
pokemon.scene.queueMessage(getPokemonMessage(pokemon, '\'s disguise was busted!')); pokemon.scene.queueMessage(getPokemonMessage(pokemon, '\'s disguise was busted!'));
return true; return true;
} }
@ -733,6 +734,7 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr {
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean {
if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) {
attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER);
attacker.turnData.damageTaken += Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio));
return true; return true;
} }
@ -2070,6 +2072,7 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr {
return false; return false;
} }
attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER);
attacker.turnData.damageTaken += Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio));
return true; return true;
} }

View File

@ -252,6 +252,7 @@ class SpikesTag extends ArenaTrapTag {
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' is hurt\nby the spikes!')); pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' is hurt\nby the spikes!'));
pokemon.damageAndUpdate(damage, HitResult.OTHER); pokemon.damageAndUpdate(damage, HitResult.OTHER);
pokemon.turnData.damageTaken += damage;
return true; return true;
} }
} }
@ -382,6 +383,7 @@ class StealthRockTag extends ArenaTrapTag {
const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio); const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio);
pokemon.scene.queueMessage(`Pointed stones dug into\n${pokemon.name}!`); pokemon.scene.queueMessage(`Pointed stones dug into\n${pokemon.name}!`);
pokemon.damageAndUpdate(damage, HitResult.OTHER); pokemon.damageAndUpdate(damage, HitResult.OTHER);
pokemon.turnData.damageTaken += damage;
} }
return false; return false;

View File

@ -695,6 +695,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(getPokemonMessage(user, ' is hit\nwith recoil!')); user.scene.queueMessage(getPokemonMessage(user, ' is hit\nwith recoil!'));
user.turnData.damageTaken += recoilDamage;
return true; return true;
} }
@ -714,6 +715,7 @@ export class SacrificialAttr extends MoveEffectAttr {
return false; return false;
user.damageAndUpdate(user.hp, HitResult.OTHER, false, true, true); user.damageAndUpdate(user.hp, HitResult.OTHER, false, true, true);
user.turnData.damageTaken += user.hp;
return true; return true;
} }
@ -884,6 +886,7 @@ export class HitHealAttr extends MoveEffectAttr {
!reverseDrain ? healAmount : healAmount * -1, !reverseDrain ? healAmount : healAmount * -1,
!reverseDrain ? getPokemonMessage(target, ` had its\nenergy drained!`) : undefined, !reverseDrain ? getPokemonMessage(target, ` had its\nenergy drained!`) : undefined,
false, true)); false, true));
if (reverseDrain) user.turnData.damageTaken += healAmount;
return true; return true;
} }
@ -2392,6 +2395,7 @@ const crashDamageFunc = (user: Pokemon, move: Move) => {
user.damageAndUpdate(Math.floor(user.getMaxHp() / 2), HitResult.OTHER, false, true); user.damageAndUpdate(Math.floor(user.getMaxHp() / 2), HitResult.OTHER, false, true);
user.scene.queueMessage(getPokemonMessage(user, ' kept going\nand crashed!')); user.scene.queueMessage(getPokemonMessage(user, ' kept going\nand crashed!'));
user.turnData.damageTaken += Math.floor(user.getMaxHp() / 2);
return true; return true;
}; };
@ -4741,7 +4745,7 @@ export function initMoves() {
new AttackMove(Moves.PAYBACK, Type.DARK, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 4) new AttackMove(Moves.PAYBACK, Type.DARK, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 4)
.attr(MovePowerMultiplierAttr, (user, target, move) => target.getLastXMoves(1).find(m => m.turn === target.scene.currentBattle.turn) || user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command === Command.BALL ? 2 : 1), .attr(MovePowerMultiplierAttr, (user, target, move) => target.getLastXMoves(1).find(m => m.turn === target.scene.currentBattle.turn) || user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command === Command.BALL ? 2 : 1),
new AttackMove(Moves.ASSURANCE, Type.DARK, MoveCategory.PHYSICAL, 60, 100, 10, -1, 0, 4) new AttackMove(Moves.ASSURANCE, Type.DARK, MoveCategory.PHYSICAL, 60, 100, 10, -1, 0, 4)
.partial(), .attr(MovePowerMultiplierAttr, (user, target, move) => target.turnData.damageTaken > 0 ? 2 : 1),
new StatusMove(Moves.EMBARGO, Type.DARK, 100, 15, -1, 0, 4) new StatusMove(Moves.EMBARGO, Type.DARK, 100, 15, -1, 0, 4)
.unimplemented(), .unimplemented(),
new AttackMove(Moves.FLING, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4) new AttackMove(Moves.FLING, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4)

View File

@ -1390,6 +1390,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const oneHitKo = result === HitResult.ONE_HIT_KO; const oneHitKo = result === HitResult.ONE_HIT_KO;
damage.value = this.damageAndUpdate(damage.value, result as DamageResult, isCritical, oneHitKo, oneHitKo); damage.value = this.damageAndUpdate(damage.value, result as DamageResult, isCritical, oneHitKo, oneHitKo);
this.turnData.damageTaken += damage.value;
if (isCritical) if (isCritical)
this.scene.queueMessage('A critical hit!'); this.scene.queueMessage('A critical hit!');
this.scene.setPhaseQueueSplice(); this.scene.setPhaseQueueSplice();
@ -2976,6 +2977,7 @@ export class PokemonTurnData {
public hitCount: integer; public hitCount: integer;
public hitsLeft: integer; public hitsLeft: integer;
public damageDealt: integer = 0; public damageDealt: integer = 0;
public damageTaken: integer = 0;
public attacksReceived: AttackMoveResult[] = []; public attacksReceived: AttackMoveResult[] = [];
} }