diff --git a/data/random-teams.ts b/data/random-teams.ts index 203b45df69b9..eaa88fb5ec3d 100644 --- a/data/random-teams.ts +++ b/data/random-teams.ts @@ -2047,7 +2047,9 @@ export class RandomTeams { // Picks `n` random pokemon--no repeats, even among formes // Also need to either normalize for formes or select formes at random // Unreleased are okay but no CAP + const last = [0, 151, 251, 386, 493, 649, 721, 807, 898, 1017][this.gen]; + if (n <= 0 || n > last) throw new Error(`n must be a number between 1 and ${last} (got ${n})`); if (requiredType && !this.dex.types.get(requiredType).exists) { throw new Error(`"${requiredType}" is not a valid type.`); } @@ -2069,6 +2071,7 @@ export class RandomTeams { if (minSourceGen && species.gen < minSourceGen) continue; const num = species.num; if (num <= 0 || pool.includes(num)) continue; + if (num > last) break; pool.push(num); } } else {