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[],
|
args: any[],
|
||||||
gainedMidTurn = false,
|
gainedMidTurn = false,
|
||||||
simulated = false,
|
simulated = false,
|
||||||
priorityCondition?: (p: number) => boolean,
|
|
||||||
messages: string[] = []
|
messages: string[] = []
|
||||||
) {
|
) {
|
||||||
if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) {
|
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();
|
const ability = passive ? pokemon.getPassiveAbility() : pokemon.getAbility();
|
||||||
if (
|
if (gainedMidTurn && ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain())) {
|
||||||
gainedMidTurn && ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain())
|
|
||||||
|| (priorityCondition && !priorityCondition(ability.postSummonPriority))
|
|
||||||
) {
|
|
||||||
return;
|
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 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 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 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>(
|
function applyAbAttrsInternal<TAttr extends AbAttr>(
|
||||||
attrType: Constructor<TAttr>,
|
attrType: Constructor<TAttr>,
|
||||||
@ -5496,11 +5491,10 @@ function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||||||
simulated: boolean = false,
|
simulated: boolean = false,
|
||||||
messages: string[] = [],
|
messages: string[] = [],
|
||||||
gainedMidTurn = false,
|
gainedMidTurn = false,
|
||||||
priorityCondition?: (p: number) => boolean
|
|
||||||
) {
|
) {
|
||||||
for (const passive of [ false, true ]) {
|
for (const passive of [ false, true ]) {
|
||||||
if (pokemon) {
|
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();
|
globalScene.clearPhaseQueueSplice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5746,20 +5740,19 @@ export function applyPostVictoryAbAttrs(
|
|||||||
export function applyPostSummonAbAttrs(
|
export function applyPostSummonAbAttrs(
|
||||||
attrType: Constructor<PostSummonAbAttr>,
|
attrType: Constructor<PostSummonAbAttr>,
|
||||||
pokemon: Pokemon,
|
pokemon: Pokemon,
|
||||||
|
passive = false,
|
||||||
simulated = false,
|
simulated = false,
|
||||||
priorityCondition?: (p: number) => boolean,
|
|
||||||
...args: any[]
|
...args: any[]
|
||||||
): void {
|
): void {
|
||||||
applyAbAttrsInternal<PostSummonAbAttr>(
|
applySingleAbAttrs<PostSummonAbAttr>(
|
||||||
attrType,
|
|
||||||
pokemon,
|
pokemon,
|
||||||
|
passive,
|
||||||
|
attrType,
|
||||||
(attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args),
|
(attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args),
|
||||||
(attr, passive) => attr.canApplyPostSummon(pokemon, passive, simulated, args),
|
(attr, passive) => attr.canApplyPostSummon(pokemon, passive, simulated, args),
|
||||||
args,
|
args,
|
||||||
simulated,
|
|
||||||
[],
|
|
||||||
false,
|
false,
|
||||||
priorityCondition
|
simulated
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
|||||||
private queueAbilityPhase(phase: PostSummonPhase): void {
|
private queueAbilityPhase(phase: PostSummonPhase): void {
|
||||||
const phasePokemon = phase.getPokemon();
|
const phasePokemon = phase.getPokemon();
|
||||||
|
|
||||||
phasePokemon.getAbilityPriorities().forEach(priority => {
|
phasePokemon.getAbilityPriorities().forEach((priority, idx) => {
|
||||||
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority));
|
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx));
|
||||||
globalScene.appendToPhase(
|
globalScene.appendToPhase(
|
||||||
new ActivatePriorityQueuePhase(DynamicPhaseType.POST_SUMMON),
|
new ActivatePriorityQueuePhase(DynamicPhaseType.POST_SUMMON),
|
||||||
ActivatePriorityQueuePhase,
|
ActivatePriorityQueuePhase,
|
||||||
|
@ -2265,8 +2265,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAbilityPriorities(): Set<number> {
|
public getAbilityPriorities(): number[] {
|
||||||
return new Set([ this.getAbility().postSummonPriority, this.getPassiveAbility().postSummonPriority ]);
|
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
|
* Helper to {@linkcode PostSummonPhase} which applies abilities
|
||||||
*
|
|
||||||
* Priority abilities activate before others and before hazards
|
|
||||||
*
|
|
||||||
* @see Example - {@link https://bulbapedia.bulbagarden.net/wiki/Neutralizing_Gas_(Ability) | Neutralizing Gas}
|
|
||||||
*/
|
*/
|
||||||
export class PostSummonActivateAbilityPhase extends PostSummonPhase {
|
export class PostSummonActivateAbilityPhase extends PostSummonPhase {
|
||||||
private priority: number;
|
private priority: number;
|
||||||
|
private passive: boolean;
|
||||||
|
|
||||||
constructor(battlerIndex: BattlerIndex, priority: number) {
|
constructor(battlerIndex: BattlerIndex, priority: number, passive: boolean) {
|
||||||
super(battlerIndex);
|
super(battlerIndex);
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
|
this.passive = passive;
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
applyPostSummonAbAttrs(PostSummonAbAttr, this.getPokemon(), false, (p: number) => p === this.priority);
|
applyPostSummonAbAttrs(PostSummonAbAttr, this.getPokemon(), this.passive, false);
|
||||||
|
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user