diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js
index 8ab4cafba..70a520fd8 100644
--- a/js/client-teambuilder.js
+++ b/js/client-teambuilder.js
@@ -18,6 +18,7 @@
this.buildMovelists();
if (this.curTeam) {
this.curTeam.iconCache = '!';
+ this.curTeam.gen = this.getGen(this.curTeam.format);
Storage.activeSetList = this.curSetList;
}
},
@@ -229,6 +230,7 @@
i = +i;
this.curTeam = teams[i];
this.curTeam.iconCache = '!';
+ this.curTeam.gen = this.getGen(this.curTeam.format);
Storage.activeSetList = this.curSetList = Storage.unpackTeam(this.curTeam.team);
this.curTeamIndex = i;
this.update();
@@ -620,14 +622,16 @@
'N': '—'
};
buf += '' + (set.level || 100) + '';
- buf += '' + GenderChart[template.gender || set.gender || 'N'] + '';
- buf += '' + (typeof set.happiness === 'number' ? set.happiness : 255) + '';
- buf += '' + (set.shiny ? 'Yes' : 'No') + '';
+ if (this.curTeam.gen > 1) {
+ buf += '' + GenderChart[template.gender || set.gender || 'N'] + '';
+ buf += '' + (typeof set.happiness === 'number' ? set.happiness : 255) + '';
+ buf += '' + (set.shiny ? 'Yes' : 'No') + '';
+ }
buf += '';
buf += '
';
// moves
@@ -644,6 +648,7 @@
buf += ' EV';
var stats = {};
for (var j in BattleStatNames) {
+ if (j === 'spd' && this.curTeam.gen === 1) continue;
stats[j] = this.getStat(j, set);
var ev = '' + (set.evs[j] || '') + '';
if (BattleNatures[set.nature] && BattleNatures[set.nature].plus === j) {
@@ -656,7 +661,8 @@
if (width > 75) width = 75;
var color = Math.floor(stats[j] * 180 / 714);
if (color > 360) color = 360;
- buf += ' ' + ev + '';
+ var statName = this.curTeam.gen === 1 && j === 'spa' ? 'Spc' : BattleStatNames[j];
+ buf += ' ' + ev + '';
}
buf += '';
@@ -721,8 +727,10 @@
},
formatChange: function (e) {
this.curTeam.format = e.currentTarget.value;
+ this.curTeam.gen = this.getGen(this.curTeam.format);
this.save();
- if (this.curTeam.format.substr(0, 4) === 'gen5' && !Tools.loadedSpriteData['bw']) Tools.loadSpriteData('bw');
+ if (this.curTeam.gen === 5 && !Tools.loadedSpriteData['bw']) Tools.loadSpriteData('bw');
+ this.update();
},
nicknameChange: function (e) {
var i = +$(e.currentTarget).closest('li').attr('value');
@@ -1025,6 +1033,7 @@
// stat cell
var buf = ' EV';
for (var stat in stats) {
+ if (stat === 'spd' && this.curTeam.gen === 1) continue;
stats[stat] = this.getStat(stat, set);
var ev = '' + (set.evs[stat] || '') + '';
if (BattleNatures[set.nature] && BattleNatures[set.nature].plus === stat) {
@@ -1053,6 +1062,7 @@
buf = '';
var totalev = 0;
for (var stat in stats) {
+ if (stat === 'spd' && this.curTeam.gen === 1) continue;
var width = stats[stat] * 180 / 504;
if (stat == 'hp') width = stats[stat] * 180 / 704;
if (width > 179) width = 179;
@@ -1064,10 +1074,11 @@
buf += 'Remaining:
';
this.$chart.find('.graphcol').html(buf);
- if (totalev <= 510) {
- this.$chart.find('.totalev').html('' + (totalev > 508 ? 0 : 508 - totalev) + '');
+ var maxEv = this.curTeam.gen > 2 ? 510 : this.curTeam.gen === 1 ? 1275 : 1530;
+ if (totalev <= maxEv) {
+ this.$chart.find('.totalev').html('' + (totalev > (maxEv-2) ? 0 : (maxEv-2) - totalev) + '');
} else {
- this.$chart.find('.totalev').html('' + (510 - totalev) + '');
+ this.$chart.find('.totalev').html('' + (maxEv - totalev) + '');
}
this.$chart.find('select[name=nature]').val(set.nature || 'Serious');
},
@@ -1096,7 +1107,7 @@
this.updateChartTimeout = setTimeout(function () {
self.updateChartTimeout = null;
if (self.curChartType === 'stats' || self.curChartType === 'details' || !self.curChartName) return;
- self.$chart.html(Chart.chart(self.$('input[name=' + self.curChartName + ']').val(), self.curChartType, true, _.bind(self.arrangeCallback[self.curChartType], self)));
+ self.$chart.html(Chart.chart(self.$('input[name=' + self.curChartName + ']').val(), self.curChartType, true, _.bind(self.arrangeCallback[self.curChartType], self), null, self.curTeam.gen));
}, 10);
},
updateChartTimeout: null,
@@ -1111,7 +1122,7 @@
this.updateChartTimeout = setTimeout(function () {
self.updateChartTimeout = null;
if (self.curChartType === 'stats' || self.curChartType === 'details') return;
- self.$chart.html(Chart.chart(self.$('input[name=' + self.curChartName + ']').val(), self.curChartType, false, _.bind(self.arrangeCallback[self.curChartType], self)));
+ self.$chart.html(Chart.chart(self.$('input[name=' + self.curChartName + ']').val(), self.curChartType, false, _.bind(self.arrangeCallback[self.curChartType], self), null, self.curTeam.gen));
}, 200);
},
selectPokemon: function (i) {
@@ -1226,14 +1237,21 @@
}
var stats = {hp:'',atk:'',def:'',spa:'',spd:'',spe:''};
+ if (this.curTeam.gen === 1) delete stats.spd;
if (!set) return;
var nature = BattleNatures[set.nature || 'Serious'];
if (!nature) nature = {};
// label column
buf += '';
- buf += '
';
- buf += '
';
+ buf += '';
+ if (this.curTeam.gen === 1) {
+ buf += '
';
+ } else {
+ buf += '';
+ }
+
+ buf += '';
buf += 'Base
';
for (var i in stats) {
@@ -1274,15 +1292,17 @@
buf += '
';
totalev += (set.evs[i] || 0);
}
- if (totalev <= 510) {
- buf += '
' + (totalev > 508 ? 0 : 508 - totalev) + '
';
+ var maxEv = this.curTeam.gen > 2 ? 510 : this.curTeam.gen === 1 ? 1275 : 1530;
+ if (totalev <= maxEv) {
+ buf += '
' + (totalev > (maxEv-2) ? 0 : (maxEv-2) - totalev) + '
';
} else {
- buf += '
' + (510 - totalev) + '
';
+ buf += '
' + (maxEv - totalev) + '
';
}
buf += '
';
buf += '';
for (var i in stats) {
+ if (i === 'spd' && this.curTeam.gen === 1) continue;
buf += '
';
}
buf += '
';
@@ -1303,18 +1323,20 @@
}
buf += '';
- buf += 'Nature:
';
+ buf += '';
- buf += 'Protip: You can also set natures by typing "+" and "-" next to a stat.
';
+ buf += 'Protip: You can also set natures by typing "+" and "-" next to a stat.
';
+ }
buf += '';
this.$chart.html(buf);
@@ -1491,23 +1513,25 @@
buf += '';
- buf += '';
-
- buf += '';
-
- buf += '';
buf += '';
this.$chart.html(buf);
@@ -1551,9 +1575,11 @@
'N': '—'
};
buf += '' + (set.level || 100) + '';
- buf += '' + GenderChart[set.gender || 'N'] + '';
- buf += '' + (typeof set.happiness === 'number' ? set.happiness : 255) + '';
- buf += '' + (set.shiny ? 'Yes' : 'No') + '';
+ if (this.curTeam.gen > 1) {
+ buf += '' + GenderChart[set.gender || 'N'] + '';
+ buf += '' + (typeof set.happiness === 'number' ? set.happiness : 255) + '';
+ buf += '' + (set.shiny ? 'Yes' : 'No') + '';
+ }
this.$('button[name=details]').html(buf);
this.save();
@@ -1648,7 +1674,7 @@
e.preventDefault();
var name = e.currentTarget.name;
- this.$chart.html(Chart.chart(e.currentTarget.value, this.curChartType, false, _.bind(this.arrangeCallback[this.curChartType], this)));
+ this.$chart.html(Chart.chart(e.currentTarget.value, this.curChartType, false, _.bind(this.arrangeCallback[this.curChartType], this), null, this.curTeam.gen));
var val = Chart.firstResult;
this.chartSet(val, true);
return;
@@ -1689,7 +1715,7 @@
if (this.arrangeCallback[this.curChartType]) {
arrange = _.bind(this.arrangeCallback[this.curChartType], this);
}
- this.$chart.html(Chart.chart(e.currentTarget.value, type, false, arrange));
+ this.$chart.html(Chart.chart(e.currentTarget.value, type, false, arrange, null, this.curTeam.gen));
var val = Chart.firstResult;
var id = toId(e.currentTarget.value);
if (toId(val) !== id) {
@@ -2325,6 +2351,11 @@
this.movelist = Tools.movelists[speciesid];
}
},
+ getGen: function (format) {
+ format = '' + format;
+ if (format.substr(0, 3) !== 'gen') return 6;
+ return parseInt(format.substr(3, 1)) || 6;
+ },
destroy: function () {
app.clearGlobalListeners();
Room.prototype.destroy.call(this);
diff --git a/js/utilichart.js b/js/utilichart.js
index f862e259b..227f7b8ca 100644
--- a/js/utilichart.js
+++ b/js/utilichart.js
@@ -40,23 +40,23 @@ function BattleChart() {
if (self.selectCallback) self.selectCallback(x);
};
- this.row = function (thing, attrs, match, isFirst, dataCommand) {
+ this.row = function (thing, attrs, match, isFirst, dataCommand, gen) {
if (isFirst) {
self.firstResult = thing.name;
}
attrs = attrs || '';
switch (match.thingType) {
case 'pokemon':
- return self.pokemonRow(thing, attrs, match, isFirst, dataCommand);
+ return self.pokemonRow(thing, attrs, match, isFirst, dataCommand, gen);
case 'item':
return self.itemRow(thing, attrs, match, isFirst, dataCommand);
case 'ability':
return self.abilityRow(thing, attrs, match, isFirst, dataCommand);
case 'move':
- return self.moveRow(thing, attrs, match, isFirst, dataCommand);
+ return self.moveRow(thing, attrs, match, isFirst, dataCommand, gen);
}
};
- this.pokemonRow = function (pokemon, attrs, match, isFirst, dataCommand) {
+ this.pokemonRow = function (pokemon, attrs, match, isFirst, dataCommand, gen) {
var tag = dataCommand ? 'div' : 'a';
var text = '<' + tag + attrs + ' data-name="' + Tools.escapeHTML(pokemon.species) + '">';
@@ -105,36 +105,42 @@ function BattleChart() {
}
text += ' ';
- text += '';
- if (pokemon.abilities['1']) {
- text += '';
- }
- else {
- text += '';
- }
- for (var i in pokemon.abilities) {
- var ability = pokemon.abilities[i];
- if (!ability) continue;
+ if (!gen || gen > 2) {
+ text += '';
+ if (pokemon.abilities['1']) {
+ text += '';
+ }
+ else {
+ text += '';
+ }
+ for (var i in pokemon.abilities) {
+ var ability = pokemon.abilities[i];
+ if (!ability) continue;
- if (i === '1') text += '
';
- if (match.ability && match.ability[i]) {
- ability = ability.substr(0, match.ability[i].start) + '' + ability.substr(match.ability[i].start, match.ability[i].end - match.ability[i].start) + '' + ability.substr(match.ability[i].end);
+ if (i === '1') text += '
';
+ if (match.ability && match.ability[i]) {
+ ability = ability.substr(0, match.ability[i].start) + '' + ability.substr(match.ability[i].start, match.ability[i].end - match.ability[i].start) + '' + ability.substr(match.ability[i].end);
+ }
+ if (i == 'H') {
+ ability = '' + (pokemon.unreleasedHidden ? '' + ability + '' : ability) + '';
+ }
+ text += ability;
}
- if (i == 'H') {
- ability = '' + (pokemon.unreleasedHidden ? '' + ability + '' : ability) + '';
- }
- text += ability;
+ if (!pokemon.abilities['H']) text += '';
+ text += '';
+ text += '';
}
- if (!pokemon.abilities['H']) text += '';
- text += '';
- text += '';
text += '';
text += 'HP
' + pokemon.baseStats.hp + ' ';
text += 'Atk
' + pokemon.baseStats.atk + ' ';
text += 'Def
' + pokemon.baseStats.def + ' ';
- text += 'SpA
' + pokemon.baseStats.spa + ' ';
- text += 'SpD
' + pokemon.baseStats.spd + ' ';
+ if (!gen || gen > 1) {
+ text += 'SpA
' + pokemon.baseStats.spa + ' ';
+ text += 'SpD
' + pokemon.baseStats.spd + ' ';
+ } else {
+ text += 'Spc
' + pokemon.baseStats.spa + ' ';
+ }
text += 'Spe
' + pokemon.baseStats.spe + ' ';
var bst = 0;
for (i in pokemon.baseStats) bst += pokemon.baseStats[i];
@@ -195,7 +201,7 @@ function BattleChart() {
return text;
};
- this.moveRow = function (move, attrs, match, isFirst) {
+ this.moveRow = function (move, attrs, match, isFirst, gen) {
var text = '';
var name = Tools.escapeHTML(move.name);
@@ -236,7 +242,7 @@ function BattleChart() {
return text;
};
- this.chart = function (searchTerm, type, init, thisArrange, thisSort) {
+ this.chart = function (searchTerm, type, init, thisArrange, thisSort, gen) {
if (!searchTerm) searchTerm = '';
else searchTerm = searchTerm.toLowerCase();
if (!init && searchTerm === self.lastSearch) return;
@@ -267,28 +273,74 @@ function BattleChart() {
self.pokemon.sort(thisSort);
self.lastPokemonSort = thisSort;
}
- things = self.pokemon;
+ if (gen > 0) {
+ things = self.pokemon.filter(function (mon) {
+ if (gen < 6 && mon.forme.substr(0, 4) === 'Mega') return false;
+ if (gen === 1 && mon.num > 151) return false;
+ if (gen === 2 && mon.num > 251) return false;
+ if (gen === 3 && mon.num > 386) return false;
+ if (gen === 4 && mon.num > 493) return false;
+ if (gen === 5 && mon.num > 649) return false;
+ if (gen === 6 && mon.num > 721) return false;
+ return true;
+ });
+ } else {
+ things = self.pokemon;
+ }
break;
case 'item':
if (thisSort !== self.lastItemSort) {
self.items.sort(thisSort);
self.lastItemSort = thisSort;
}
- things = self.items;
+ if (gen > 0) {
+ things = self.items.filter(function (item) {
+ if (gen === 1) return false;
+ if (gen === 2 && item.gen > 2) return false;
+ if (gen === 3 && item.gen > 3) return false;
+ if (gen === 4 && item.gen > 4) return false;
+ if (gen === 5 && item.gen > 5) return false;
+ return true;
+ });
+ } else {
+ things = self.items;
+ }
break;
case 'ability':
if (thisSort !== self.lastAbilitySort) {
self.abilities.sort(thisSort);
self.lastAbilitySort = thisSort;
}
- things = self.abilities;
+ if (gen > 0) {
+ things = self.abilities.filter(function (ability) {
+ console.log(ability);
+ if (gen < 3) return false;
+ if (gen === 3 && ability.num > 76) return false;
+ if (gen === 4 && ability.num > 123) return false;
+ if (gen === 5 && ability.num > 164) return false;
+ return true;
+ });
+ } else {
+ things = self.abilities;
+ }
break;
case 'move':
if (thisSort !== self.lastMoveSort) {
self.moves.sort(thisSort);
self.lastMoveSort = thisSort;
}
- things = self.moves;
+ if (gen > 0) {
+ things = self.moves.filter(function (move) {
+ if (gen === 1 && (move.num > 165 || move.id === 'hiddenpower')) return false;
+ if (gen === 2 && move.num > 251) return false;
+ if (gen === 3 && move.num > 354) return false;
+ if (gen === 4 && move.num > 467) return false;
+ if (gen === 5 && move.num > 559) return false;
+ return true;
+ });
+ } else {
+ things = self.moves;
+ }
break;
}
@@ -429,7 +481,7 @@ function BattleChart() {
if (firstMatch) {
text += 'Matches
';
}
- text += self.row(match.thing, '', match, firstMatch);
+ text += self.row(match.thing, '', match, firstMatch, null, gen);
firstMatch = false;
}
}
@@ -450,7 +502,7 @@ function BattleChart() {
if (firstMatch) {
text += 'Details Matches
';
}
- text += self.row(match.thing, '', match, firstMatch && noNameMatch);
+ text += self.row(match.thing, '', match, firstMatch && noNameMatch, null, gen);
firstMatch = false;
}
}
@@ -461,7 +513,7 @@ function BattleChart() {
if (firstMatch) {
text += 'Details Matches
';
}
- text += self.row(match.thing, '', match, firstMatch && noNameMatch);
+ text += self.row(match.thing, '', match, firstMatch && noNameMatch, null, gen);
firstMatch = false;
}
}
@@ -477,7 +529,7 @@ function BattleChart() {
text += '' + buckets[i] + '
';
firstMatch = false;
}
- text += self.row(match.thing, '', match);
+ text += self.row(match.thing, '', match, null, null, gen);
}
}
}