Merge branch 'pagefaultgames:main' into main

This commit is contained in:
ARSOD-Z 2024-04-15 13:34:04 -03:00 committed by GitHub
commit fee8acb825
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 142 additions and 46 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "pokemon-rogue-battle", "name": "pokemon-rogue-battle",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"start": "vite", "start": "vite",

View File

@ -2813,7 +2813,8 @@ export function initAbilities() {
.bypassFaint(), .bypassFaint(),
new Ability(Abilities.SEED_SOWER, "Seed Sower", "Turns the ground into Grassy Terrain when the Pokémon is hit by an attack.", 9) new Ability(Abilities.SEED_SOWER, "Seed Sower", "Turns the ground into Grassy Terrain when the Pokémon is hit by an attack.", 9)
.attr(PostDefendTerrainChangeAbAttr, TerrainType.GRASSY), .attr(PostDefendTerrainChangeAbAttr, TerrainType.GRASSY),
new Ability(Abilities.THERMAL_EXCHANGE, "Thermal Exchange (P)", "Boosts the Attack stat when the Pokémon is hit by a Fire-type move. The Pokémon also cannot be burned.", 9) new Ability(Abilities.THERMAL_EXCHANGE, "Thermal Exchange", "Boosts the Attack stat when the Pokémon is hit by a Fire-type move. The Pokémon also cannot be burned.", 9)
.attr(PostDefendStatChangeAbAttr, (target, user, move) => move.type === Type.FIRE, BattleStat.ATK, 1)
.attr(StatusEffectImmunityAbAttr, StatusEffect.BURN) .attr(StatusEffectImmunityAbAttr, StatusEffect.BURN)
.ignorable(), .ignorable(),
new Ability(Abilities.ANGER_SHELL, "Anger Shell (N)", "When an attack causes its HP to drop to half or less, the Pokémon gets angry. This lowers its Defense and Sp. Def stats but boosts its Attack, Sp. Atk, and Speed stats.", 9), new Ability(Abilities.ANGER_SHELL, "Anger Shell (N)", "When an attack causes its HP to drop to half or less, the Pokémon gets angry. This lowers its Defense and Sp. Def stats but boosts its Attack, Sp. Atk, and Speed stats.", 9),

View File

@ -799,7 +799,7 @@ export class TruantTag extends AbilityBattlerTag {
} }
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if ((!pokemon.canApplyAbility() || pokemon.getAbility().id !== Abilities.TRUANT) && (!pokemon.canApplyAbility(true) || pokemon.getPassiveAbility().id !== Abilities.TRUANT)) if (!pokemon.hasAbility(Abilities.TRUANT))
return super.lapse(pokemon, lapseType); return super.lapse(pokemon, lapseType);
const passive = pokemon.getAbility().id !== Abilities.TRUANT; const passive = pokemon.getAbility().id !== Abilities.TRUANT;
@ -827,7 +827,7 @@ export class SlowStartTag extends AbilityBattlerTag {
} }
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if ((!pokemon.canApplyAbility() || pokemon.getAbility().id !== this.ability) && (!pokemon.canApplyAbility(true) || pokemon.getPassiveAbility().id !== this.ability)) if (!pokemon.hasAbility(this.ability))
this.turnCount = 1; this.turnCount = 1;
return super.lapse(pokemon, lapseType); return super.lapse(pokemon, lapseType);

View File

