mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-10-01 22:01:41 -05:00
Fix validating Pokemon with event-only prevolutions (#8495)
This commit is contained in:
@@ -340,6 +340,24 @@ export class TeamValidator {
|
||||
return problems;
|
||||
}
|
||||
|
||||
getEventOnlyData(species: Species, noRecurse?: boolean): {species: Species, eventData: EventInfo[]} | null {
|
||||
const dex = this.dex;
|
||||
const learnset = dex.species.getLearnsetData(species.id);
|
||||
if (!learnset?.eventOnly) {
|
||||
if (noRecurse) return null;
|
||||
return this.getEventOnlyData(dex.species.get(species.prevo), true);
|
||||
}
|
||||
|
||||
if (!learnset.eventData && species.forme) {
|
||||
return this.getEventOnlyData(dex.species.get(species.baseSpecies), true);
|
||||
}
|
||||
if (!learnset.eventData) {
|
||||
throw new Error(`Event-only species ${species.name} has no eventData table`);
|
||||
}
|
||||
|
||||
return {species, eventData: learnset.eventData};
|
||||
}
|
||||
|
||||
validateSet(set: PokemonSet, teamHas: AnyObject): string[] | null {
|
||||
const format = this.format;
|
||||
const dex = this.dex;
|
||||
@@ -598,6 +616,7 @@ export class TeamValidator {
|
||||
}
|
||||
|
||||
const learnsetSpecies = dex.species.getLearnsetData(outOfBattleSpecies.id);
|
||||
let eventOnlyData;
|
||||
|
||||
if (!setSources.sourcesBefore && setSources.sources.length) {
|
||||
let legal = false;
|
||||
@@ -629,13 +648,8 @@ export class TeamValidator {
|
||||
if (eventProblems) problems.push(...eventProblems);
|
||||
}
|
||||
}
|
||||
} else if (ruleTable.has('obtainablemisc') && learnsetSpecies.eventOnly) {
|
||||
const eventSpecies = !learnsetSpecies.eventData &&
|
||||
outOfBattleSpecies.baseSpecies !== outOfBattleSpecies.name ?
|
||||
dex.species.get(outOfBattleSpecies.baseSpecies) : outOfBattleSpecies;
|
||||
const eventData = learnsetSpecies.eventData ||
|
||||
dex.species.getLearnsetData(eventSpecies.id).eventData;
|
||||
if (!eventData) throw new Error(`Event-only species ${species.name} has no eventData table`);
|
||||
} else if (ruleTable.has('obtainablemisc') && (eventOnlyData = this.getEventOnlyData(outOfBattleSpecies))) {
|
||||
const {species: eventSpecies, eventData} = eventOnlyData;
|
||||
let legal = false;
|
||||
for (const event of eventData) {
|
||||
if (this.validateEvent(set, event, eventSpecies)) continue;
|
||||
|
||||
@@ -651,7 +651,7 @@ describe('Team Validator', function () {
|
||||
assert(illegal);
|
||||
});
|
||||
|
||||
it.skip('should not allow evolutions of Shiny-locked events to be Shiny', function () {
|
||||
it('should not allow evolutions of Shiny-locked events to be Shiny', function () {
|
||||
const team = [
|
||||
{species: 'urshifu', ability: 'unseenfist', shiny: true, moves: ['snore'], evs: {hp: 1}},
|
||||
{species: 'cosmoem', ability: 'sturdy', shiny: true, moves: ['teleport'], evs: {hp: 1}},
|
||||
|
||||
Reference in New Issue
Block a user