From cd5e357b6738e4de83a02cd374ff8c6f140b4f95 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sat, 25 Jul 2015 19:54:19 -0400 Subject: [PATCH] Track PP for moves --- js/battle.js | 28 +++++++++++++++++++++++++--- js/client-battle.js | 17 +++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/js/battle.js b/js/battle.js index 37d3f6bdd..f58a6b5b8 100644 --- a/js/battle.js +++ b/js/battle.js @@ -190,6 +190,7 @@ var Pokemon = (function () { this.turnstatuses = {}; this.movestatuses = {}; this.lastmove = ''; + this.moveTrack = []; this.name = ''; this.species = ''; @@ -516,6 +517,17 @@ var Pokemon = (function () { this.clearTurnstatuses(); this.clearMovestatuses(); }; + Pokemon.prototype.markMove = function(moveName, noPP) { + moveName = Tools.getMove(moveName).name; + if (this.volatiles.transform) moveName = '*' + moveName; + for (var i = 0; i < this.moveTrack.length; i++) { + if (moveName === this.moveTrack[i][0]) { + if (!noPP) this.moveTrack[i][1]++; + return; + } + } + this.moveTrack.push([moveName, noPP ? 0 : 1]); + }; Pokemon.prototype.getName = function (shortName) { if (this.side.n === 0) { return Tools.escapeHTML(this.name); @@ -618,6 +630,12 @@ var Pokemon = (function () { this.spe = this.speStat; this.boosts = {}; this.clearVolatiles(); + for (var i = 0; i < this.moveTrack.length; i++) { + if (this.moveTrack[i][0].charAt(0) === '*') { + this.moveTrack.splice(i, 1); + i--; + } + } //this.lastmove = ''; this.statusStage = 0; }; @@ -3032,7 +3050,7 @@ var Battle = (function () { } else if (window.Config && Config.server && Config.server.afd && (move.id === 'metronome' || move.id === 'sleeptalk' || move.id === 'assist')) { this.message(pokemon.getName() + ' used ' + move.name + '!'); var buttons = ["A", "B", "START", "SELECT", "UP", "DOWN", "LEFT", "RIGHT", "DEMOCRACY", "ANARCHY"]; - var people = ["Zarel", "The Immortal", "Diatom", "Nani Man", "shaymin", "apt-get", "sirDonovan", "Arcticblast", "Goddess Briyella"]; + var people = ["Zarel", "The Immortal", "Diatom", "Nani Man", "shaymin", "apt-get", "sirDonovan", "Arcticblast", "Trickster"]; var button; for (var i = 0; i < 10; i++) { var name = people[Math.floor(Math.random() * people.length)]; @@ -3040,11 +3058,12 @@ var Battle = (function () { this.log('
' + Tools.escapeHTML(name) + ': ' + button + '
'); button = (name === 'Diatom' ? "thanks diatom" : null); } - } else if (window.Config && Config.server && Config.server.afd && (move.id === 'taunt')) { - this.message(pokemon.getName() + ' used ' + move.name + '!'); } else { this.message(pokemon.getName() + ' used ' + move.name + '!'); } + if (!fromeffect.id) { + pokemon.markMove(move.name); + } break; } if (window.Config && Config.server && Config.server.afd && move.id === 'taunt') { @@ -4801,6 +4820,9 @@ var Battle = (function () { break; case 'forewarn': actions += "" + poke.getName() + "'s Forewarn alerted it to " + Tools.escapeHTML(args[3]) + "!"; + if (poke.side.foe.active.length === 1) { + poke.side.foe.active[0].markMove(args[3], true); + } break; case 'anticipation': actions += "" + poke.getName() + " shuddered!"; diff --git a/js/client-battle.js b/js/client-battle.js index a9618afc0..3da849218 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -1109,6 +1109,23 @@ text += '⋅ ' + name + '
'; } text += '

'; + } else if (pokemon.moveTrack && pokemon.moveTrack.length) { + text += '

'; + for (var i = 0; i < pokemon.moveTrack.length; i++) { + var moveName = pokemon.moveTrack[i][0]; + var move, maxpp; + if (moveName.charAt(0) === '*') { + moveName = moveName.substr(1); + move = Tools.getMove(moveName); + maxpp = 5; + } else { + move = Tools.getMove(moveName); + maxpp = Math.floor(move.pp * 8 / 5); + } + var pp = maxpp - pokemon.moveTrack[i][1]; + text += '⋅ ' + move.name + ' (' + pp + '/' + maxpp + ')
'; + } + text += '

'; } text += ''; break;