diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js index 91efdde7e..465e8c614 100644 --- a/js/client-teambuilder.js +++ b/js/client-teambuilder.js @@ -621,14 +621,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 += '
'; - buf += '
'; - buf += '
'; + if (this.curTeam.gen > 1) buf += '
'; + if (this.curTeam.gen > 2) buf += '
'; buf += '
'; // moves @@ -645,6 +647,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) { @@ -657,7 +660,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 += ''; @@ -725,6 +729,7 @@ this.curTeam.gen = this.getGen(this.curTeam.format); this.save(); if (this.curTeam.gen === 5 && !Tools.loadedSpriteData['bw']) Tools.loadSpriteData('bw'); + this.update(); }, nicknameChange: function (e) { var i = +$(e.currentTarget).closest('li').attr('value'); @@ -1027,6 +1032,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) { @@ -1055,6 +1061,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; @@ -1066,10 +1073,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'); }, @@ -1098,7 +1106,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, @@ -1113,7 +1121,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) { @@ -1228,14 +1236,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) { @@ -1276,15 +1291,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 += '
'; @@ -1305,18 +1322,20 @@ } buf += ''; - buf += '

Nature: '; + for (var i in BattleNatures) { + var curNature = BattleNatures[i]; + buf += ''; } - buf += ''; - } - buf += '

'; + 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); @@ -1488,28 +1507,30 @@ var set = this.curSet; var template = Tools.getTemplate(set.species); if (!set) return; - buf += '

Details

'; - buf += '
'; + buf += '

Details

'; + buf += ''; - buf += '
'; + buf += '
'; - buf += '
'; - if (template.gender) { - var genderTable = {'M': "Male", 'F': "Female", 'N': "Genderless"}; - buf += genderTable[template.gender]; - } else { - buf += ' '; - buf += ' '; - buf += ''; + if (this.curTeam.gen > 1) { + buf += '
'; + if (template.gender) { + var genderTable = {'M': "Male", 'F': "Female", 'N': "Genderless"}; + buf += genderTable[template.gender]; + } else { + buf += ' '; + buf += ' '; + buf += ''; + } + buf += '
'; + + buf += '
'; + + buf += '
'; + buf += ' '; + buf += ''; + buf += '
'; } - buf += '
'; - - buf += '
'; - - buf += '
'; - buf += ' '; - buf += ''; - buf += '
'; buf += '
'; this.$chart.html(buf); @@ -1553,9 +1574,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(); @@ -1650,7 +1673,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; @@ -1691,7 +1714,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) { diff --git a/js/utilichart.js b/js/utilichart.js index f862e259b..c7c699e17 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; @@ -429,7 +435,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 +456,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 +467,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 +483,7 @@ function BattleChart() { text += '
  • ' + buckets[i] + '

  • '; firstMatch = false; } - text += self.row(match.thing, '', match); + text += self.row(match.thing, '', match, null, null, gen); } } }