@ -275,7 +275,7 @@ export default class Move {
checkFlag(flag: MoveFlags, user: Pokemon, target: Pokemon): boolean { checkFlag(flag: MoveFlags, user: Pokemon, target: Pokemon): boolean {
switch (flag) { switch (flag) {
case MoveFlags.MAKES_CONTACT: case MoveFlags.MAKES_CONTACT:
if ((user.canApplyAbility() && user.getAbility().hasAttr(IgnoreContactAbAttr)) || (user.canApplyAbility(true) && user.getPassiveAbility().hasAttr(IgnoreContactAbAttr))) if (user.hasAbilityWithAttr(IgnoreContactAbAttr))
return false; return false;
break; break;
} }
@ -2828,46 +2828,48 @@ export class NaturePowerAttr extends OverrideMoveEffectAttr {
case TerrainType.NONE: case TerrainType.NONE:
switch (user.scene.arena.biomeType) { switch (user.scene.arena.biomeType) {
case Biome.TOWN: case Biome.TOWN:
case Biome.METROPOLIS:
case Biome.SLUM:
moveId = Moves.TRI_ATTACK; moveId = Moves.TRI_ATTACK;
break; break;
case Biome.PLAINS case Biome.PLAINS:
|| Biome.GRASS case Biome.GRASS:
|| Biome.TALL_GRASS case Biome.TALL_GRASS:
|| Biome.MEADOW case Biome.MEADOW:
|| Biome.FOREST case Biome.FOREST:
|| Biome.JUNGLE: case Biome.JUNGLE:
moveId = Moves.ENERGY_BALL; moveId = Moves.ENERGY_BALL;
break; break;
case Biome.SEA case Biome.SEA:
|| Biome.SWAMP case Biome.SWAMP:
|| Biome.BEACH case Biome.BEACH:
|| Biome.LAKE case Biome.LAKE:
|| Biome.SEABED case Biome.SEABED:
|| Biome.ISLAND: case Biome.ISLAND:
moveId = Moves.HYDRO_PUMP; moveId = Moves.HYDRO_PUMP;
break; break;
case Biome.MOUNTAIN: case Biome.MOUNTAIN:
moveId = Moves.AIR_SLASH; moveId = Moves.AIR_SLASH;
break; break;
case Biome.BADLANDS case Biome.BADLANDS:
|| Biome.DESERT case Biome.DESERT:
|| Biome.WASTELAND case Biome.WASTELAND:
|| Biome.CONSTRUCTION_SITE: case Biome.CONSTRUCTION_SITE:
moveId = Moves.EARTH_POWER; moveId = Moves.EARTH_POWER;
break; break;
case Biome.CAVE: case Biome.CAVE:
moveId = Moves.POWER_GEM; moveId = Moves.POWER_GEM;
break; break;
case Biome.ICE_CAVE case Biome.ICE_CAVE:
|| Biome.SNOWY_FOREST: case Biome.SNOWY_FOREST:
moveId = Moves.ICE_BEAM; moveId = Moves.ICE_BEAM;
break; break;
case Biome.VOLCANO: case Biome.VOLCANO:
moveId = Moves.FLAMETHROWER; moveId = Moves.FLAMETHROWER;
break; break;
case Biome.GRAVEYARD case Biome.GRAVEYARD:
|| Biome.RUINS case Biome.RUINS:
|| Biome.TEMPLE: case Biome.TEMPLE:
moveId = Moves.SHADOW_BALL; moveId = Moves.SHADOW_BALL;
break; break;
case Biome.DOJO: case Biome.DOJO:
@ -2876,11 +2878,20 @@ export class NaturePowerAttr extends OverrideMoveEffectAttr {
case Biome.FAIRY_CAVE: case Biome.FAIRY_CAVE:
moveId = Moves.MOONBLAST; moveId = Moves.MOONBLAST;
break; break;
case Biome.ABYSS case Biome.ABYSS:
|| Biome.SPACE case Biome.SPACE:
|| Biome.END:
moveId = Moves.DARK_PULSE; moveId = Moves.DARK_PULSE;
break; break;
case Biome.FACTORY:
case Biome.LABORATORY:
moveId = Moves.FLASH_CANNON;
break;
case Biome.POWER_PLANT:
moveId = Moves.THUNDERBOLT;
break;
case Biome.END:
moveId = Moves.ETERNABEAM;
break;
} }
break; break;
case TerrainType.MISTY: case TerrainType.MISTY:
@ -4849,9 +4860,9 @@ export function initMoves() {
.attr(StatChangeAttr, [ BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD ], 2, true) .attr(StatChangeAttr, [ BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD ], 2, true)
.ignoresVirtual(), .ignoresVirtual(),
new StatusMove(Moves.MAGNETIC_FLUX, "Magnetic Flux", Type.ELECTRIC, -1, 20, "The user manipulates magnetic fields, which raises the Defense and Sp. Def stats of ally Pokémon with the Plus or Minus Ability.", -1, 0, 6) new StatusMove(Moves.MAGNETIC_FLUX, "Magnetic Flux", Type.ELECTRIC, -1, 20, "The user manipulates magnetic fields, which raises the Defense and Sp. Def stats of ally Pokémon with the Plus or Minus Ability.", -1, 0, 6)
.attr(StatChangeAttr, [ BattleStat.DEF, BattleStat.SPDEF ], 1, false, (user, target, move) => !![ Abilities.PLUS, Abilities.MINUS].find(a => a === user.getAbility().id || (user.canApplyPassive() && a === user.getPassiveAbility().id))) .attr(StatChangeAttr, [ BattleStat.DEF, BattleStat.SPDEF ], 1, false, (user, target, move) => !![ Abilities.PLUS, Abilities.MINUS].find(a => target.hasAbility(a, false)))
.target(MoveTarget.USER_AND_ALLIES) .target(MoveTarget.USER_AND_ALLIES)
.condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ Abilities.PLUS, Abilities.MINUS].find(a => a === p.getAbility().id || (user.canApplyPassive() && a === user.getPassiveAbility().id)))), .condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ Abilities.PLUS, Abilities.MINUS].find(a => p.hasAbility(a, false)))),
new StatusMove(Moves.HAPPY_HOUR, "Happy Hour (N)", Type.NORMAL, -1, 30, "Using Happy Hour doubles the amount of prize money received after battle.", -1, 0, 6) // No animation new StatusMove(Moves.HAPPY_HOUR, "Happy Hour (N)", Type.NORMAL, -1, 30, "Using Happy Hour doubles the amount of prize money received after battle.", -1, 0, 6) // No animation
.target(MoveTarget.USER_SIDE), .target(MoveTarget.USER_SIDE),
new StatusMove(Moves.ELECTRIC_TERRAIN, "Electric Terrain", Type.ELECTRIC, -1, 10, "The user electrifies the ground for five turns, powering up Electric-type moves. Pokémon on the ground no longer fall asleep.", -1, 0, 6) new StatusMove(Moves.ELECTRIC_TERRAIN, "Electric Terrain", Type.ELECTRIC, -1, 10, "The user electrifies the ground for five turns, powering up Electric-type moves. Pokémon on the ground no longer fall asleep.", -1, 0, 6)
@ -4979,9 +4990,9 @@ export function initMoves() {
new SelfStatusMove(Moves.LASER_FOCUS, "Laser Focus", Type.NORMAL, -1, 30, "The user concentrates intensely. The attack on the next turn always results in a critical hit.", -1, 0, 7) new SelfStatusMove(Moves.LASER_FOCUS, "Laser Focus", Type.NORMAL, -1, 30, "The user concentrates intensely. The attack on the next turn always results in a critical hit.", -1, 0, 7)
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false), .attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false),
new StatusMove(Moves.GEAR_UP, "Gear Up", Type.STEEL, -1, 20, "The user engages its gears to raise the Attack and Sp. Atk stats of ally Pokémon with the Plus or Minus Ability.", -1, 0, 7) new StatusMove(Moves.GEAR_UP, "Gear Up", Type.STEEL, -1, 20, "The user engages its gears to raise the Attack and Sp. Atk stats of ally Pokémon with the Plus or Minus Ability.", -1, 0, 7)
.attr(StatChangeAttr, [ BattleStat.ATK, BattleStat.SPATK ], 1, false, (user, target, move) => [ Abilities.PLUS, Abilities.MINUS ].includes(target.getAbility().id) || (target.canApplyPassive() && [ Abilities.PLUS, Abilities.MINUS ].includes(target.getPassiveAbility().id))) .attr(StatChangeAttr, [ BattleStat.ATK, BattleStat.SPATK ], 1, false, (user, target, move) => !![ Abilities.PLUS, Abilities.MINUS].find(a => target.hasAbility(a, false)))
.target(MoveTarget.USER_AND_ALLIES) .target(MoveTarget.USER_AND_ALLIES)
.condition((user, target, move) => !![ user, user.getAlly() ].find(p => p && [ Abilities.PLUS, Abilities.MINUS ].includes(p.getAbility().id) || (target.canApplyPassive() && [ Abilities.PLUS, Abilities.MINUS ].includes(target.getPassiveAbility().id)))), .condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ Abilities.PLUS, Abilities.MINUS].find(a => p.hasAbility(a, false)))),
new AttackMove(Moves.THROAT_CHOP, "Throat Chop (P)", Type.DARK, MoveCategory.PHYSICAL, 80, 100, 15, "The user attacks the target's throat, and the resultant suffering prevents the target from using moves that emit sound for two turns.", 100, 0, 7), new AttackMove(Moves.THROAT_CHOP, "Throat Chop (P)", Type.DARK, MoveCategory.PHYSICAL, 80, 100, 15, "The user attacks the target's throat, and the resultant suffering prevents the target from using moves that emit sound for two turns.", 100, 0, 7),
new AttackMove(Moves.POLLEN_PUFF, "Pollen Puff (P)", Type.BUG, MoveCategory.SPECIAL, 90, 100, 15, "The user attacks the enemy with a pollen puff that explodes. If the target is an ally, it gives the ally a pollen puff that restores its HP instead.", -1, 0, 7) new AttackMove(Moves.POLLEN_PUFF, "Pollen Puff (P)", Type.BUG, MoveCategory.SPECIAL, 90, 100, 15, "The user attacks the enemy with a pollen puff that explodes. If the target is an ally, it gives the ally a pollen puff that restores its HP instead.", -1, 0, 7)
.ballBombMove(), .ballBombMove(),

