mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 15:33:29 +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 {
|
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;
|
const category = allMoves[ar.move].category;
|
||||||
return (category !== MoveCategory.STATUS || areAllies(user.getBattlerIndex(), ar.sourceBattlerIndex))
|
return (
|
||||||
})
|
category !== MoveCategory.STATUS
|
||||||
let damage = 0;
|
&& !areAllies(user.getBattlerIndex(), ar.sourceBattlerIndex)
|
||||||
const userBattlerIndex = user.getBattlerIndex();
|
&& (this.moveFilter === undefined || category === this.moveFilter)
|
||||||
for (const ar of user.turnData.attacksReceived) {
|
)
|
||||||
// TODO: Adjust this for moves with variable damage categories
|
})?.damage ?? 0;
|
||||||
const category = allMoves[ar.move].category;
|
|
||||||
if (category === MoveCategory.STATUS
|
|
||||||
|| areAllies(userBattlerIndex, ar.sourceBattlerIndex)
|
|
||||||
|| (this.moveFilter && category !== this.moveFilter)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
damage = ar.damage;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(args[0] as NumberHolder).value = toDmgValue(damage * this.multiplier);
|
(args[0] as NumberHolder).value = toDmgValue(damage * this.multiplier);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -909,7 +909,6 @@ export class MovePhase extends PokemonPhase {
|
|||||||
*/
|
*/
|
||||||
protected resolveCounterAttackTarget(): void {
|
protected resolveCounterAttackTarget(): void {
|
||||||
if (this.targets.length !== 1 || this.targets[0] !== BattlerIndex.ATTACKER) {
|
if (this.targets.length !== 1 || this.targets[0] !== BattlerIndex.ATTACKER) {
|
||||||
console.log("%cSkipping counter attack target resolution", "color: blue");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user