Berries activate simultaneously
parent
be88f4783e
commit
93a7af853b
|
@ -1862,12 +1862,17 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
return (player ? this.modifiers : this.enemyModifiers).find(m => (modifierFilter as ModifierPredicate)(m));
|
return (player ? this.modifiers : this.enemyModifiers).find(m => (modifierFilter as ModifierPredicate)(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyModifiers(modifierType: { new(...args: any[]): Modifier }, player: boolean = true, ...args: any[]): void {
|
applyModifiers(modifierType: { new(...args: any[]): Modifier }, player: boolean = true, ...args: any[]): PersistentModifier[] {
|
||||||
|
const appliedModifiers: PersistentModifier[] = [];
|
||||||
const modifiers = (player ? this.modifiers : this.enemyModifiers).filter(m => m instanceof modifierType && m.shouldApply(args));
|
const modifiers = (player ? this.modifiers : this.enemyModifiers).filter(m => m instanceof modifierType && m.shouldApply(args));
|
||||||
for (let modifier of modifiers) {
|
for (let modifier of modifiers) {
|
||||||
if (modifier.apply(args))
|
if (modifier.apply(args)) {
|
||||||
console.log('Applied', modifier.type.name, !player ? '(enemy)' : '');
|
console.log('Applied', modifier.type.name, !player ? '(enemy)' : '');
|
||||||
|
appliedModifiers.push(modifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return appliedModifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyModifier(modifierType: { new(...args: any[]): Modifier }, player: boolean = true, ...args: any[]): PersistentModifier {
|
applyModifier(modifierType: { new(...args: any[]): Modifier }, player: boolean = true, ...args: any[]): PersistentModifier {
|
||||||
|
|
|
@ -3455,15 +3455,17 @@ export class BerryPhase extends CommonAnimPhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
let berryModifier: BerryModifier;
|
let berryModifiers: BerryModifier[];
|
||||||
|
|
||||||
if ((berryModifier = this.scene.applyModifier(BerryModifier, this.player, this.getPokemon()) as BerryModifier)) {
|
if ((berryModifiers = this.scene.applyModifiers(BerryModifier, this.player, this.getPokemon()) as BerryModifier[])) {
|
||||||
if (berryModifier.consumed) {
|
for (let berryModifier of berryModifiers) {
|
||||||
if (!--berryModifier.stackCount)
|
if (berryModifier.consumed) {
|
||||||
this.scene.removeModifier(berryModifier);
|
if (!--berryModifier.stackCount)
|
||||||
else
|
this.scene.removeModifier(berryModifier);
|
||||||
berryModifier.consumed = false;
|
else
|
||||||
this.scene.updateModifiers(this.player);
|
berryModifier.consumed = false;
|
||||||
|
this.scene.updateModifiers(this.player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.start();
|
return super.start();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue