From e28316d48d996ca773362cce2d62039ad1ddde44 Mon Sep 17 00:00:00 2001 From: urkerab Date: Tue, 29 Dec 2015 22:45:16 +0000 Subject: [PATCH] Create seperate function to return the boost value --- js/client-battle-tooltips.js | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/js/client-battle-tooltips.js b/js/client-battle-tooltips.js index 0ec463cfd..aac19a389 100644 --- a/js/client-battle-tooltips.js +++ b/js/client-battle-tooltips.js @@ -1,5 +1,62 @@ var BattleTooltips = (function () { + var incenseTypes = { + 'Odd Incense': 'Psychic', + 'Rock Incense': 'Rock', + 'Rose Incense': 'Grass', + 'Sea Incense': 'Water', + 'Wave Incense': 'Water' + }; + var itemTypes = { + 'Black Belt': 'Fighting', + 'Black Glasses': 'Dark', + 'Charcoal': 'Fire', + 'Dragon Fang': 'Dragon', + 'Hard Stone': 'Rock', + 'Magnet': 'Electric', + 'Metal Coat': 'Steel', + 'Miracle Seed': 'Grass', + 'Mystic Water': 'Water', + 'Never-Melt Ice': 'Ice', + 'Poison Barb': 'Poison', + 'Sharp Beak': 'Flying', + 'Silk Scarf': 'Normal', + 'SilverPowder': 'Bug', + 'Soft Sand': 'Ground', + 'Spell Tag': 'Ghost', + 'TwistedSpoon': 'Psychic' + }; + var noGemMoves = { + 'Fire Pledge': 1, + 'Fling': 1, + 'Grass Pledge': 1, + 'Struggle': 1, + 'Water Pledge': 1 + }; function BattleTooltips() {} + BattleTooltips.prototype.getItemBoost = function (BattleRoom, move, pokemon) { + var myPokemon = BattleRoom.myPokemon[pokemon.slot]; + if (!myPokemon.item || BattleRoom.battle.hasPseudoWeather('Magic Room') || pokemon.volatiles && pokemon.volatiles['embargo']) return 0; + + var item = Tools.getItem(myPokemon.item); + var moveType = BattleRoom.getMoveType(move, pokemon); + var itemName = item.name; + var moveName = move.name; + + // Plates + if (item.onPlate === moveType) return 1.2; + + // Incenses + if (incenseTypes[item.name] === moveType) return 1.2; + + // Type-enhancing items + if (itemTypes[item.name] === moveType) return BattleRoom.battle.gen < 4 ? 1.1 : 1.2; + + // Gems + if (moveName in noGemMoves) return 0; + if (itemName === moveType + ' Gem') return BattleRoom.battle.gen < 6 ? 1.5 : 1.3; + + return 0; + }; BattleTooltips.prototype.boostBasePower = function (BattleRoom, move, pokemon, basePower, basePowerComment) { var myPokemon = BattleRoom.myPokemon[pokemon.slot]; if (myPokemon.item && !BattleRoom.battle.hasPseudoWeather('Magic Room') && (!pokemon.volatiles || !pokemon.volatiles['embargo'])) {