View File

@ -535,8 +535,8 @@ export const pokemonFormChanges: PokemonFormChanges = {
new SpeciesFormChange(Species.MELOETTA, 'pirouette', 'aria', new SpeciesFormChangeActiveTrigger(false), true) new SpeciesFormChange(Species.MELOETTA, 'pirouette', 'aria', new SpeciesFormChangeActiveTrigger(false), true)
], ],
[Species.AEGISLASH]: [ [Species.AEGISLASH]: [
new SpeciesFormChange(Species.AEGISLASH, 'blade', 'shield', new SpeciesFormChangePreMoveTrigger(Moves.KINGS_SHIELD), true, new SpeciesFormChangeCondition(p => p.getAbility().id === Abilities.STANCE_CHANGE)), new SpeciesFormChange(Species.AEGISLASH, 'blade', 'shield', new SpeciesFormChangePreMoveTrigger(Moves.KINGS_SHIELD), true, new SpeciesFormChangeCondition(p => p.hasAbility(Abilities.STANCE_CHANGE))),
new SpeciesFormChange(Species.AEGISLASH, 'shield', 'blade', new SpeciesFormChangePreMoveTrigger(m => allMoves[m].category !== MoveCategory.STATUS), true, new SpeciesFormChangeCondition(p => p.getAbility().id === Abilities.STANCE_CHANGE)), new SpeciesFormChange(Species.AEGISLASH, 'shield', 'blade', new SpeciesFormChangePreMoveTrigger(m => allMoves[m].category !== MoveCategory.STATUS), true, new SpeciesFormChangeCondition(p => p.hasAbility(Abilities.STANCE_CHANGE))),
new SpeciesFormChange(Species.AEGISLASH, 'blade', 'shield', new SpeciesFormChangeActiveTrigger(false), true) new SpeciesFormChange(Species.AEGISLASH, 'blade', 'shield', new SpeciesFormChangeActiveTrigger(false), true)
], ],
[Species.DIANCIE]: [ [Species.DIANCIE]: [

View File

@ -108,7 +108,7 @@ export class Weather {
for (let pokemon of field) { for (let pokemon of field) {
let suppressWeatherEffectAbAttr = pokemon.getAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr; let suppressWeatherEffectAbAttr = pokemon.getAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr;
if (!suppressWeatherEffectAbAttr) if (!suppressWeatherEffectAbAttr)
suppressWeatherEffectAbAttr = pokemon.canApplyPassive() ? pokemon.getPassiveAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr : null; suppressWeatherEffectAbAttr = pokemon.hasPassive() ? pokemon.getPassiveAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr : null;
if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable)) if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable))
return true; return true;
} }

