mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 00:12:16 +02:00
#3772 more refactoring according to code review
This commit is contained in:
parent
5256d95830
commit
d4fa31788d
@ -822,7 +822,7 @@ export class DrowsyTag extends BattlerTag {
|
||||
}
|
||||
|
||||
canAdd(pokemon: Pokemon): boolean {
|
||||
const isElectricTerrainProtected = pokemon.scene.arena.terrain?.terrainType === TerrainType.ELECTRIC && !pokemon.isGrounded();
|
||||
const isElectricTerrainProtected = (pokemon.scene.arena.terrain?.terrainType === TerrainType.ELECTRIC && pokemon.isGrounded());
|
||||
if (isElectricTerrainProtected) {
|
||||
pokemon.scene.queueMessage(i18next.t("terrain:defaultBlockMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), terrainName: getTerrainName(TerrainType.ELECTRIC) }));
|
||||
}
|
||||
|
@ -1954,12 +1954,8 @@ export class StatusEffectAttr extends MoveEffectAttr {
|
||||
}
|
||||
}
|
||||
|
||||
if (!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0)) {
|
||||
pokemon.checkIfCanSetStatus(this.effect, false, false, user);
|
||||
}
|
||||
|
||||
if ((!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0))
|
||||
&& pokemon.trySetStatus(this.effect, true, user, this.cureTurn)) {
|
||||
&& pokemon.checkIfCanSetStatus(this.effect, false, false, user) && pokemon.trySetStatus(this.effect, true, user, this.cureTurn)) {
|
||||
applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, false, this.effect);
|
||||
return true;
|
||||
}
|
||||
|
@ -2742,7 +2742,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return this.gender !== Gender.GENDERLESS && pokemon.gender === (this.gender === Gender.MALE ? Gender.FEMALE : Gender.MALE);
|
||||
}
|
||||
|
||||
// This function only checks if it is possible to set status. If will not apply anything or do anything, just check if possible.
|
||||
/**
|
||||
* Checks if it is possible for a pokemon to be afflicted with the given status
|
||||
* @param effect {@linkcode StatusEffect} the status effect being checked.
|
||||
* @param quiet a boolean value determining whether or not to show messages.
|
||||
* @param overrideStatus a boolean value to determine whether a status should be overriden. If true, the pokemon cannot be statused essentially
|
||||
* @param sourcePokemon {@linkcode Pokemon} The pokemon causing the status. The target pokemon is 'this'.
|
||||
* @returns true if the pokemon can be affected by the status, false if not.
|
||||
*/
|
||||
checkIfCanSetStatus(effect: StatusEffect | undefined, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon | null = null): boolean {
|
||||
if (effect !== StatusEffect.FAINT) {
|
||||
if (overrideStatus ? this.status?.effect === effect : this.status) {
|
||||
@ -2807,12 +2814,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if it is possible for a pokemon to be afflicted with the given status
|
||||
* @param effect {@linkcode StatusEffect} the status effect being checked.
|
||||
* @param quiet a boolean value that is sometimes used as the asPhase boolean which causes unshifting the phase.
|
||||
* @param overrideStatus a boolean value to determine whether a status should be overriden. If true, the pokemon cannot be statused essentially
|
||||
* @param sourcePokemon {@linkcode Pokemon} The pokemon causing the status. The target pokemon is 'this'.
|
||||
* @returns true if the pokemon can be affected by the status, false if not.
|
||||
*/
|
||||
canSetStatus(effect: StatusEffect | undefined, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon | null = null): boolean {
|
||||
const checker = this.checkIfCanSetStatus(effect, quiet, overrideStatus, sourcePokemon);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user