cleaning up code and fixing some desync test issues

This commit is contained in:
PrabbyDD 2024-09-11 15:45:45 -07:00
parent afc36e3859
commit 3125882a5f
2 changed files with 39 additions and 48 deletions

View File

@ -1872,8 +1872,8 @@ export class CursedTag extends BattlerTag {
}
export class BurnedUpTag extends BattlerTag {
constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType, sourceMove: Moves) {
super(tagType, lapseType, 1, sourceMove);
constructor() {
super(BattlerTagType.BURNED_UP, BattlerTagLapseType.CUSTOM, 1, Moves.BURN_UP);
}
}
@ -1890,64 +1890,61 @@ export class GroundedTag extends BattlerTag {
/**
* @item `ROOSTED`: Tag for temporary grounding if only source of ungrounding is flying and pokemon uses Roost.
* Roost removes flying type from a pokemon for a single turn.
*
* Need to add check for terrastalized pokemon
*/
export class RoostedTag extends BattlerTag {
private isOriginallyOnlyFlying : boolean = false;
private isOriginallyFlying: boolean = false;
private isBaseFlying : boolean;
private isBasePureFlying : boolean;
constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType, sourceMove: Moves) {
super(tagType, lapseType, 1, sourceMove);
constructor() {
super(BattlerTagType.ROOSTED, BattlerTagLapseType.TURN_END, 1, Moves.ROOST);
}
onRemove(pokemon: Pokemon): void {
const currentTypes = pokemon.getTypes();
const baseTypes = pokemon.getTypes(false, false, true);
let userTypes = pokemon.getTypes(true);
let forestsCurseApplied: boolean = false;
let trickOrTreatApplied: boolean = false;
const isOriginallyGrass = pokemon.getSpeciesForm().type1 === Type.GRASS || pokemon.getSpeciesForm().type2 === Type.GRASS;
const isOriginallyGhost = pokemon.getSpeciesForm().type1 === Type.GHOST || pokemon.getSpeciesForm().type2 === Type.GHOST;
const forestsCurseApplied: boolean = currentTypes.includes(Type.GRASS) && !baseTypes.includes(Type.GRASS);
const trickOrTreatApplied: boolean = currentTypes.includes(Type.GHOST) && !baseTypes.includes(Type.GHOST);
if (!!userTypes.find(type => type === Type.GHOST) && !isOriginallyGhost) {
trickOrTreatApplied = true;
}
if (!!userTypes.find(type => type === Type.GRASS) && !isOriginallyGrass) {
forestsCurseApplied = true;
}
if (this.isOriginallyFlying) {
if (this.isOriginallyOnlyFlying) {
if (this.isBaseFlying) {
let modifiedTypes: Type[] = [];
if (this.isBasePureFlying) {
if (forestsCurseApplied || trickOrTreatApplied) {
userTypes = userTypes.filter(type => type !== Type.NORMAL);
userTypes.push(Type.FLYING);
modifiedTypes = currentTypes.filter(type => type !== Type.NORMAL);
modifiedTypes.push(Type.FLYING);
} else {
userTypes = [Type.FLYING];
modifiedTypes = [Type.FLYING];
}
} else {
userTypes.push(Type.FLYING);
modifiedTypes = [...currentTypes];
modifiedTypes.push(Type.FLYING);
}
pokemon.summonData.types = userTypes;
pokemon.summonData.types = modifiedTypes;
pokemon.updateInfo();
}
}
onAdd(pokemon: Pokemon): void {
const userTypes = pokemon.getTypes(true);
const isOriginallyDualType = !!pokemon.getSpeciesForm().type1 && !!pokemon.getSpeciesForm().type2;
const isCurrentlyDualType = userTypes.length > 1;
this.isOriginallyFlying = pokemon.getSpeciesForm().type1 === Type.FLYING || pokemon.getSpeciesForm().type2 === Type.FLYING;
this.isOriginallyOnlyFlying = pokemon.getSpeciesForm().type1 === Type.FLYING && pokemon.getSpeciesForm().type2 === null;
const currentTypes = pokemon.getTypes();
const baseTypes = pokemon.getTypes(false, false, true);
if (this.isOriginallyFlying) {
const isOriginallyDualType = baseTypes.length === 2;
const isCurrentlyDualType = currentTypes.length === 2;
this.isBaseFlying = baseTypes.includes(Type.FLYING);
this.isBasePureFlying = baseTypes[0] === Type.FLYING && baseTypes.length === 1;
if (this.isBaseFlying) {
let modifiedTypes: Type[];
if (this.isOriginallyOnlyFlying && !isCurrentlyDualType) {
if (this.isBasePureFlying && !isCurrentlyDualType) {
modifiedTypes = [Type.NORMAL];
} else {
if (!!pokemon.getTag(BurnedUpTag) && isOriginallyDualType && !isCurrentlyDualType) {
modifiedTypes = [Type.UNKNOWN];
} else {
modifiedTypes = userTypes.filter(type => type !== Type.FLYING);
modifiedTypes = currentTypes.filter(type => type !== Type.FLYING);
}
}
pokemon.summonData.types = modifiedTypes;

View File

@ -30,7 +30,7 @@ describe("Moves - Roost", () => {
game.override.enemySpecies(Species.RELICANTH);
game.override.startingLevel(100);
game.override.enemyLevel(60);
game.override.enemyMoveset([Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE]);
game.override.enemyMoveset(Moves.EARTHQUAKE);
game.override.moveset([Moves.ROOST, Moves.BURN_UP]);
game.override.starterForms({ [Species.ROTOM]: 4 });
});
@ -55,14 +55,13 @@ describe("Moves - Roost", () => {
"Non flying type uses roost -> no type change, took damage",
async () => {
await game.classicMode.startBattle([Species.DUNSPARCE]);
game.move.select(Moves.ROOST);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerPokemonStartingHP = playerPokemon.hp;
let playerPokemonTypes = playerPokemon.getTypes();
game.move.select(Moves.ROOST);
await game.phaseInterceptor.to(MoveEffectPhase);
// Should only be normal type, and NOT flying type
playerPokemonTypes = playerPokemon.getTypes();
let playerPokemonTypes = playerPokemon.getTypes();
expect(playerPokemonTypes[0] === Type.NORMAL).toBeTruthy();
expect(playerPokemonTypes.length === 1).toBeTruthy();
expect(playerPokemon.isGrounded()).toBeTruthy();
@ -82,9 +81,9 @@ describe("Moves - Roost", () => {
"Pure flying type -> becomes normal after roost and takes damage from ground moves -> regains flying",
async () => {
await game.classicMode.startBattle([Species.TORNADUS]);
game.move.select(Moves.ROOST);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerPokemonStartingHP = playerPokemon.hp;
game.move.select(Moves.ROOST);
await game.phaseInterceptor.to(MoveEffectPhase);
// Should only be normal type, and NOT flying type
@ -109,10 +108,9 @@ describe("Moves - Roost", () => {
"Dual X/flying type -> becomes type X after roost and takes damage from ground moves -> regains flying",
async () => {
await game.classicMode.startBattle([Species.HAWLUCHA]);
game.move.select(Moves.ROOST);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerPokemonStartingHP = playerPokemon.hp;
game.move.select(Moves.ROOST);
await game.phaseInterceptor.to(MoveEffectPhase);
// Should only be pure fighting type and grounded
@ -137,10 +135,9 @@ describe("Moves - Roost", () => {
"Pokemon with levitate after using roost should lose flying type but still be unaffected by ground moves",
async () => {
await game.classicMode.startBattle([Species.ROTOM]);
game.move.select(Moves.ROOST);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerPokemonStartingHP = playerPokemon.hp;
game.move.select(Moves.ROOST);
await game.phaseInterceptor.to(MoveEffectPhase);
// Should only be pure fighting type and grounded
@ -165,10 +162,9 @@ describe("Moves - Roost", () => {
"A fire/flying type that uses burn up, then roost should be typeless until end of turn",
async () => {
await game.classicMode.startBattle([Species.MOLTRES]);
game.move.select(Moves.BURN_UP);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerPokemonStartingHP = playerPokemon.hp;
game.move.select(Moves.BURN_UP);
await game.phaseInterceptor.to(MoveEffectPhase);
// Should only be pure flying type after burn up
@ -177,7 +173,6 @@ describe("Moves - Roost", () => {
expect(playerPokemonTypes.length === 1).toBeTruthy();
await game.phaseInterceptor.to(TurnEndPhase);
game.move.select(Moves.ROOST);
await game.phaseInterceptor.to(MoveEffectPhase);
@ -205,9 +200,8 @@ describe("Moves - Roost", () => {
async () => {
game.override.enemyMoveset([Moves.TRICK_OR_TREAT, Moves.TRICK_OR_TREAT, Moves.TRICK_OR_TREAT, Moves.TRICK_OR_TREAT]);
await game.classicMode.startBattle([Species.MOLTRES]);
game.move.select(Moves.ROOST);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.ROOST);
await game.phaseInterceptor.to(MoveEffectPhase);
let playerPokemonTypes = playerPokemon.getTypes();