Add Toxic Spikes neutralization
parent
4432522e15
commit
27e40d8526
|
@ -141,7 +141,7 @@ export class ArenaTrapTag extends ArenaTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(arena: Arena, args: any[]): boolean {
|
apply(arena: Arena, args: any[]): boolean {
|
||||||
const pokemon = args[0] as Pokemon;
|
const pokemon = args[0] as Pokemon;
|
||||||
if (this.sourceId === pokemon.id || (this.side === ArenaTagSide.PLAYER) !== pokemon.isPlayer())
|
if (this.sourceId === pokemon.id || (this.side === ArenaTagSide.PLAYER) !== pokemon.isPlayer())
|
||||||
return false;
|
return false;
|
||||||
|
@ -181,8 +181,11 @@ class SpikesTag extends ArenaTrapTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ToxicSpikesTag extends ArenaTrapTag {
|
class ToxicSpikesTag extends ArenaTrapTag {
|
||||||
|
private neutralized: boolean;
|
||||||
|
|
||||||
constructor(sourceId: integer, side: ArenaTagSide) {
|
constructor(sourceId: integer, side: ArenaTagSide) {
|
||||||
super(ArenaTagType.TOXIC_SPIKES, Moves.TOXIC_SPIKES, sourceId, side, 2);
|
super(ArenaTagType.TOXIC_SPIKES, Moves.TOXIC_SPIKES, sourceId, side, 2);
|
||||||
|
this.neutralized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdd(arena: Arena): void {
|
onAdd(arena: Arena): void {
|
||||||
|
@ -192,10 +195,23 @@ class ToxicSpikesTag extends ArenaTrapTag {
|
||||||
arena.scene.queueMessage(`${this.getMoveName()} were scattered\nall around ${source.getOpponentDescriptor()}'s feet!`);
|
arena.scene.queueMessage(`${this.getMoveName()} were scattered\nall around ${source.getOpponentDescriptor()}'s feet!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRemove(arena: Arena): void {
|
||||||
|
if (!this.neutralized)
|
||||||
|
super.onRemove(arena);
|
||||||
|
}
|
||||||
|
|
||||||
activateTrap(pokemon: Pokemon): boolean {
|
activateTrap(pokemon: Pokemon): boolean {
|
||||||
if (!pokemon.status && pokemon.isGrounded()) {
|
if (!pokemon.status && pokemon.isGrounded()) {
|
||||||
const toxic = this.layers > 1;
|
const toxic = this.layers > 1;
|
||||||
return pokemon.trySetStatus(!toxic ? StatusEffect.POISON : StatusEffect.TOXIC, true, null, `the ${this.getMoveName()}`);
|
if (pokemon.trySetStatus(!toxic ? StatusEffect.POISON : StatusEffect.TOXIC, true, null, `the ${this.getMoveName()}`))
|
||||||
|
return true;
|
||||||
|
else if (pokemon.isOfType(Type.POISON)) {
|
||||||
|
this.neutralized = true;
|
||||||
|
if (pokemon.scene.arena.removeTag(this.tagType)) {
|
||||||
|
pokemon.scene.queueMessage(`The ${this.getMoveName()} were\nneutralized by ${pokemon.name}.`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -470,13 +470,22 @@ export class Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
lapseTags(): void {
|
lapseTags(): void {
|
||||||
const tags = this.tags;
|
this.tags.filter(t => !(t.lapse(this))).forEach(t => {
|
||||||
tags.filter(t => !(t.lapse(this))).forEach(t => {
|
|
||||||
t.onRemove(this);
|
t.onRemove(this);
|
||||||
tags.splice(tags.indexOf(t), 1);
|
this.tags.splice(this.tags.indexOf(t), 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeTag(tagType: ArenaTagType): boolean {
|
||||||
|
const tags = this.tags;
|
||||||
|
const tag = tags.find(t => t.tagType === tagType);
|
||||||
|
if (tag) {
|
||||||
|
tag.onRemove(this);
|
||||||
|
tags.splice(tags.indexOf(tag), 1);
|
||||||
|
}
|
||||||
|
return !!tag;
|
||||||
|
}
|
||||||
|
|
||||||
removeAllTags(): void {
|
removeAllTags(): void {
|
||||||
while (this.tags.length) {
|
while (this.tags.length) {
|
||||||
this.tags[0].onRemove(this);
|
this.tags[0].onRemove(this);
|
||||||
|
|
Loading…
Reference in New Issue