View File

@ -25,7 +25,7 @@ import { TempBattleStat } from '../data/temp-battle-stat';
import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from '../data/arena-tag'; import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from '../data/arena-tag';
import { ArenaTagType } from "../data/enums/arena-tag-type"; import { ArenaTagType } from "../data/enums/arena-tag-type";
import { Biome } from "../data/enums/biome"; import { Biome } from "../data/enums/biome";
import { Ability, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from '../data/ability'; import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from '../data/ability';
import { Abilities } from "#app/data/enums/abilities"; import { Abilities } from "#app/data/enums/abilities";
import PokemonData from '../system/pokemon-data'; import PokemonData from '../system/pokemon-data';
import { BattlerIndex } from '../battle'; import { BattlerIndex } from '../battle';
@ -561,7 +561,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
let value = Math.floor(((2 * baseStat + this.ivs[s]) * this.level) * 0.01); let value = Math.floor(((2 * baseStat + this.ivs[s]) * this.level) * 0.01);
if (isHp) { if (isHp) {
value = value + this.level + 10; value = value + this.level + 10;
if ((this.canApplyAbility() && this.getAbility().hasAttr(NonSuperEffectiveImmunityAbAttr)) || (this.canApplyAbility(true) && this.getPassiveAbility().hasAttr(NonSuperEffectiveImmunityAbAttr))) if (this.hasAbility(Abilities.WONDER_GUARD, false, true))
value = 1; value = 1;
if (this.hp > value || this.hp === undefined) if (this.hp > value || this.hp === undefined)
this.hp = value; this.hp = value;
@ -730,12 +730,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return allAbilities[starterPassiveAbilities[starterSpeciesId]]; return allAbilities[starterPassiveAbilities[starterSpeciesId]];
} }
canApplyPassive(): boolean { hasPassive(): boolean {
return this.passive || this.isBoss(); return this.passive || this.isBoss();
} }
canApplyAbility(passive: boolean = false): boolean { canApplyAbility(passive: boolean = false): boolean {
if (passive && !this.canApplyPassive()) if (passive && !this.hasPassive())
return false; return false;
const ability = (!passive ? this.getAbility() : this.getPassiveAbility()); const ability = (!passive ? this.getAbility() : this.getPassiveAbility());
if (ability.isIgnorable && this.scene.arena.ignoreAbilities) if (ability.isIgnorable && this.scene.arena.ignoreAbilities)
@ -743,6 +743,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return (this.hp || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this)); return (this.hp || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this));
} }
hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean {
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).id === ability)
return true;
if (this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().id === ability)
return true;
return false;
}
hasAbilityWithAttr(attrType: { new(...args: any[]): AbAttr }, canApply: boolean = true, ignoreOverride?: boolean): boolean {
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType))
return true;
if (this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().hasAttr(attrType))
return true;
return false;
}
getWeight(): number { getWeight(): number {
const weight = new Utils.NumberHolder(this.species.weight); const weight = new Utils.NumberHolder(this.species.weight);
// This will trigger the ability overlay so only call this function when necessary // This will trigger the ability overlay so only call this function when necessary

View File

@ -379,6 +379,16 @@ export class UnavailablePhase extends Phase {
} }
} }
export class OutdatedPhase extends Phase {
constructor(scene: BattleScene) {
super(scene);
}
start(): void {
this.scene.ui.setMode(Mode.OUTDATED);
}
}
export class SelectGenderPhase extends Phase { export class SelectGenderPhase extends Phase {
constructor(scene: BattleScene) { constructor(scene: BattleScene) {
super(scene); super(scene);
@ -2190,7 +2200,7 @@ export class MovePhase extends BattlePhase {
for (let opponent of targetedOpponents) { for (let opponent of targetedOpponents) {
if (this.move.ppUsed === this.move.getMove().pp) if (this.move.ppUsed === this.move.getMove().pp)
break; break;
if ((opponent.canApplyAbility() && opponent.getAbility().hasAttr(IncreasePpAbAttr)) || (opponent.canApplyAbility(true) && opponent.getPassiveAbility().hasAttr(IncreasePpAbAttr))) if (opponent.hasAbilityWithAttr(IncreasePpAbAttr))
this.move.ppUsed = Math.min(this.move.ppUsed + 1, this.move.getMovePp()); this.move.ppUsed = Math.min(this.move.ppUsed + 1, this.move.getMovePp());
} }
} }

View File

@ -27,6 +27,7 @@ import { Moves } from "../data/enums/moves";
import { speciesEggMoves } from "../data/egg-moves"; import { speciesEggMoves } from "../data/egg-moves";
import { allMoves } from "../data/move"; import { allMoves } from "../data/move";
import { TrainerVariant } from "../field/trainer"; import { TrainerVariant } from "../field/trainer";
import { OutdatedPhase, UnavailablePhase } from "#app/phases";
const saveKey = 'x0i2O7WRiANTqPmZ'; // Temporary; secure encryption is not yet necessary const saveKey = 'x0i2O7WRiANTqPmZ'; // Temporary; secure encryption is not yet necessary
@ -269,6 +270,10 @@ export class GameData {
.then(error => { .then(error => {
this.scene.ui.savingIcon.hide(); this.scene.ui.savingIcon.hide();
if (error) { if (error) {
if (error.startsWith('client version out of date')) {
this.scene.clearPhaseQueue();
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
}
console.error(error); console.error(error);
return resolve(false); return resolve(false);
} }

View File

@ -0,0 +1,47 @@
import BattleScene from "../battle-scene";
import { ModalConfig, ModalUiHandler } from "./modal-ui-handler";
import { addTextObject, TextStyle } from "./text";
import { Mode } from "./ui";
export default class OutdatedModalUiHandler extends ModalUiHandler {
constructor(scene: BattleScene, mode?: Mode) {
super(scene, mode);
}
getModalTitle(): string {
return '';
}
getWidth(): number {
return 160;
}
getHeight(): number {
return 64;
}
getMargin(): [number, number, number, number] {
return [ 0, 0, 48, 0 ];
}
getButtonLabels(): string[] {
return [ ];
}
setup(): void {
super.setup();
const label = addTextObject(this.scene, this.getWidth() / 2, this.getHeight() / 2, 'Your client is currently outdated.\nPlease reload to update the game.\n\nIf this error persists, please clear your browser cache.', TextStyle.WINDOW, { fontSize: '48px', align: 'center' });
label.setOrigin(0.5, 0.5);
this.modalContainer.add(label);
}
show(args: any[]): boolean {
const config: ModalConfig = {
buttonActions: []
};
return super.show([ config ]);
}
}

View File

@ -114,8 +114,10 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
ui.showText(null, 0); ui.showText(null, 0);
}, false, 0, 19, 2000); }, false, 0, 19, 2000);
}); });
} else } else if (this.sessionSlots[this.cursor].hasData === false)
saveAndCallback(); saveAndCallback();
else
return false;
break; break;
} }
success = true; success = true;
@ -210,7 +212,6 @@ class SessionSlot extends Phaser.GameObjects.Container {
super(scene, 0, slotId * 56); super(scene, 0, slotId * 56);
this.slotId = slotId; this.slotId = slotId;
this.hasData = false;
this.setup(); this.setup();
} }
@ -282,6 +283,7 @@ class SessionSlot extends Phaser.GameObjects.Container {
return new Promise<boolean>(resolve => { return new Promise<boolean>(resolve => {
this.scene.gameData.getSession(this.slotId).then(async sessionData => { this.scene.gameData.getSession(this.slotId).then(async sessionData => {
if (!sessionData) { if (!sessionData) {
this.hasData = false;
this.loadingLabel.setText('Empty'); this.loadingLabel.setText('Empty');
resolve(false); resolve(false);
return; return;

View File

@ -34,6 +34,7 @@ import SaveSlotSelectUiHandler from './save-slot-select-ui-handler';
import TitleUiHandler from './title-ui-handler'; import TitleUiHandler from './title-ui-handler';
import SavingIconHandler from './saving-icon-handler'; import SavingIconHandler from './saving-icon-handler';
import UnavailableModalUiHandler from './unavailable-modal-ui-handler'; import UnavailableModalUiHandler from './unavailable-modal-ui-handler';
import OutdatedModalUiHandler from './outdated-modal-ui-handler';
export enum Mode { export enum Mode {
MESSAGE, MESSAGE,
@ -63,7 +64,8 @@ export enum Mode {
LOGIN_FORM, LOGIN_FORM,
REGISTRATION_FORM, REGISTRATION_FORM,
LOADING, LOADING,
UNAVAILABLE UNAVAILABLE,
OUTDATED
}; };
const transitionModes = [ const transitionModes = [
@ -90,7 +92,8 @@ const noTransitionModes = [
Mode.LOGIN_FORM, Mode.LOGIN_FORM,
Mode.REGISTRATION_FORM, Mode.REGISTRATION_FORM,
Mode.LOADING, Mode.LOADING,
Mode.UNAVAILABLE Mode.UNAVAILABLE,
Mode.OUTDATED
]; ];
export default class UI extends Phaser.GameObjects.Container { export default class UI extends Phaser.GameObjects.Container {
@ -141,7 +144,8 @@ export default class UI extends Phaser.GameObjects.Container {
new LoginFormUiHandler(scene), new LoginFormUiHandler(scene),
new RegistrationFormUiHandler(scene), new RegistrationFormUiHandler(scene),
new LoadingModalUiHandler(scene), new LoadingModalUiHandler(scene),
new UnavailableModalUiHandler(scene) new UnavailableModalUiHandler(scene),
new OutdatedModalUiHandler(scene)
]; ];
} }