Skip to content

Instantly share code, notes, and snippets.

@NookieGrey
Last active June 27, 2016 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NookieGrey/316dd1a945ebcb6cb263be7fabcfe6df to your computer and use it in GitHub Desktop.
Save NookieGrey/316dd1a945ebcb6cb263be7fabcfe6df to your computer and use it in GitHub Desktop.
!(function () {
var tipPerItem = document.createElement('div');
tipPerItem.setAttribute('id', 'tipPerItem');
document.getElementById('tooltipDiv').appendChild(tipPerItem);
var oldTooltip = window.tooltip;
window.tooltip = function (what, isItIn, event, textString, attachFunction, numCheck, renameBtn, noHide) {
document.getElementById('tipPerItem').innerHTML = '';
var isEquipment, isPatch;
if (isItIn == "buildings") {
isEquipment = false;
isPatch = true;
}
if (isItIn == "equipment") {
isEquipment = true;
isPatch = true;
}
if (isPatch) {
var costPerItemString = "";
var amount = 1;
var toTip = game[isItIn][what];
var tooltipText = toTip.tooltip;
if (typeof tooltipText === 'function') {
tooltipText = tooltipText();
}
var tipSplit = tooltipText.split('$');
if (typeof tipSplit[1] !== 'undefined') {
if (tipSplit[1] == 'incby') {
var increase = toTip.increase.by;
if (game.portal.Carpentry.level && toTip.increase.what == "trimps.max") increase *= Math.pow(1.1, game.portal.Carpentry.level);
if (game.portal.Carpentry_II.level && toTip.increase.what == "trimps.max") increase *= (1 + (game.portal.Carpentry_II.modifier * game.portal.Carpentry_II.level));
amount = increase;
}
else
amount = toTip[tipSplit[1]]
}
if (what == "Gym") {
if (game.upgrades.Gymystic.done) {
amount = newGymBlock(game.buildings.Gym.owned + 1)
}
}
var toBuy, price;
if (!isEquipment) toBuy = game.buildings[what];
else toBuy = game.equipment[what];
var purchaseAmt = game.global.buyAmt;
if (game.global.buyAmt == "Max") {
return oldTooltip.apply(null, arguments); //todo
}
var totalPrice = 0;
for (var costItem in toBuy.cost) {
var color = 'green';
price = parseFloat(getBuildingItemPrice(toBuy, costItem, isEquipment, purchaseAmt));
if (price > game.resources[costItem].owned || !(isFinite(price))) {
color = "red";
}
costPerItemString += '<span class="' + color + '">' + costItem + ':&nbsp;' + prettify(price / amount) + '</span>, ';
if (!isEquipment) {
var k = 1;
if (costItem == 'gems') {
k = 0; // todo trimps total / baseGems * baseLoot
}
if (costItem == 'fragments') {
k = 0; // todo speed update / 2
}
totalPrice += price / amount * k;
}
}
costPerItemString = costPerItemString.slice(0, -2);
costPerItemString = '<hr style="margin-top: 1vh; margin-bottom: 1vh;" />' + costPerItemString;
if (!isEquipment) {
costPerItemString += '<hr style="margin-top: 1vh; margin-bottom: 1vh;" />' + prettify(totalPrice);
}
document.getElementById('tipPerItem').innerHTML = costPerItemString;
}
oldTooltip.apply(null, arguments);
};
function getGymBlock(gyms) {
var gymysticLvl = game.upgrades.Gymystic.done;
return Math.floor(6 * Math.pow(1.04 + 0.01 * gymysticLvl, gyms) * gyms);
}
function newGymBlock(lvl) {
return getGymBlock(lvl) - getGymBlock(lvl - 1)
}
var keyCodes = {
'space': 32
};
document.addEventListener("keydown", function (event) {
if (event.keyCode == keyCodes.space) {
toggleSetting('pauseGame')
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment