mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Fix injective field position indexing (#11789)
This commit is contained in:
parent
cf8cbd8f5d
commit
f494d48434
|
|
@ -180,7 +180,7 @@ export class BattleActions {
|
|||
}
|
||||
const allActive = this.battle.getAllActive(true);
|
||||
this.battle.speedSort(allActive);
|
||||
this.battle.speedOrder = allActive.map(a => a.side.n * a.battle.sides.length + a.position);
|
||||
this.battle.speedOrder = allActive.map(a => a.getFieldPositionValue());
|
||||
this.battle.fieldEvent('SwitchIn', switchersIn);
|
||||
|
||||
for (const poke of switchersIn) {
|
||||
|
|
|
|||
|
|
@ -1009,8 +1009,7 @@ export class Battle {
|
|||
// Pokemon speeds including ties are resolved before all onSwitchIn handlers and aren't re-sorted in-between
|
||||
// so we subtract a fractional speed from each Pokemon's respective event handlers by using the index of their
|
||||
// unique field position in a pre-sorted-by-speed array
|
||||
const fieldPositionValue = pokemon.side.n * this.sides.length + pokemon.position;
|
||||
handler.speed -= this.speedOrder.indexOf(fieldPositionValue) / (this.activePerHalf * 2);
|
||||
handler.speed -= this.speedOrder.indexOf(pokemon.getFieldPositionValue()) / (this.activePerHalf * 2);
|
||||
}
|
||||
}
|
||||
return handler;
|
||||
|
|
|
|||
|
|
@ -518,6 +518,11 @@ export class Pokemon {
|
|||
return (this.side.id + positionLetter) as PokemonSlot;
|
||||
}
|
||||
|
||||
getFieldPositionValue() {
|
||||
// p1a, p2a, p3a, ..., p1b, p2b, p3b, ...
|
||||
return this.side.n + this.battle.sides.length * this.position;
|
||||
}
|
||||
|
||||
toString() {
|
||||
const fullname = (this.illusion) ? this.illusion.fullname : this.fullname;
|
||||
return this.isActive ? this.getSlot() + fullname.slice(2) : fullname;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user