Skip to content

Commit

Permalink
Fix VGC '17 validation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheImmortal committed Jan 30, 2017
1 parent b82a38d commit 28ed21a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/formats.js
Expand Up @@ -212,7 +212,7 @@ exports.Formats = [
},
ruleset: ['Pokemon', 'Species Clause', 'Nickname Clause', 'Item Clause', 'Team Preview', 'Cancel Mod', 'Alola Pokedex'],
banlist: ['Illegal', 'Unreleased', 'Solgaleo', 'Lunala', 'Necrozma', 'Magearna', 'Marshadow', 'Zygarde', 'Mega'],
requirePentagon: true,
requirePlus: true,

This comment has been minimized.

Copy link
@Zarel

Zarel Feb 16, 2017

Member

What exactly is a plus? Does Gen 7 no longer use pentagons? Does Gen 7 display pentagon for gen 6 and plus for gen 7?

This comment has been minimized.

Copy link
@TheImmortal

TheImmortal Feb 16, 2017

Author Contributor

Plus is the gen 7 symbol. Pentagon is gen 6. Yes, Pokémon bred in gen 7 have plus and Pokémon transferred from gen 6 have pentagon.

This comment has been minimized.

Copy link
@Zarel

Zarel Feb 16, 2017

Member

Yeah, that's how I interpreted it in my code. Good to know I didn't get it wrong.

},
{
name: "[Gen 7] Battle Spot Doubles",
Expand Down
21 changes: 16 additions & 5 deletions team-validator.js
Expand Up @@ -340,6 +340,8 @@ class Validator {
problemString = problemString.concat(` because it can only sketch ${problem.maxSketches} move${plural}.`);
} else if (problem.type === 'pentagon') {
problemString = problemString.concat(` because it's only obtainable before gen 6.`);
} else if (problem.type === 'pastGen') {
problemString = problemString.concat(` because it's only obtainable from a previous generation.`);
} else {
problemString = problemString.concat(`.`);
}
Expand Down Expand Up @@ -453,7 +455,7 @@ class Validator {
events:
for (let i = 0; i < eventPokemon.length; i++) {
let eventData = eventPokemon[i];
if (format.requirePentagon && eventData.generation < 6) continue;
if ((format.requirePentagon && eventData.generation < 6) || (format.requirePlus && eventData.generation < 7)) continue;
if (eventData.level && set.level < eventData.level) continue;
if ((eventData.shiny === true && !set.shiny) || (!eventData.shiny && set.shiny)) continue;
if (eventData.nature && set.nature !== eventData.nature) continue;
Expand Down Expand Up @@ -685,6 +687,7 @@ class Validator {
// the equivalent of adding "every source at or before this gen" to sources
let sourcesBefore = 0;
if (lsetData.sourcesBefore === undefined) lsetData.sourcesBefore = tools.gen;
let noPastGen = !!format.requirePlus;
// Pokemon cannot be traded to past generations except in Gen 1 Tradeback
let noFutureGen = !(format.banlistTable && format.banlistTable['allowtradeback']);
// if a move can only be learned from a gen 2-5 egg, we have to check chainbreeding validity
Expand Down Expand Up @@ -720,7 +723,7 @@ class Validator {
for (let i = 0, len = lset.length; i < len; i++) {
let learned = lset[i];
let learnedGen = parseInt(learned.charAt(0));
if (format.requirePentagon && learnedGen < 6) continue;
if ((format.requirePentagon && learnedGen < 6) || (noPastGen && learnedGen < tools.gen)) continue;
if (noFutureGen && learnedGen > tools.gen) continue;

// redundant
Expand Down Expand Up @@ -767,7 +770,8 @@ class Validator {
} else if (learned.charAt(1) === 'E') {
// egg moves:
// only if that was the source
if (learnedGen >= 6 || lsetData.fastCheck) {
const noPastGenBreeding = noPastGen && tools.gen === 7;
if ((learnedGen >= 6 && !noPastGenBreeding) || lsetData.fastCheck) {
// gen 6 doesn't have egg move incompatibilities except for certain cases with baby Pokemon
learned = learnedGen + 'E' + (template.prevo ? template.id : '');
sources.push(learned);
Expand Down Expand Up @@ -807,12 +811,17 @@ class Validator {
if (!father.eggGroups.some(eggGroup => eggGroupsSet.has(eggGroup))) continue;

// detect unavailable egg moves
const fatherLatestMoveGen = parseInt(fatherSources[0].charAt(0));
if (format.requirePentagon) {
const fatherLatestMoveGen = fatherSources[0].charAt(0);
if (parseInt(fatherLatestMoveGen) < 6) continue;
atLeastOne = true;
break;
}
if (noPastGenBreeding) {
if (parseInt(fatherLatestMoveGen) < tools.gen) continue;
atLeastOne = true;
break;
}

// we can breed with it
atLeastOne = true;
Expand All @@ -823,7 +832,7 @@ class Validator {
sources.push(learned + father.id);
if (limitedEgg !== false) limitedEgg = true;
}
if (atLeastOne) {
if (atLeastOne && noPastGenBreeding) {
// gen 6+ doesn't have egg move incompatibilities except for certain cases with baby Pokemon
learned = learnedGen + 'E' + (template.prevo ? template.id : '');
sources.push(learned);
Expand All @@ -833,6 +842,7 @@ class Validator {
// chainbreeding with itself
// e.g. ExtremeSpeed Dragonite
if (!atLeastOne) {
if (noPastGenBreeding) continue;
sources.push(learned + template.id);
limitedEgg = 'self';
}
Expand Down Expand Up @@ -915,6 +925,7 @@ class Validator {
// Now that we have our list of possible sources, intersect it with the current list
if (!sourcesBefore && !sources.length) {
if (format.requirePentagon && sometimesPossible) return {type:'pentagon'};
if (noPastGen && sometimesPossible) return {type:'pastGen'};
if (incompatibleAbility) return {type:'incompatibleAbility'};
return true;
}
Expand Down

3 comments on commit 28ed21a

@Zarel
Copy link
Member

@Zarel Zarel commented on 28ed21a Jan 31, 2017

Choose a reason for hiding this comment

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

I'm not sure noPastGenBreeding is the correct name for the functionality you're looking for.

@Zarel
Copy link
Member

@Zarel Zarel commented on 28ed21a Feb 11, 2017

Choose a reason for hiding this comment

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

Also, according to many reports, this doesn't actually fix VGC validation.

@TheImmortal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

b8c56f0 should fix it

Please sign in to comment.