mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +02:00
Adjust counter attr to use array.find
This commit is contained in:
parent
8feaa8c86b
commit
5c7c87e075
@ -1818,25 +1818,15 @@ export class CounterDamageAttr extends FixedDamageAttr {
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
user.turnData.attacksReceived.find(ar => {
|
||||
const damage = user.turnData.attacksReceived.find(ar => {
|
||||
const category = allMoves[ar.move].category;
|
||||
return (category !== MoveCategory.STATUS || areAllies(user.getBattlerIndex(), ar.sourceBattlerIndex))
|
||||
})
|
||||
let damage = 0;
|
||||
const userBattlerIndex = user.getBattlerIndex();
|
||||
for (const ar of user.turnData.attacksReceived) {
|
||||
// TODO: Adjust this for moves with variable damage categories
|
||||
const category = allMoves[ar.move].category;
|
||||
if (category === MoveCategory.STATUS
|
||||
|| areAllies(userBattlerIndex, ar.sourceBattlerIndex)
|
||||
|| (this.moveFilter && category !== this.moveFilter)) {
|
||||
continue;
|
||||
}
|
||||
damage = ar.damage;
|
||||
break;
|
||||
}
|
||||
return (
|
||||
category !== MoveCategory.STATUS
|
||||
&& !areAllies(user.getBattlerIndex(), ar.sourceBattlerIndex)
|
||||
&& (this.moveFilter === undefined || category === this.moveFilter)
|
||||
)
|
||||
})?.damage ?? 0;
|
||||
(args[0] as NumberHolder).value = toDmgValue(damage * this.multiplier);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -909,7 +909,6 @@ export class MovePhase extends PokemonPhase {
|
||||
*/
|
||||
protected resolveCounterAttackTarget(): void {
|
||||
if (this.targets.length !== 1 || this.targets[0] !== BattlerIndex.ATTACKER) {
|
||||
console.log("%cSkipping counter attack target resolution", "color: blue");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user