Skip to content

Commit

Permalink
Add min source gen for event-only Pokemon (smogon#10339)
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-Comfey authored Jun 11, 2024
1 parent 8f86a98 commit 48059af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sim/team-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export class PokemonSources {
* `null` = definitely not an event egg that can be used with the Pomeg glitch
*/
pomegEventEgg?: string | null;
/**
* For event-only Pokemon that do not have a minimum source gen identified by its moves
*/
eventOnlyMinSourceGen?: number;
/**
* Some Pokemon evolve by having a move in their learnset (like Piloswine
* with Ancient Power). These can only carry three other moves from their
Expand Down Expand Up @@ -151,6 +155,7 @@ export class PokemonSources {
this.limitedEggMoves = null;
}
minSourceGen() {
if (this.eventOnlyMinSourceGen) return this.eventOnlyMinSourceGen;
if (this.sourcesBefore) return this.sourcesAfter || 1;
let min = 10;
for (const source of this.sources) {
Expand Down Expand Up @@ -877,6 +882,7 @@ export class TeamValidator {
let legal = false;
for (const event of eventData) {
if (this.validateEvent(set, setSources, event, eventSpecies)) continue;
setSources.eventOnlyMinSourceGen = event.generation;
legal = true;
break;
}
Expand Down
12 changes: 12 additions & 0 deletions test/sim/team-validator/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ describe('Team Validator', function () {
assert.false.legalTeam(team, 'gen7anythinggoes');
});

it('should identify the minimum source gen of event-only Pokemon which haven\'t already been identified by its moves', function () {
let team = [
{species: 'jirachi', ability: 'serenegrace', shiny: true, moves: ['aurasphere'], evs: {hp: 1}, ivs: {hp: 31, atk: 0, def: 31, spa: 31, spd: 31, spe: 31}},
];
assert.legalTeam(team, 'gen9ou');

team = [
{species: 'jirachi', ability: 'serenegrace', shiny: true, moves: ['hiddenpowerfighting'], nature: 'serious', evs: {hp: 1}, ivs: {hp: 31, atk: 0, def: 31, spa: 31, spd: 31, spe: 31}},
];
assert.false.legalTeam(team, 'gen7ou');
});

it.skip('should allow evolved Pokemon obtainable from events at lower levels than they could otherwise be obtained', function () {
const team = [
{species: 'dragonite', ability: 'innerfocus', moves: ['dracometeor'], evs: {hp: 1}, level: 50},
Expand Down

0 comments on commit 48059af

Please sign in to comment.