Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement fainted forme regression #10810

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2030,8 +2030,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
if (pokemon.illusion) {
this.debug('illusion cleared');
pokemon.illusion = null;
const details = pokemon.species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
const details = pokemon.getSimpleDetails();
this.add('replace', pokemon, details);
this.add('-end', pokemon, 'Illusion');
if (this.ruleTable.has('illusionlevelmod')) {
Expand Down
3 changes: 1 addition & 2 deletions data/mods/gen7pokebilities/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ export const Scripts: ModdedBattleScriptsData = {
this.illusion ? this.illusion.species.name : species.baseSpecies;
if (isPermanent) {
this.baseSpecies = rawSpecies;
this.details = species.name + (this.level === 100 ? '' : ', L' + this.level) +
(this.gender === '' ? '' : ', ' + this.gender) + (this.set.shiny ? ', shiny' : '');
this.details = this.getSimpleDetails();
this.battle.add('detailschange', this, (this.illusion || this).details);
if (source.effectType === 'Item') {
this.canTerastallize = null; // National Dex behavior
Expand Down
3 changes: 1 addition & 2 deletions data/mods/gen9ssb/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1755,8 +1755,7 @@ export const Abilities: import('../../../sim/dex-abilities').ModdedAbilityDataTa
target.clearBoosts();
this.add('-clearboost', target);
this.boost({atk: 1, def: -1, spa: 1, spd: -1, spe: 1});
const details = target.species.name + (target.level === 100 ? '' : ', L' + target.level) +
(target.gender === '' ? '' : ', ' + target.gender) + (target.set.shiny ? ', shiny' : '');
const details = target.getSimpleDetails();
target.details = details;
this.add('replace', target, details);
}
Expand Down
6 changes: 2 additions & 4 deletions data/mods/gen9ssb/moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4236,8 +4236,7 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = {
pokemon.cureStatus();
this.boost({def: 1, spd: 1});
(pokemon as any).level += 5;
pokemon.details = pokemon.species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
pokemon.details = pokemon.getSimpleDetails();
this.add('-anim', pokemon, 'Geomancy', pokemon);
this.add('replace', pokemon, pokemon.details);
this.add('-message', `${pokemon.name} gained 5 levels!`);
Expand Down Expand Up @@ -5905,8 +5904,7 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = {
this.add(`c:|${getName((source.illusion || source).name)}|lol never do that ever again thanks`);
this.add('custom', '-endterastallize', pokemon);
delete pokemon.terastallized;
const details = pokemon.species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
const details = pokemon.getSimpleDetails();
this.add('detailschange', pokemon, details);
}
},
Expand Down
6 changes: 2 additions & 4 deletions data/mods/gen9ssb/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ export function changeSet(context: Battle, pokemon: Pokemon, newSet: SSBSet, cha
pokemon.teraType = newSet.teraType === 'Any' ? context.sample(allTypes) :
Array.isArray(newSet.teraType) ? context.sample(newSet.teraType) : newSet.teraType;
}
const details = pokemon.species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
const details = pokemon.getSimpleDetails();
if (oldShiny !== pokemon.set.shiny || oldGender !== pokemon.gender) context.add('replace', pokemon, details);
if (changeAbility) pokemon.setAbility(newSet.ability as string, undefined, true);

Expand Down Expand Up @@ -386,8 +385,7 @@ export const Scripts: ModdedBattleScriptsData = {
const species = pokemon.setSpecies(rawSpecies);
if (!species) continue;
pokemon.baseSpecies = rawSpecies;
pokemon.details = species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
pokemon.details = pokemon.getSimpleDetails();
// pokemon.setAbility(species.abilities['0'], null, true);
// pokemon.baseAbility = pokemon.ability;

Expand Down
6 changes: 2 additions & 4 deletions data/mods/mixandmega/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export const Scripts: ModdedBattleScriptsData = {
const species = pokemon.setSpecies(rawSpecies);
if (!species) continue;
pokemon.baseSpecies = rawSpecies;
pokemon.details = species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
pokemon.details = pokemon.getSimpleDetails();
pokemon.ability = this.toID(species.abilities['0']);
pokemon.baseAbility = pokemon.ability;
}
Expand Down Expand Up @@ -118,8 +117,7 @@ export const Scripts: ModdedBattleScriptsData = {
const species = pokemon.setSpecies(rawSpecies);
if (!species) continue;
pokemon.baseSpecies = rawSpecies;
pokemon.details = species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
pokemon.details = pokemon.getSimpleDetails();
pokemon.ability = this.toID(species.abilities['0']);
pokemon.baseAbility = pokemon.ability;

Expand Down
3 changes: 1 addition & 2 deletions data/mods/pokebilities/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ export const Scripts: ModdedBattleScriptsData = {
this.illusion ? this.illusion.species.name : species.baseSpecies;
if (isPermanent) {
this.baseSpecies = rawSpecies;
this.details = species.name + (this.level === 100 ? '' : ', L' + this.level) +
(this.gender === '' ? '' : ', ' + this.gender) + (this.set.shiny ? ', shiny' : '');
this.details = this.getSimpleDetails();
this.battle.add('detailschange', this, (this.illusion || this).details);
if (source.effectType === 'Item') {
this.canTerastallize = null; // National Dex behavior
Expand Down
2 changes: 1 addition & 1 deletion sim/battle-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ export class BattleActions {
}
if (pokemon.species.baseSpecies === 'Morpeko') {
pokemon.baseSpecies = pokemon.species;
pokemon.details = pokemon.details.replace('Morpeko', pokemon.species.name);
pokemon.details = pokemon.getSimpleDetails();
Copy link
Member

@KrisXV KrisXV Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pokemon.details = pokemon.getSimpleDetails();
pokemon.details = pokemon.getSimpleDetails(pokemon.species.name);

Copy link
Contributor Author

@andrebastosdias andrebastosdias Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, pokemon.species.name is used. Currently, that argument is only used for Greninja-Bond.

}
this.battle.runEvent('AfterTerastallization', pokemon);
}
Expand Down
14 changes: 12 additions & 2 deletions sim/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,17 @@ export class Battle {
pokemon.illusion = null;
pokemon.isActive = false;
pokemon.isStarted = false;
if (
(pokemon.terastallized && ['Morpeko', 'Ogerpon', 'Terapagos'].includes(pokemon.baseSpecies.baseSpecies)) ||
pokemon.baseSpecies.isMega
) {
const baseSpecies = this.dex.species.get(pokemon.set.species || pokemon.set.name);
pokemon.setSpecies(baseSpecies);
pokemon.baseSpecies = baseSpecies;
pokemon.baseAbility = pokemon.ability = toID(pokemon.set.ability);
pokemon.details = pokemon.getSimpleDetails();
this.add('detailschange', pokemon, pokemon.details, '[silent]');
}
delete pokemon.terastallized;
pokemon.side.faintedThisTurn = pokemon;
if (this.faintQueue.length >= faintQueueLeft) checkWin = true;
Expand Down Expand Up @@ -2494,8 +2505,7 @@ export class Battle {
const species = pokemon.setSpecies(rawSpecies);
if (!species) continue;
pokemon.baseSpecies = rawSpecies;
pokemon.details = species.name + (pokemon.level === 100 ? '' : ', L' + pokemon.level) +
(pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
pokemon.details = pokemon.getSimpleDetails();
pokemon.setAbility(species.abilities['0'], null, true);
pokemon.baseAbility = pokemon.ability;

Expand Down
31 changes: 16 additions & 15 deletions sim/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ export class Pokemon {
this.position = 0;
let displayedSpeciesName = this.species.name;
if (displayedSpeciesName === 'Greninja-Bond') displayedSpeciesName = 'Greninja';
this.details = displayedSpeciesName + (this.level === 100 ? '' : ', L' + this.level) +
(this.gender === '' ? '' : ', ' + this.gender) + (this.set.shiny ? ', shiny' : '');
this.details = this.getSimpleDetails(displayedSpeciesName);

this.status = '';
this.statusState = {};
Expand Down Expand Up @@ -509,17 +508,21 @@ export class Pokemon {
return this.isActive ? this.getSlot() + fullname.slice(2) : fullname;
}

getSimpleDetails(displayedSpeciesName: string | null = null, illusionDetails = false) {
let name = displayedSpeciesName || this.species.name;
let level = this.level;
if (illusionDetails && this.illusion) {
if (this.battle.ruleTable.has('illusionlevelmod')) level = this.illusion.level;
name = this.illusion.species.name;
if (name === 'Greninja-Bond') name = 'Greninja';
}
return name + (level === 100 ? '' : ', L' + level) +
(this.gender === '' ? '' : ', ' + this.gender) + (this.set.shiny ? ', shiny' : '');
}

getDetails = () => {
const health = this.getHealth();
let details = this.details;
if (this.illusion) {
const level = this.battle.ruleTable.has('illusionlevelmod') ? this.illusion.level : this.level;
let displayedSpeciesName = this.illusion.species.name;
if (displayedSpeciesName === 'Greninja-Bond') displayedSpeciesName = 'Greninja';
const illusionDetails = displayedSpeciesName + (level === 100 ? '' : ', L' + level) +
(this.illusion.gender === '' ? '' : ', ' + this.illusion.gender) + (this.illusion.set.shiny ? ', shiny' : '');
details = illusionDetails;
}
let details = this.getSimpleDetails(null, true);
if (this.terastallized) details += `, tera:${this.terastallized}`;
return {side: health.side, secret: `${details}|${health.secret}`, shared: `${details}|${health.shared}`};
};
Expand Down Expand Up @@ -1320,8 +1323,7 @@ export class Pokemon {

// Pokemon transformed into Ogerpon cannot Terastallize
// restoring their ability to tera after they untransform is handled ELSEWHERE
if (this.species.baseSpecies === 'Ogerpon' && this.canTerastallize) this.canTerastallize = false;
if (this.species.baseSpecies === 'Terapagos' && this.canTerastallize) this.canTerastallize = false;
if (['Ogerpon', 'Terapagos'].includes(this.species.baseSpecies) && this.canTerastallize) this.canTerastallize = false;

return true;
}
Expand Down Expand Up @@ -1387,8 +1389,7 @@ export class Pokemon {
this.illusion ? this.illusion.species.name : species.baseSpecies;
if (isPermanent) {
this.baseSpecies = rawSpecies;
this.details = species.name + (this.level === 100 ? '' : ', L' + this.level) +
(this.gender === '' ? '' : ', ' + this.gender) + (this.set.shiny ? ', shiny' : '');
this.details = this.getSimpleDetails();
let details = (this.illusion || this).details;
if (this.terastallized) details += `, tera:${this.terastallized}`;
this.battle.add('detailschange', this, details);
Expand Down
26 changes: 26 additions & 0 deletions test/sim/misc/terapagos.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@ describe(`Terapagos`, function () {
assert.false(!!ditto.terastallized);
});

it(`shouldn't revert to Terapagos-Normal if it faints while not Terastallized`, function () {
battle = common.createBattle([[
{species: 'terapagos', ability: 'terashift', moves: ['memento']},
{species: 'darkrai', moves: ['darkpulse']},
], [
{species: 'mareep', ability: 'static', moves: ['sleeptalk']},
]]);
const terapagos = battle.p1.active[0];
battle.makeChoices();
assert.species(terapagos, 'Terapagos-Terastal');
assert.equal(terapagos.ability, 'terashell', `Expected ${terapagos}'ability to be Tera Shell, not ${terapagos.ability}`);
});

it(`should revert to Terapagos-Normal if it faints while Terastallized`, function () {
battle = common.createBattle([[
{species: 'terapagos', ability: 'terashift', moves: ['memento']},
{species: 'darkrai', moves: ['darkpulse']},
], [
{species: 'mareep', ability: 'static', moves: ['sleeptalk']},
]]);
const terapagos = battle.p1.active[0];
battle.makeChoices('move memento terastallize', 'auto');
assert.species(terapagos, 'Terapagos');
assert.equal(terapagos.ability, 'terashift', `Expected ${terapagos}'ability to be Tera Shift, not ${terapagos.ability}`);
});

it(`[Hackmons] should not cause Terapagos-Terastal to become Terapagos-Stellar if the user is Transformed`, function () {
battle = common.createBattle([[
{species: 'terapagos', ability: 'terashift', moves: ['transform'], teraType: 'Stellar'},
Expand Down
Loading