mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Always create separate ability phases for passive and use boolean instead of priority number when applying
This commit is contained in:
parent
68ca7c1ff3
commit
ccdfd09cfb
@ -5172,7 +5172,6 @@ function applySingleAbAttrs<TAttr extends AbAttr>(
|
||||
args: any[],
|
||||
gainedMidTurn = false,
|
||||
simulated = false,
|
||||
priorityCondition?: (p: number) => boolean,
|
||||
messages: string[] = []
|
||||
) {
|
||||
if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) {
|
||||
@ -5180,10 +5179,7 @@ function applySingleAbAttrs<TAttr extends AbAttr>(
|
||||
}
|
||||
|
||||
const ability = passive ? pokemon.getPassiveAbility() : pokemon.getAbility();
|
||||
if (
|
||||
gainedMidTurn && ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain())
|
||||
|| (priorityCondition && !priorityCondition(ability.postSummonPriority))
|
||||
) {
|
||||
if (gainedMidTurn && ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5485,7 +5481,6 @@ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr {
|
||||
* @param simulated `true` if the call is simulated and the battle state should not be changes
|
||||
* @param messages Array of messages which will be added to if the ability displays a message
|
||||
* @param gainedMidTurn `true` if the ability is activating because it was gained during the battle
|
||||
* @param priorityCondition If defined, only abilities with priority that meets the condition will be applied
|
||||
*/
|
||||
function applyAbAttrsInternal<TAttr extends AbAttr>(
|
||||
attrType: Constructor<TAttr>,
|
||||
@ -5496,11 +5491,10 @@ function applyAbAttrsInternal<TAttr extends AbAttr>(
|
||||
simulated: boolean = false,
|
||||
messages: string[] = [],
|
||||
gainedMidTurn = false,
|
||||
priorityCondition?: (p: number) => boolean
|
||||
) {
|
||||
for (const passive of [ false, true ]) {
|
||||
if (pokemon) {
|
||||
applySingleAbAttrs(pokemon, passive, attrType, applyFunc, successFunc, args, gainedMidTurn, simulated, priorityCondition, messages);
|
||||
applySingleAbAttrs(pokemon, passive, attrType, applyFunc, successFunc, args, gainedMidTurn, simulated, messages);
|
||||
globalScene.clearPhaseQueueSplice();
|
||||
}
|
||||
}
|
||||
@ -5746,20 +5740,19 @@ export function applyPostVictoryAbAttrs(
|
||||
export function applyPostSummonAbAttrs(
|
||||
attrType: Constructor<PostSummonAbAttr>,
|
||||
pokemon: Pokemon,
|
||||
passive = false,
|
||||
simulated = false,
|
||||
priorityCondition?: (p: number) => boolean,
|
||||
...args: any[]
|
||||
): void {
|
||||
applyAbAttrsInternal<PostSummonAbAttr>(
|
||||
attrType,
|
||||
applySingleAbAttrs<PostSummonAbAttr>(
|
||||
pokemon,
|
||||
passive,
|
||||
attrType,
|
||||
(attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args),
|
||||
(attr, passive) => attr.canApplyPostSummon(pokemon, passive, simulated, args),
|
||||
args,
|
||||
simulated,
|
||||
[],
|
||||
false,
|
||||
priorityCondition
|
||||
simulated
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
||||
private queueAbilityPhase(phase: PostSummonPhase): void {
|
||||
const phasePokemon = phase.getPokemon();
|
||||
|
||||
phasePokemon.getAbilityPriorities().forEach(priority => {
|
||||
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority));
|
||||
phasePokemon.getAbilityPriorities().forEach((priority, idx) => {
|
||||
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx));
|
||||
globalScene.appendToPhase(
|
||||
new ActivatePriorityQueuePhase(DynamicPhaseType.POST_SUMMON),
|
||||
ActivatePriorityQueuePhase,
|
||||
|
@ -2265,8 +2265,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getAbilityPriorities(): Set<number> {
|
||||
return new Set([ this.getAbility().postSummonPriority, this.getPassiveAbility().postSummonPriority ]);
|
||||
public getAbilityPriorities(): number[] {
|
||||
return [this.getAbility().postSummonPriority, this.getPassiveAbility().postSummonPriority];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,22 +40,20 @@ export class PostSummonPhase extends PokemonPhase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Phase to apply (post-summon) ability attributes for abilities with nonzero priority
|
||||
*
|
||||
* Priority abilities activate before others and before hazards
|
||||
*
|
||||
* @see Example - {@link https://bulbapedia.bulbagarden.net/wiki/Neutralizing_Gas_(Ability) | Neutralizing Gas}
|
||||
* Helper to {@linkcode PostSummonPhase} which applies abilities
|
||||
*/
|
||||
export class PostSummonActivateAbilityPhase extends PostSummonPhase {
|
||||
private priority: number;
|
||||
private passive: boolean;
|
||||
|
||||
constructor(battlerIndex: BattlerIndex, priority: number) {
|
||||
constructor(battlerIndex: BattlerIndex, priority: number, passive: boolean) {
|
||||
super(battlerIndex);
|
||||
this.priority = priority;
|
||||
this.passive = passive;
|
||||
}
|
||||
|
||||
start() {
|
||||
applyPostSummonAbAttrs(PostSummonAbAttr, this.getPokemon(), false, (p: number) => p === this.priority);
|
||||
applyPostSummonAbAttrs(PostSummonAbAttr, this.getPokemon(), this.passive, false);
|
||||
|
||||
this.end();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user