Skip to content

Commit

Permalink
Add Learnsets validator
Browse files Browse the repository at this point in the history
I didn't have time to fix all the errors the validator found, but I
fixed half of them.
  • Loading branch information
Zarel committed Jun 2, 2020
1 parent e378a0b commit 36941fe
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 28 deletions.
56 changes: 28 additions & 28 deletions data/learnsets.ts
Expand Up @@ -10846,12 +10846,12 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
farfetchd: {
learnset: {
acrobatics: ["8M", "7M", "7L37", "6M", "6L37", "5M", "5L37"],
aerialace: ["8L20", "7M", "7L9", "6M", "6L9", "5M", "5L13", "4M", "4L13", "3M", "3S0"],
aerialace: ["8L20", "7M", "7L9", "6M", "6L9", "5M", "5L13", "4M", "4L13", "3M", "3S1"],
agility: ["8M", "8L60", "8V", "7L31", "7V", "6L31", "5L31", "4L31", "3L36"],
aircutter: ["8L25", "7L21", "6L21", "5L21", "4T", "4L21"],
airslash: ["8M", "8L50", "8V", "7L49", "6L49", "5L49", "4L37"],
attract: ["8M", "7M", "7V", "6M", "5M", "4M", "3M"],
batonpass: ["8M", "3S0"],
batonpass: ["8M", "3S1"],
bide: ["7V"],
bodyslam: ["8M", "7V", "3T"],
bravebird: ["8M", "8L65", "7L1", "6L1", "5L55"],
Expand Down Expand Up @@ -10918,7 +10918,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
simplebeam: ["8E", "7E", "6E"],
skullbash: ["7V"],
skyattack: ["8E", "8V", "7T", "6T", "5T"],
slash: ["8L40", "8V", "7L19", "7V", "6L19", "5L19", "4L19", "3L41", "3S0"],
slash: ["8L40", "8V", "7L19", "7V", "6L19", "5L19", "4L19", "3L41", "3S1"],
sleeptalk: ["8M", "7M", "7V", "6M", "5T", "4M", "3T"],
snore: ["8M", "7T", "7V", "6T", "5T", "4T", "3T"],
solarblade: ["8M"],
Expand All @@ -10927,7 +10927,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
sunnyday: ["8M", "7M", "7V", "6M", "5M", "4M", "3M"],
swagger: ["7M", "7V", "6M", "5M", "4M", "3T"],
swift: ["8M", "7V", "4T", "3T"],
swordsdance: ["8M", "8L45", "8V", "7M", "7L25", "7V", "6M", "6L25", "5M", "5L25", "4M", "4L25", "3T", "3L31", "3S0"],
swordsdance: ["8M", "8L45", "8V", "7M", "7L25", "7V", "6M", "6L25", "5M", "5L25", "4M", "4L25", "3T", "3L31", "3S1"],
tailwind: ["7T", "6T", "5T"],
takedown: ["7V"],
thief: ["8M", "7M", "7V", "6M", "5M", "4M", "3M"],
Expand Down Expand Up @@ -24524,11 +24524,11 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
learnset: {
amnesia: ["8M", "8L1"],
charm: ["8M", "8L1", "7L1", "6L1", "5L1", "4L1", "3L1", "3S0"],
counter: ["8L1", "7L15", "6L15", "5L15", "4L15", "3L15", "3S0"],
destinybond: ["8L1", "7L15", "6L15", "5L15", "4L15", "3L15", "3S0"],
counter: ["8L1", "7L15", "6L15", "5L15", "4L15", "3L15"],
destinybond: ["8L1", "7L15", "6L15", "5L15", "4L15", "3L15"],
encore: ["8M", "8L1", "7L1", "6L1", "5L1", "4L1", "3L1", "3S0"],
mirrorcoat: ["8L1", "7L15", "6L15", "5L15", "4L15", "3L15", "3S0"],
safeguard: ["8M", "8L1", "7M", "7L15", "6M", "6L15", "5L15", "4L15", "3L15", "3S0"],
mirrorcoat: ["8L1", "7L15", "6L15", "5L15", "4L15", "3L15"],
safeguard: ["8M", "8L1", "7M", "7L15", "6M", "6L15", "5L15", "4L15", "3L15"],
splash: ["8L1", "7L1", "6L1", "5L1", "4L1", "3L1", "3S0"],
tickle: ["3S0"],
},
Expand Down Expand Up @@ -27887,7 +27887,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
hydropump: ["7L71", "7V", "6L1", "5L71", "4L71", "3L71"],
hyperbeam: ["7M", "7V", "6M", "5M", "4M", "3M"],
icebeam: ["7M", "6M", "5M", "4M", "3M"],
icefang: ["7L50", "6L50", "5L50", "4L50"],
icefang: ["7L50", "6L50", "6S4", "5L50", "4L50"],
icywind: ["7T", "7V", "6T", "5T", "4T", "3T"],
ironhead: ["7T", "6T", "5T", "4T"],
irontail: ["7T", "7V", "6T", "5T", "4M", "3M"],
Expand All @@ -27902,7 +27902,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
protect: ["7M", "7V", "6M", "5M", "4M", "3M"],
psychup: ["7M", "7V", "6M", "5M", "4M", "3T"],
quash: ["7M", "6M", "5M"],
raindance: ["7M", "7L1", "7S5", "7V", "6M", "6L15", "6S4", "5M", "5L15", "4M", "4L15", "4S2", "3M", "3L21", "3S0"],
raindance: ["7M", "7L1", "7S5", "7V", "6M", "6L15", "5M", "5L15", "4M", "4L15", "4S2", "3M", "3L21", "3S0"],
reflect: ["7M", "6M", "5M", "4M", "3M"],
rest: ["7M", "7V", "6M", "5M", "4M", "3M"],
return: ["7M", "7V", "6M", "5M", "4M", "3M"],
Expand Down Expand Up @@ -31003,7 +31003,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
drainingkiss: ["8M", "8L12", "7L22", "6L22"],
dreameater: ["8L36", "7M", "7L39", "6M", "6L39", "5M", "5L50", "4M", "4L45", "3T", "3L46"],
echoedvoice: ["7M", "6M", "5M"],
encore: ["8M", "7E", "6E", "6S0", "5E", "4E"],
encore: ["8M", "7E", "6E", "6S3", "5E", "4E"],
endure: ["8M", "4M", "3T"],
facade: ["8M", "7M", "6M", "5M", "4M", "3M"],
firepunch: ["8M", "7T", "6T", "5T", "4T", "3T"],
Expand All @@ -31012,7 +31012,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
frustration: ["7M", "6M", "5M", "4M", "3M"],
futuresight: ["8M", "8L39", "7L32", "6L32", "5L39", "4L34", "3L36"],
grassknot: ["8M", "7M", "6M", "5M", "4M"],
growl: ["8L1", "7L1", "6L1", "6S0", "5L1", "4L1", "3L1", "3S1", "3S0"],
growl: ["8L1", "7L1", "6L1", "6S3", "5L1", "4L1", "3L1", "3S1", "3S0"],
grudge: ["8E", "7E", "6E", "5E", "4E"],
headbutt: ["4T"],
healpulse: ["8L33", "7L19", "6L19", "5L23"],
Expand Down Expand Up @@ -35983,7 +35983,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
swagger: ["7M", "6M", "5M", "4M", "3T"],
swift: ["4T", "3T"],
tailwind: ["7T", "6T", "5T", "4T"],
takedown: ["7L23", "6L23", "5L28", "5S2", "4L28", "3L31", "3S1", "3S0"],
takedown: ["7L23", "6L23", "5L28", "5S2", "4L28", "3L31", "3S0"],
thief: ["7M", "6M", "5M", "4M", "3M"],
toxic: ["7M", "6M", "5M", "4M", "3M"],
twister: ["4T"],
Expand Down Expand Up @@ -40278,11 +40278,11 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
dragonpulse: ["7T", "7L50", "7S8", "6T", "6L50", "6S5", "6S4", "5T", "5L90", "5S3", "5S2", "4M", "4L75"],
dragontail: ["7M", "6M", "5M"],
earthpower: ["7T", "6T", "5T", "4T"],
earthquake: ["7M", "6M", "6S6", "5M", "4M", "3M"],
earthquake: ["7M", "6M", "5M", "4M", "3M"],
echoedvoice: ["7M", "6M", "5M"],
endure: ["4M", "3T"],
energyball: ["7M", "6M", "5M", "4M"],
extremespeed: ["7L45", "7S8", "6L45", "6S5", "6S4", "5L75", "5S3", "4L60", "3L60", "3S0"],
extremespeed: ["7L45", "7S8", "6L45", "6S6", "6S5", "6S4", "5L75", "5S3", "4L60", "3L60", "3S0"],
facade: ["7M", "6M", "5M", "4M", "3M"],
fireblast: ["7M", "6M", "5M", "4M", "3M"],
flamethrower: ["7M", "6M", "5M", "4M", "3M"],
Expand Down Expand Up @@ -45741,7 +45741,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
irontail: ["7T", "6T", "5T", "4M"],
knockoff: ["7T", "6T", "5T", "4T"],
laserfocus: ["7T"],
lastresort: ["7T", "7L1", "6T", "6L1", "5T", "5L61", "4T", "4L61"],
lastresort: ["7T", "7L1", "6T", "6L1", "5T", "5L61", "5S2", "4T", "4L61"],
lightscreen: ["7M", "6M", "5M", "4M"],
magiccoat: ["7T", "6T", "5T", "4T"],
magicroom: ["7T", "6T", "5T"],
Expand Down Expand Up @@ -45785,7 +45785,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
toxic: ["7M", "6M", "5M", "4M"],
trick: ["7T", "6T", "5T", "4T"],
trickroom: ["7M", "6M", "5M", "4M"],
uproar: ["7T", "7L31", "7S4", "6T", "6L31", "6S3", "5T", "5L31", "5S2", "4T", "4L31", "4S1", "4S0"],
uproar: ["7T", "7L31", "7S4", "6T", "6L31", "6S3", "5T", "5L31", "4T", "4L31", "4S1", "4S0"],
uturn: ["7M", "6M", "5M", "4M"],
waterpulse: ["7T", "6T", "4M"],
wonderroom: ["7T", "6T", "5T"],
Expand Down Expand Up @@ -46312,7 +46312,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
naturalgift: ["4M"],
protect: ["7M", "6M", "5M", "4M"],
psychic: ["7M", "7L93", "6M", "6L93", "5M", "5L93", "4M", "4L93"],
psychocut: ["7L1", "6L1", "5L66", "4L66"],
psychocut: ["7L1", "6L1", "5L66", "5S1", "4L66"],
psychoshift: ["7L1", "6L1", "5L75", "4L75"],
psychup: ["7M", "6M", "5M", "4M"],
psyshock: ["7M", "6M", "5M", "5S2"],
Expand All @@ -46338,7 +46338,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
telekinesis: ["7T", "5M"],
thunderwave: ["7M", "6M", "5M", "4M"],
toxic: ["7M", "6M", "5M", "4M"],
trick: ["7T", "6T", "5T", "5S1", "4T"],
trick: ["7T", "6T", "5T", "4T"],
trickroom: ["7M", "6M", "5M", "4M"],
zenheadbutt: ["7T", "6T", "5T", "4T"],
},
Expand Down Expand Up @@ -57955,8 +57955,8 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
doubleteam: ["7M", "6M", "5M"],
earthpower: ["7T", "7L37", "7S4", "6T", "6L43", "6S2", "5T", "5L43"],
earthquake: ["7M", "7L49", "7S4", "6M", "6L55", "6S3", "5M", "5L55", "5S0"],
explosion: ["7M", "6M", "6S2", "5M"],
extrasensory: ["7L25", "6L31", "5L31"],
explosion: ["7M", "6M", "5M"],
extrasensory: ["7L25", "6L31", "6S2", "5L31"],
facade: ["7M", "6M", "5M"],
fissure: ["7L1", "6L1", "5L67", "5S0"],
fling: ["7M", "6M", "5M"],
Expand Down Expand Up @@ -63700,17 +63700,18 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
eventData: [
{generation: 6, level: 70, moves: ["crunch", "earthquake", "camouflage", "dragonpulse"]},
{generation: 6, level: 100, moves: ["landswrath", "extremespeed", "glare", "outrage"], pokeball: "cherishball"},
{generation: 7, level: 30, moves: ["safeguard", "dig", "bind", "landswrath"]},
{generation: 7, level: 30, moves: ["safeguard", "dig", "bind", "landswrath"]}, // 10%
{generation: 7, level: 50, moves: ["bind", "landswrath", "sandstorm", "haze"]},
{generation: 7, level: 50, isHidden: true, moves: ["bind", "landswrath", "sandstorm", "haze"]},
{generation: 7, level: 60, shiny: true, moves: ["landswrath", "glare", "safeguard", "dragonbreath"], pokeball: "cherishball"},
{generation: 7, level: 60, shiny: true, isHidden: true, moves: ["landswrath", "glare", "safeguard", "dragonbreath"], pokeball: "cherishball"},
{generation: 7, level: 60, shiny: true, isHidden: true, moves: ["landswrath", "glare", "safeguard", "dragonbreath"], pokeball: "cherishball"}, // 10%
{generation: 7, level: 100, shiny: true, moves: ["thousandarrows", "outrage", "extremespeed", "dragondance"], pokeball: "cherishball"},
{generation: 7, level: 100, shiny: true, isHidden: true, moves: ["thousandarrows", "outrage", "extremespeed", "dragondance"], pokeball: "cherishball"},
{generation: 7, level: 100, shiny: true, isHidden: true, moves: ["thousandarrows", "outrage", "extremespeed", "dragondance"], pokeball: "cherishball"}, // 10%
],
eventOnly: true,
},
zygarde10: {
// FIXME: figure out what's going on here
eventData: [
{generation: 7, level: 30, moves: ["safeguard", "dig", "bind", "landswrath"]},
{generation: 7, level: 50, isHidden: true, moves: ["safeguard", "dig", "bind", "landswrath"]},
Expand Down Expand Up @@ -75993,8 +75994,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
stratagem: {
learnset: {
accelerock: ["8L21", "7L21"],
accupressure: ["8L26"],
acupressure: ["7L26", "4L20"],
acupressure: ["7L26", "4L20", "8L26"],
aerialace: ["7M", "4M"],
ancientpower: ["8L30", "7L30", "4T"],
bulldoze: ["8M", "7M"],
Expand Down Expand Up @@ -76297,8 +76297,8 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
dragontail: ["8L24", "7M"],
earthquake: ["8M", "7M", "4M"],
eerieimpulse: ["8M"],
electoball: ["8M"],
electricterrain: ["8M", "8L1", "7L1"],
electroball: ["8M"],
electroweb: ["8M", "7T"],
endure: ["8M", "4M"],
facade: ["8M", "7M", "4M"],
Expand Down Expand Up @@ -76758,7 +76758,7 @@ export const BattleLearnsets: {[speciesid: string]: LearnsetData} = {
naturepower: ["8E", "7M"],
overheat: ["7M", "4M"],
petalblizzard: ["8E", "7E"],
petaldance: ["7L 46", "4L29"],
petaldance: ["7L46", "4L29"],
protect: ["7M", "4M"],
rest: ["7M", "4M"],
return: ["7M", "4M"],
Expand Down
56 changes: 56 additions & 0 deletions test/sim/data.js
Expand Up @@ -138,4 +138,60 @@ describe('Dex data', function () {
assert.equal(toID(entry.name), formatid, `Mismatched Format/Ruleset key "${formatid}" of "${entry.name}"`);
}
});

it('should have valid Learnsets entries', function () {
const Learnsets = Dex.data.Learnsets;
for (const speciesid in Learnsets) {
const species = Dex.getSpecies(speciesid);
assert.equal(speciesid, species.id, `Key "${speciesid}" in Learnsets should be a Species ID`);
assert(species.exists, `Key "${speciesid}" in Learnsets should be a pokemon`);
const entry = Learnsets[speciesid];
for (const moveid in entry.learnset) {
const move = Dex.getMove(moveid);
assert.equal(moveid, move.id, `Move key "${moveid}" of Learnsets entry ${species.name} should be a Move ID`);
assert(move.exists && !move.realMove, `Move key "${moveid}" of Learnsets entry ${species.name} should be a real move`);

// FIXME: too messy to fix now, will fix later
if (speciesid === 'zygarde') continue;

for (const learned of entry.learnset[moveid]) {
// See the definition of MoveSource in sim/global-types
assert(/^[1-8][LMTRESDVC]/.test(learned), `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid`);
switch (learned.charAt(1)) {
case 'L':
assert(/^[0-9]+$/.test(learned.slice(2)), `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid: a level-up move should have the level`);
const level = parseInt(learned.slice(2));
assert(level >= 0 && level <= 100, `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid: level should be between 0 and 100`);
break;
case 'S':
assert(/^[0-9]+$/.test(learned.slice(2)), `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid: an event move should have the event number`);
const eventNum = parseInt(learned.slice(2));
const eventEntry = entry.eventData[eventNum];
assert(eventEntry, `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid: an event move's event number should be available in entry.eventData`);
assert(eventEntry.moves.includes(moveid), `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid: an event move's event entry should include that move`);
break;
default:
assert.strictEqual(learned, learned.slice(0, 2), `Learn method "${learned}" for ${species.name}'s ${move.name} is invalid: it should be 2 characters long`);
break;
}
}
}

if (entry.eventData) {
// FIXME: will fix later
if (speciesid === 'nidoking' || speciesid === 'dracozolt' || speciesid === 'arctozolt' || speciesid === 'dracovish' || speciesid === 'arctovish' || speciesid === 'caribolt' || speciesid === 'pumpkaboosuper' || speciesid === 'zygarde' || speciesid === 'zygarde10') continue;

if (speciesid.startsWith('pokestar')) continue;
for (const [i, eventEntry] of entry.eventData.entries()) {
if (eventEntry.moves) {
const learned = `${eventEntry.generation}S${i}`;
for (const eventMove of eventEntry.moves) {
assert(entry.learnset, `${species.name} has event moves but no learnset`);
assert(entry.learnset[eventMove].includes(learned), `${species.name}'s event move ${Dex.getMove(eventMove).name} should exist as "${learned}"`);
}
}
}
}
}
});
});

0 comments on commit 36941fe

Please sign in to comment.