#3722 improving code function

This commit is contained in:
Jesse Chung 2024-08-26 17:17:43 -07:00
parent 5c4c366abe
commit a925123121
2 changed files with 4 additions and 9 deletions

View File

@ -1945,7 +1945,7 @@ export class StatusEffectAttr extends MoveEffectAttr {
}
}
if ((!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0))
&& pokemon.trySetStatus(this.effect, true, user, this.cureTurn)) {
&& pokemon.trySetStatus(this.effect, false, user, this.cureTurn)) {
applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, this.effect);
return true;
}

View File

@ -2737,6 +2737,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
break;
case StatusEffect.SLEEP:
if (this.isGrounded() && this.scene.arena.terrain?.terrainType === TerrainType.ELECTRIC) {
if (!quiet) {
this.scene.queueMessage(i18next.t("terrain:defaultBlockMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(this), terrainName: getTerrainName(TerrainType.ELECTRIC) }));
}
return false;
}
break;
@ -2767,14 +2770,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
trySetStatus(effect: StatusEffect | undefined, asPhase: boolean = false, sourcePokemon: Pokemon | null = null, cureTurn: integer | null = 0, sourceText: string | null = null): boolean {
if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) {
switch (effect) {
case StatusEffect.SLEEP:
if (this.isGrounded() && this.scene.arena.terrain?.terrainType === TerrainType.ELECTRIC) {
this.scene.queueMessage(i18next.t("terrain:defaultBlockMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(this), terrainName: getTerrainName(TerrainType.ELECTRIC) }));
return false;
}
break;
}
return false;
}