From df4cc30de474d41eac31f5194fb3e008fac6e57f Mon Sep 17 00:00:00 2001 From: hvk3 Date: Thu, 10 Dec 2015 16:46:19 +0530 Subject: [PATCH 1/2] Added gem-boosted powers to move description --- js/client-battle.js | 152 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 141 insertions(+), 11 deletions(-) diff --git a/js/client-battle.js b/js/client-battle.js index fb41671e7..2868d4b8a 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -1332,6 +1332,17 @@ var basePower = move.basePower; var basePowerComment = ''; var thereIsWeather = (this.battle.weather in {'sunnyday': 1, 'desolateland': 1, 'raindance': 1, 'primordialsea': 1, 'sandstorm': 1, 'hail':1}); + if (myPokemon.item && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && basePower && (moveName != 'Struggle' || moveName != 'Water Pledge' || moveName != 'Grass Pledge' || moveName != 'Fire Pledge' || moveName != 'Fling')) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } + } if (move.id === 'acrobatics') { if (!myPokemon.item) { basePower *= 2; @@ -1340,10 +1351,29 @@ } if (move.id === 'crushgrip' || move.id === 'wringout') { basePower = Math.floor(Math.floor((120 * (100 * Math.floor(target.hp * 4096 / target.maxhp)) + 2048 - 1) / 4096) / 100) || 1; - basePowerComment = ' (Approximation)'; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } + basePowerComment += ' (Approximation)'; } if (move.id === 'eruption' || move.id === 'waterspout') { basePower = Math.floor(150 * pokemon.hp / pokemon.maxhp) || 1; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + } } if (move.id === 'flail' || move.id === 'reversal') { if (this.battle.gen > 4) { @@ -1360,10 +1390,20 @@ else if (ratio < ratios[3]) basePower = 80; else if (ratio < ratios[4]) basePower = 40; else basePower = 20; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } } if (move.id === 'hex' && target.status) { basePower *= 2; - basePowerComment = ' (Boosted by status)'; + basePowerComment += ' (Boosted by status)'; } if (move.id === 'punishment') { var boosts = Object.keys(target.boosts); @@ -1372,12 +1412,22 @@ if (target.boosts[boosts[i]] > 0) multiply += target.boosts[boosts[i]]; } basePower = 60 + 20 * multiply; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } if (basePower > 200) basePower = 200; } if (move.id === 'smellingsalts') { if (target.status === 'par') { basePower *= 2; - basePowerComment = ' (Boosted by status)'; + basePowerComment += ' (Boosted by status)'; } } if (move.id === 'storedpower') { @@ -1387,6 +1437,16 @@ if (pokemon.boosts[boosts[i]] > 0) multiply += pokemon.boosts[boosts[i]]; } basePower = 20 + 20 * multiply; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } } if (move.id === 'trumpcard') { basePower = 40; @@ -1394,21 +1454,41 @@ else if (move.pp === 2) basePower = 80; else if (move.pp === 3) basePower = 60; else if (move.pp === 4) basePower = 50; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } } if (move.id === 'venoshock') { if (target.status === 'psn' || target.status === 'tox') { basePower *= 2; - basePowerComment = ' (Boosted by status)'; + basePowerComment += ' (Boosted by status)'; } } if (move.id === 'wakeupslap') { if (target.status === 'slp') { basePower *= 2; - basePowerComment = ' (Boosted by status)'; + basePowerComment += ' (Boosted by status)'; } } if (move.id === 'weatherball' && thereIsWeather) { basePower = 100; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } } // Moves that check opponent speed. if (move.id === 'electroball') { @@ -1416,8 +1496,8 @@ var min = 0; var max = 0; if (target.volatiles && target.volatiles.formechange) template = Tools.getTemplate(target.volatiles.formechange[2]); - var minRatio = (myPokemon.stats['spe'] / this.getTemplateMinSpeed(template, target.level)); - var maxRatio = (myPokemon.stats['spe'] / this.getTemplateMaxSpeed(template, target.level)); + var minRatio = (myPokemon.stats['spe'] / this.getTemplateMaxSpeed(template, target.level)); + var maxRatio = (myPokemon.stats['spe'] / this.getTemplateMinSpeed(template, target.level)); if (minRatio >= 4) min = 150; else if (minRatio >= 3) min = 120; else if (minRatio >= 2) min = 80; @@ -1437,6 +1517,17 @@ } else { basePowerComment = (min === max) ? max : min + ' to ' + max; } + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + min *= this.battle.gen >= 6 ? 1.3 : 1.5; + max *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } } if (move.id === 'gyroball') { var template = target; @@ -1446,6 +1537,7 @@ if (min > 150) min = 150; if (max > 150) max = 150; // Special case due to range as well. + basePower = 0; if (ability === 'Technician') { if (min <= 60) min *= 1.5; @@ -1454,6 +1546,16 @@ } else { basePowerComment = (min === max) ? max : min + ' to ' + max; } + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + min *= this.battle.gen >= 6 ? 1.3 : 1.5; + max *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } } // Movements which have base power changed due to items. if (myPokemon.item && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { @@ -1480,7 +1582,17 @@ else if (targetWeight >= 50) basePower = 80; else if (targetWeight >= 25) basePower = 60; else if (targetWeight >= 10) basePower = 40; - if (target.volatiles && target.volatiles.autotomize) basePowerComment = ' (Approximation)'; + // No base power initially + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } + if (target.volatiles && target.volatiles.autotomize) basePowerComment += ' (Approximation)'; } if (move.id === 'heavyslam' || move.id === 'heatcrash') { basePower = 40; @@ -1488,7 +1600,16 @@ else if (pokemonWeight > targetWeight * 4) basePower = 100; else if (pokemonWeight > targetWeight * 3) basePower = 80; else if (pokemonWeight > targetWeight * 2) basePower = 60; - if (target.volatiles && target.volatiles.autotomize) basePowerComment = ' (Approximation)'; + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } + if (target.volatiles && target.volatiles.autotomize) basePowerComment += ' (Approximation)'; } } if (!basePower) return basePowerComment; @@ -1496,12 +1617,21 @@ // Other ability boosts. if (ability === 'Technician' && basePower <= 60) { basePower *= 1.5; - basePowerComment = ' (Technician boosted)'; + basePowerComment += ' (Technician boosted)'; } if (move.type === 'Normal' && move.category !== 'Status' && !(move.id in {'naturalgift': 1, 'struggle': 1}) && (!thereIsWeather || thereIsWeather && move.id !== 'weatherball')) { if (ability in {'Aerilate': 1, 'Pixilate': 1, 'Refrigerate': 1}) { basePower = Math.floor(basePower * 1.3); - basePowerComment = ' (' + ability + ' boosted)'; + var itemName = Tools.getItem(myPokemon.item).name; + var pos = this.choice.choices.length; + var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); + var splitItemName = itemName.split(' '); + var moveName = move.name; + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + itemName + ')'; + } + basePowerComment += ' (' + ability + ' boosted)'; } } return basePower + basePowerComment; From 311acb8fcd5ea5798fe3e29cc065dfe38f7c8e32 Mon Sep 17 00:00:00 2001 From: Harshvardhan Date: Wed, 16 Dec 2015 17:24:56 +0530 Subject: [PATCH 2/2] Added support for all power-boosting items Removed redundancy from code Moved to tooltips file Reduced code Reduced code Reduced code Reduced globals to 1 Minor error corrections --- .eslintrc.js | 2 +- js/client-battle-tooltips.js | 81 ++++++++++++++++ js/client-battle.js | 183 +++++++---------------------------- testclient.html | 1 + 4 files changed, 116 insertions(+), 151 deletions(-) create mode 100644 js/client-battle-tooltips.js diff --git a/.eslintrc.js b/.eslintrc.js index 9c820e10c..52ad61252 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,7 @@ module.exports = { "fs": false, "gui": false, "ga": false, "macgap": false, "nwWindow": false, "webkitNotifications": false, // Battle stuff - "Battle": true, "Pokemon": true, "BattleSound": true, + "Battle": true, "Pokemon": true, "BattleSound": true, "BattleTooltips": true, "BattleAbilities": false, "BattleAliases": false, "BattleBackdrops": false, "BattleBackdropsFour": false, "BattleBackdropsThree": false, "BattleEffects": false, "BattleFormats": false, "BattleFormatsData": false, "BattleLearnsets": false, "BattleItems": false, "BattleMoveAnims": false, "BattleMovedex": false, "BattleNatures": false, "BattleOtherAnims": false, "BattlePokedex": false,"BattlePokemonSprites": false, "BattlePokemonSpritesBW": false, "BattleSearchCountIndex": false, "BattleSearchIndex": false, diff --git a/js/client-battle-tooltips.js b/js/client-battle-tooltips.js new file mode 100644 index 000000000..cd0ce324e --- /dev/null +++ b/js/client-battle-tooltips.js @@ -0,0 +1,81 @@ +var BattleTooltips = (function () { + function BattleTooltips() {} + BattleTooltips.prototype.boostBasePower = function (BattleRoom, move, pokemon, target, basePower, basePowerComment) { + var myPokemon = BattleRoom.myPokemon[pokemon.slot]; + var ability = Tools.getAbility(myPokemon.baseAbility).name; + var thereIsWeather = (BattleRoom.battle.weather in {'sunnyday': 1, 'desolateland': 1, 'raindance': 1, 'primordialsea': 1, 'sandstorm': 1, 'hail':1}); + if (!BattleRoom.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + var item = Tools.getItem(myPokemon.item); + var pos = BattleRoom.choice.choices.length; + var moveType = BattleRoom.getMoveType(move, BattleRoom.battle.mySide.active[pos]); + var splitItemName = item.name.split(' '); + var moveName = move.name; + if (basePower) { + // Gems + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && (moveName != 'Struggle' || moveName != 'Water Pledge' || moveName != 'Grass Pledge' || moveName != 'Fire Pledge' || moveName != 'Fling')) { + basePower *= BattleRoom.battle.gen >= 6 ? 1.3 : 1.5; + basePowerComment += ' (Boosted by ' + item.name + ')'; + } + // Plates + if (splitItemName[1] == 'Plate' && item.onPlate && moveType == item.onPlate) { + basePower *= 1.2; + basePowerComment += ' (Boosted by ' + item.name + ')'; + } + // Type-enhancing items + if (item.name == 'Black Belt' && moveType == 'Fighting' || item.name == 'Black Glasses' && moveType == 'Dark' || item.name == 'Charcoal' && moveType == 'Fire' || item.name == 'Dragon Fang' && moveType == 'Dragon' || item.name == 'Hard Stone' && moveType == 'Rock' || item.name == 'Magnet' && moveType == 'Electric' || item.name == 'Metal Coat' && moveType == 'Steel' || item.name == 'Miracle Seed' && moveType == 'Grass' || item.name == 'Mystic Water' && moveType == 'Water' || item.name == 'Never-Melt Ice' && moveType == 'Ice' || item.name == 'Poison Barb' && moveType == 'Poison' || item.name == 'Sharp Beak' && moveType == 'Flying' || item.name == 'Silk Scarf' && moveType == 'Normal' || item.name == 'SilverPowder' && moveType == 'Bug' || item.name == 'Soft Sand' && moveType == 'Ground' || item.name == 'Spell Tag' && moveType == 'Ghost' || item.name == 'TwistedSpoon' && moveType == 'Psychic') { + basePower *= BattleRoom.battle.gen >= 4 ? 1.2 : 1.1; + basePowerComment += ' (Boosted by ' + item.name + ')'; + } + // Incenses + if ((item.name == 'Wave Incense' || item.name == 'Sea Incense') && moveType == 'Water' || item.name == 'Rose Incense' && moveType == 'Grass' || item.name == 'Rock Incense' && moveType == 'Rock' || item.name == 'Odd Incense' && moveType == 'Psychic') { + basePower *= 1.2; + basePowerComment += ' (Boosted by ' + item.name + ')'; + } + } + basePower = Math.floor(basePower); + return basePower == 0 ? basePowerComment : basePower + basePowerComment; + } + }; + BattleTooltips.prototype.boostBasePower_Ball = function (BattleRoom, move, pokemon, target, basePower, basePowerComment, min, max) { + var myPokemon = BattleRoom.myPokemon[pokemon.slot]; + var ability = Tools.getAbility(myPokemon.baseAbility).name; + var item = Tools.getItem(myPokemon.item); + var pos = BattleRoom.choice.choices.length; + var moveType = BattleRoom.getMoveType(move, BattleRoom.battle.mySide.active[pos]); + var splitItemName = item.name.split(' '); + var moveName = move.name; + var itemCheck = false; + if (!BattleRoom.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { + if (splitItemName[1] == 'Gem' && moveType == splitItemName[0]) { + min *= BattleRoom.battle.gen >= 6 ? 1.3 : 1.5; + max *= BattleRoom.battle.gen >= 6 ? 1.3 : 1.5; + itemCheck = true; + } + if (splitItemName[1] == 'Plate' && item.onPlate && moveType == item.onPlate) { + min *= 1.2; + max *= 1.2; + itemCheck = true; + } + if (item.name == 'Magnet' && moveType == 'Electric' || item.name == 'Metal Coat' && moveType == 'Steel') { + min *= BattleRoom.battle.gen >= 4 ? 1.2 : 1.1; + max *= BattleRoom.battle.gen >= 4 ? 1.2 : 1.1; + itemCheck = true; + } + if (ability === 'Technician') { + if (min <= 60) min *= 1.5; + if (max <= 60) max *= 1.5; + basePowerComment += '' + ((min === max) ? Math.floor(max) : Math.floor(min) + ' to ' + Math.floor(max)) + ' (Technician boosted)'; + if (itemCheck) { + basePowerComment += ' (Boosted by ' + item.name + ')'; + } + } else { + basePowerComment += (min === max) ? Math.floor(max) : Math.floor(min) + ' to ' + Math.floor(max); + if (itemCheck) { + basePowerComment += ' (Boosted by ' + item.name + ')'; + } + } + } + return basePowerComment; + }; + return BattleTooltips; +})(); diff --git a/js/client-battle.js b/js/client-battle.js index 2868d4b8a..fdc392cb6 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -1331,18 +1331,8 @@ var ability = Tools.getAbility(myPokemon.baseAbility).name; var basePower = move.basePower; var basePowerComment = ''; + var Tooltips = new BattleTooltips(); var thereIsWeather = (this.battle.weather in {'sunnyday': 1, 'desolateland': 1, 'raindance': 1, 'primordialsea': 1, 'sandstorm': 1, 'hail':1}); - if (myPokemon.item && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && basePower && (moveName != 'Struggle' || moveName != 'Water Pledge' || moveName != 'Grass Pledge' || moveName != 'Fire Pledge' || moveName != 'Fling')) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } - } if (move.id === 'acrobatics') { if (!myPokemon.item) { basePower *= 2; @@ -1351,29 +1341,10 @@ } if (move.id === 'crushgrip' || move.id === 'wringout') { basePower = Math.floor(Math.floor((120 * (100 * Math.floor(target.hp * 4096 / target.maxhp)) + 2048 - 1) / 4096) / 100) || 1; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } - basePowerComment += ' (Approximation)'; + basePowerComment = ' (Approximation)'; } if (move.id === 'eruption' || move.id === 'waterspout') { basePower = Math.floor(150 * pokemon.hp / pokemon.maxhp) || 1; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - } } if (move.id === 'flail' || move.id === 'reversal') { if (this.battle.gen > 4) { @@ -1390,20 +1361,10 @@ else if (ratio < ratios[3]) basePower = 80; else if (ratio < ratios[4]) basePower = 40; else basePower = 20; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } } if (move.id === 'hex' && target.status) { basePower *= 2; - basePowerComment += ' (Boosted by status)'; + basePowerComment = ' (Boosted by status)'; } if (move.id === 'punishment') { var boosts = Object.keys(target.boosts); @@ -1412,22 +1373,12 @@ if (target.boosts[boosts[i]] > 0) multiply += target.boosts[boosts[i]]; } basePower = 60 + 20 * multiply; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } if (basePower > 200) basePower = 200; } if (move.id === 'smellingsalts') { if (target.status === 'par') { basePower *= 2; - basePowerComment += ' (Boosted by status)'; + basePowerComment = ' (Boosted by status)'; } } if (move.id === 'storedpower') { @@ -1437,16 +1388,6 @@ if (pokemon.boosts[boosts[i]] > 0) multiply += pokemon.boosts[boosts[i]]; } basePower = 20 + 20 * multiply; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } } if (move.id === 'trumpcard') { basePower = 40; @@ -1454,41 +1395,21 @@ else if (move.pp === 2) basePower = 80; else if (move.pp === 3) basePower = 60; else if (move.pp === 4) basePower = 50; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } } if (move.id === 'venoshock') { if (target.status === 'psn' || target.status === 'tox') { basePower *= 2; - basePowerComment += ' (Boosted by status)'; + basePowerComment = ' (Boosted by status)'; } } if (move.id === 'wakeupslap') { if (target.status === 'slp') { basePower *= 2; - basePowerComment += ' (Boosted by status)'; + basePowerComment = ' (Boosted by status)'; } } if (move.id === 'weatherball' && thereIsWeather) { basePower = 100; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } } // Moves that check opponent speed. if (move.id === 'electroball') { @@ -1510,23 +1431,16 @@ else max = 40; // Special case due to being a range. Other moves are checked by technician below. basePower = 0; - if (ability === 'Technician') { - if (min <= 60) min *= 1.5; - if (max <= 60) max *= 1.5; - basePowerComment = '' + ((min === max) ? max : min + ' to ' + max) + ' (Technician boosted)'; + if (!myPokemon.item) { + if (ability === 'Technician') { + if (min <= 60) min *= 1.5; + if (max <= 60) max *= 1.5; + basePowerComment = '' + ((min === max) ? max : min + ' to ' + max) + ' (Technician boosted)'; + } else { + basePowerComment = (min === max) ? max : min + ' to ' + max; + } } else { - basePowerComment = (min === max) ? max : min + ' to ' + max; - } - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - min *= this.battle.gen >= 6 ? 1.3 : 1.5; - max *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; + return Tooltips.boostBasePower_Ball(this, move, pokemon, target, basePower, basePowerComment, min, max); } } if (move.id === 'gyroball') { @@ -1537,24 +1451,17 @@ if (min > 150) min = 150; if (max > 150) max = 150; // Special case due to range as well. - basePower = 0; - if (ability === 'Technician') { - if (min <= 60) min *= 1.5; - if (max <= 60) max = Math.max(max * 1.5, 90); - basePowerComment = '' + ((min === max) ? max : min + ' to ' + max) + ' (Technician boosted)'; + if (!myPokemon.item) { + if (ability === 'Technician') { + if (min <= 60) min *= 1.5; + if (max <= 60) max *= 1.5; + basePowerComment = '' + ((min === max) ? max : min + ' to ' + max) + ' (Technician boosted)'; + } else { + basePowerComment = (min === max) ? max : min + ' to ' + max; + } } else { - basePowerComment = (min === max) ? max : min + ' to ' + max; - } - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - min *= this.battle.gen >= 6 ? 1.3 : 1.5; - max *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; + return Tooltips.boostBasePower_Ball(this, move, pokemon, target, basePower, basePowerComment, min, max); } } // Movements which have base power changed due to items. @@ -1582,17 +1489,7 @@ else if (targetWeight >= 50) basePower = 80; else if (targetWeight >= 25) basePower = 60; else if (targetWeight >= 10) basePower = 40; - // No base power initially - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } - if (target.volatiles && target.volatiles.autotomize) basePowerComment += ' (Approximation)'; + if (target.volatiles && target.volatiles.autotomize) basePowerComment = ' (Approximation)'; } if (move.id === 'heavyslam' || move.id === 'heatcrash') { basePower = 40; @@ -1600,16 +1497,7 @@ else if (pokemonWeight > targetWeight * 4) basePower = 100; else if (pokemonWeight > targetWeight * 3) basePower = 80; else if (pokemonWeight > targetWeight * 2) basePower = 60; - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } - if (target.volatiles && target.volatiles.autotomize) basePowerComment += ' (Approximation)'; + if (target.volatiles && target.volatiles.autotomize) basePowerComment = ' (Approximation)'; } } if (!basePower) return basePowerComment; @@ -1617,24 +1505,19 @@ // Other ability boosts. if (ability === 'Technician' && basePower <= 60) { basePower *= 1.5; - basePowerComment += ' (Technician boosted)'; + basePowerComment = ' (Technician boosted)'; } if (move.type === 'Normal' && move.category !== 'Status' && !(move.id in {'naturalgift': 1, 'struggle': 1}) && (!thereIsWeather || thereIsWeather && move.id !== 'weatherball')) { if (ability in {'Aerilate': 1, 'Pixilate': 1, 'Refrigerate': 1}) { basePower = Math.floor(basePower * 1.3); - var itemName = Tools.getItem(myPokemon.item).name; - var pos = this.choice.choices.length; - var moveType = this.getMoveType(move, this.battle.mySide.active[pos]); - var splitItemName = itemName.split(' '); - var moveName = move.name; - if (splitItemName[1] == 'Gem' && moveType == splitItemName[0] && !this.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) { - basePower *= this.battle.gen >= 6 ? 1.3 : 1.5; - basePowerComment += ' (Boosted by ' + itemName + ')'; - } - basePowerComment += ' (' + ability + ' boosted)'; + basePowerComment = ' (' + ability + ' boosted)'; } } - return basePower + basePowerComment; + if (myPokemon.item) { + return Tooltips.boostBasePower(this, move, pokemon, target, basePower, basePowerComment); + } else { + return basePower == 0 ? basePowerComment : basePower + basePowerComment; + } } }); diff --git a/testclient.html b/testclient.html index 7985f7a00..559d4c082 100644 --- a/testclient.html +++ b/testclient.html @@ -98,6 +98,7 @@ +