From 617eed7c6df111cd1b4e2ad3865ac1d2a1755fb6 Mon Sep 17 00:00:00 2001 From: urkerab Date: Sun, 20 Nov 2016 18:46:45 +0000 Subject: [PATCH] Make Terrains display minimum and maximum turns (#808) --- js/battle.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/js/battle.js b/js/battle.js index 3ddaa598f..a53ee6a04 100644 --- a/js/battle.js +++ b/js/battle.js @@ -2388,8 +2388,8 @@ var Battle = (function () { } } }; - Battle.prototype.addPseudoWeather = function (weather, poke) { - this.pseudoWeather.push([weather, 5]); + Battle.prototype.addPseudoWeather = function (weather, minTimeLeft, timeLeft) { + this.pseudoWeather.push([weather, minTimeLeft, timeLeft]); this.updateWeather(); }; Battle.prototype.hasPseudoWeather = function (weather) { @@ -2835,8 +2835,8 @@ var Battle = (function () { if (turnnum == this.turn + 1) { this.endLastTurnPending = true; } + if (this.turn) this.updatePseudoWeatherLeft(); this.turn = turnnum; - this.updatePseudoWeatherLeft(); if (this.mySide.active[0]) this.mySide.active[0].clearTurnstatuses(); if (this.mySide.active[1]) this.mySide.active[1].clearTurnstatuses(); @@ -2980,7 +2980,9 @@ var Battle = (function () { }; Battle.prototype.updatePseudoWeatherLeft = function () { for (var i = 0; i < this.pseudoWeather.length; i++) { - if (this.pseudoWeather[i][1] > 0) this.pseudoWeather[i][1]--; + var pWeather = this.pseudoWeather[i]; + if (pWeather[1]) pWeather[1]--; + if (pWeather[2]) pWeather[2]--; } for (var i = 0; i < this.sides.length; i++) { for (var id in this.sides[i].sideConditions) { @@ -2993,6 +2995,13 @@ var Battle = (function () { }; Battle.prototype.pseudoWeatherLeft = function (pWeather) { var buf = '
' + Tools.getMove(pWeather[0]).name; + if (!pWeather[1] && pWeather[2]) { + pWeather[1] = pWeather[2]; + pWeather[2] = 0; + } + if (pWeather[2]) { + return buf + ' (' + pWeather[1] + ' or ' + pWeather[2] + ' turns)'; + } if (pWeather[1]) { return buf + ' (' + pWeather[1] + ' turn' + (pWeather[1] == 1 ? '' : 's') + ')'; } @@ -5611,13 +5620,15 @@ var Battle = (function () { this.message('', "[" + poke.getName(true) + "'s " + fromeffect.name + "!]"); poke.markAbility(fromeffect.name); } + var maxTimeLeft = 0; if (effect.id in {'electricterrain': 1, 'grassyterrain': 1, 'mistyterrain': 1, 'psychicterrain': 1}) { this.removePseudoWeather('Electric Terrain'); this.removePseudoWeather('Grassy Terrain'); this.removePseudoWeather('Misty Terrain'); this.removePseudoWeather('Psychic Terrain'); + if (this.gen > 6) maxTimeLeft = 8; } - this.addPseudoWeather(effect.name, poke); + this.addPseudoWeather(effect.name, 5, maxTimeLeft); switch (effect.id) { case 'trickroom':