Skip to content

Commit

Permalink
Gen 2: Learnset fixes with Gen 1 TM tradeback
Browse files Browse the repository at this point in the history
Fix 6e2ce27 missed the bigger picture and c41e781 didn't account for the special Gen 1 - Gen 2 case.
On Gen 2, you may learn egg moves that do not exist in gen 1.
Those moves make that Pokémon incompatible with Gen 1 only TMs.
However, other than that, Gen 2 mons can breed in Gen 2, tradeback to Gen 1, and acquire TMs.

This is part 1 of Gen 2 learnset fix, next one being gen 2 egg incompatibilities between them.
  • Loading branch information
Joimer committed May 13, 2015
1 parent 124ffd0 commit 17e8515
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion team-validator.js
Expand Up @@ -563,6 +563,8 @@ Validator = (function () {
var limit1 = true;
var sketch = false;
var blockedHM = false;
var blockedEgg = false;
var hasGen2EggMove = false;

var sometimesPossible = false; // is this move in the learnset at all?

Expand All @@ -586,7 +588,7 @@ Validator = (function () {
var sourcesBefore = 0;
var noPastGen = !!format.requirePentagon;
// since Gen 3, Pokemon cannot be traded to past generations
var noFutureGen = tools.gen >= 2 ? true : !!(format.banlistTable && format.banlistTable['tradeback']);
var noFutureGen = tools.gen >= 3 ? true : !!(format.banlistTable && format.banlistTable['tradeback']);

do {
alreadyChecked[template.speciesid] = true;
Expand Down Expand Up @@ -649,6 +651,7 @@ Validator = (function () {
// available as long as the source gen was or was before this gen
limit1 = false;
sourcesBefore = Math.max(sourcesBefore, parseInt(learned.charAt(0), 10));
if (tools.gen === 2 && parseInt(learned.charAt(0), 10) === 1 && hasGen2EggMove) blockedEgg = true;
} else if (learned.charAt(1) in {E:1, S:1, D:1}) {
// egg, event, or DW moves:
// only if that was the source
Expand Down Expand Up @@ -681,6 +684,9 @@ Validator = (function () {
// otherwise parent must be able to learn the move
!alreadyChecked[dexEntry.speciesid] && dexEntry.learnset && (dexEntry.learnset[move] || dexEntry.learnset['sketch'])) {
if (dexEntry.eggGroups.intersect(eggGroups).length) {
// Check if it has a move that needs to come from a prior gen to this egg move.
hasGen2EggMove = tools.gen === 2 && tools.getMove(move).gen === 2;
blockedEgg = hasGen2EggMove && tools.gen === 2 && (lsetData.sourcesBefore ? lsetData.sourcesBefore : sourcesBefore) > 0 && (lsetData.sourcesBefore ? lsetData.sourcesBefore : sourcesBefore) < parseInt(learned.charAt(0), 10);
// we can breed with it
atLeastOne = true;
sources.push(learned + dexEntry.id);
Expand Down Expand Up @@ -755,6 +761,11 @@ Validator = (function () {
lsetData.hm = move;
}

if (blockedEgg) {
// Limit Gen 2 egg moves on gen 1 when move doesn't exist
return {type:'incompatible'};
}

// Now that we have our list of possible sources, intersect it with the current list
if (!sourcesBefore && !sources.length) {
if (noPastGen && sometimesPossible) return {type:'pokebank'};
Expand Down

0 comments on commit 17e8515

Please sign in to comment.