Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PurePandemonium equipment efficiency tooltip script
- // For Trimps v2.7
- // Directions: Copy and paste into javascript console for Trimps
- // Effect: efficiency calculations shown in equipment tooltips
- // e.g. "metal per attack: 3530"
- function canAffordBuilding(what, take, buildCostString, isEquipment){
- var costString = "";
- var toBuy;
- if (!isEquipment) toBuy = game.buildings[what];
- else toBuy = game.equipment[what];
- if (typeof toBuy === 'undefined') return false;
- for (var costItem in toBuy.cost) {
- var color = "green";
- var price = 0;
- price = parseFloat(getBuildingItemPrice(toBuy, costItem, isEquipment));
- if (isEquipment) price = Math.ceil(price * (Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level)));
- if (price > game.resources[costItem].owned || !(isFinite(price))) {
- if (buildCostString) color = "red";
- else return false;
- }
- if (buildCostString) {
- var percent;
- if (color == "red"){
- var thisPs = getPsString(costItem, true);
- if (thisPs > 0)
- {
- percent = calculateTimeToMax(null, thisPs, (price - game.resources[costItem].owned));
- percent = "(" + percent + ")";
- }
- else percent = "(<span class='icomoon icon-infinity'></span>)";
- }
- else{
- percent = (game.resources[costItem].owned > 0) ? prettify(((price / game.resources[costItem].owned) * 100).toFixed(1)) : 0;
- percent = "(" + percent + "%)";
- }
- costString += '<span class="' + color + '">' + costItem + ': ' + prettify(price) + ' ' + percent + '</span>, ';
- // BEGIN @PURE CHANGES
- if (isEquipment) {
- var stat = "nostat";
- var efficiency = 0;
- if (toBuy.attack) {
- stat = "attack"
- efficiency = price / toBuy.attackCalculated;
- } else if (toBuy.health && !toBuy.blockNow) {
- stat = "health"
- efficiency = price / toBuy.healthCalculated;
- } else {
- stat = "block"
- efficiency = price / toBuy.blockCalculated;
- }
- // costString should look like "metal per attack: 603"
- costString += '<span>' + costItem + " per " + stat + ": " + prettify(efficiency) + '</span>, ';
- }
- // END CHANGES
- }
- if (take) game.resources[costItem].owned -= price;
- if (what == "Wormhole" && take && costItem == "helium") {
- game.global.totalHeliumEarned -= price;
- game.stats.spentOnWorms.value += price;
- }
- }
- if (buildCostString) {
- costString = costString.slice(0, -2);
- return costString;
- }
- return true;
- }
- function tooltip(what, isItIn, event, textString, attachFunction, numCheck, renameBtn, noHide) {
- if (document.getElementById(what + "Alert") !== null) document.getElementById(what + "Alert").innerHTML = "";
- if (document.getElementById(isItIn + "Alert") !== null) document.getElementById(isItIn + "Alert").innerHTML = "";
- if (game.global.lockTooltip) return;
- var elem = document.getElementById("tooltipDiv");
- var ondisplay = null; // if non-null, called after the tooltip is displayed
- if (what == "hide"){
- elem.style.display = "none";
- tooltipUpdateFunction = "";
- return;
- }
- if ((event != 'update' || isItIn) && !game.options.menu.tooltips.enabled && !shiftPressed && what != "Well Fed") return;
- if (event != "update"){
- var whatU = what, isItInU = isItIn, eventU = event, textStringU = textString, attachFunctionU = attachFunction, numCheckU = numCheck, renameBtnU = renameBtn, noHideU = noHide;
- var newFunction = function () {
- tooltip(whatU, isItInU, eventU, textStringU, attachFunctionU, numCheckU, renameBtnU, noHideU);
- };
- tooltipUpdateFunction = newFunction;
- var cordx = 0;
- var cordy = 0;
- var e = event || window.event;
- if (e.pageX || e.pageY) {
- cordx = e.pageX;
- cordy = e.pageY;
- } else if (e.clientX || e.clientY) {
- cordx = e.clientX;
- cordy = e.clientY;
- }
- elem.style.left = (cordx + 20) + "px";
- elem.style.top = (cordy - 200) + "px";
- }
- var tooltipText;
- var costText = "";
- var toTip;
- var price;
- var canAfford;
- var percentOfTotal = "";
- if (isItIn !== null && isItIn != "maps"){
- toTip = game[isItIn];
- toTip = toTip[what];
- if (typeof toTip === 'undefined') console.log(what);
- tooltipText = toTip.tooltip;
- for (var cost in toTip.cost) {
- if (typeof toTip.cost[cost] === 'object' && typeof toTip.cost[cost][1] === 'undefined') {
- var costItem = toTip.cost[cost];
- for (var item in costItem) {
- price = costItem[item];
- if (isItIn == "upgrades" && game.upgrades[what].prestiges && (item == "metal" || item == "wood"))
- price *= Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level);
- if (typeof price === 'function') price = price();
- if (typeof price[1] !== 'undefined') price = resolvePow(price, toTip);
- var itemToCheck = game[cost];
- if (typeof itemToCheck[item] !== 'undefined'){
- canAfford = (itemToCheck[item].owned >= price) ? "green" : "red";
- if (typeof itemToCheck[item].owned !== 'undefined'){
- if (itemToCheck[item].owned < price && (typeof game.resources[item] !== 'undefined')){
- var thisPs = getPsString(item, true);
- if (thisPs > 0){
- percentOfTotal = calculateTimeToMax(null, thisPs, (price - itemToCheck[item].owned));
- percentOfTotal = "(" + percentOfTotal + ")";
- }
- else percentOfTotal = "(<span class='icomoon icon-infinity'></span>)"
- }
- else {
- percentOfTotal = (itemToCheck[item].owned > 0) ? prettify(((price / itemToCheck[item].owned) * 100).toFixed(1)) : 0;
- percentOfTotal = "(" + percentOfTotal + "%)";
- }
- }
- costText += '<span class="' + canAfford + '">' + item + ': ' + prettify(price) + ' ' + percentOfTotal + '</span>, ';
- }
- else
- costText += item + ": " + prettify(price) + ", ";
- }
- continue;
- }
- }
- costText = costText.slice(0, -2);
- }
- if (what == "Confirm Purchase"){
- if (attachFunction == "purchaseImport()" && !boneTemp.selectedImport) return;
- var btnText = "Make Purchase";
- if (numCheck && game.global.b < numCheck){
- if (typeof kongregate === 'undefined') return;
- tooltipText = "You can't afford this bonus. Would you like to visit the shop?";
- attachFunction = "showPurchaseBones()";
- btnText = "Visit Shop";
- }
- else
- tooltipText = textString;
- costText += '<div class="maxCenter"><div class="btn btn-info" onclick="' + attachFunction + '; cancelTooltip()">' + btnText + '</div><div class="btn btn-info" onclick="cancelTooltip()">Cancel</div></div>';
- game.global.lockTooltip = true;
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- if (what == "Respec"){
- tooltipText = "You can respec your perks once per portal. Clicking cancel after clicking this button will not consume your respec.";
- costText = "";
- }
- if (what == "Well Fed"){
- tooltipText = "That Turkimp was delicious, and you have leftovers. If you set yourself to gather Food, Wood, or Metal while this buff is active, you can share with your workers to increase their gather speed by 50%";
- costText = "";
- elem.style.top = "0";
- }
- if (what == "Welcome"){
- tooltipText = "Welcome to Trimps! This game saves using Local Storage in your browser. Clearing your cookies or browser settings will cause your save to disappear. Please make sure you regularly back up your save file by using the 'Export' button in the bar below and saving that somewhere safe. I recommend using Chrome or Firefox. <br/><br/> Thank you for playing, and I hope you enjoy the game!";
- game.global.lockTooltip = true;
- costText = "<div class='maxCenter'><div class='btn btn-info' onclick='cancelTooltip()'>Start</div></div>";
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- if (what == "Trustworthy Trimps"){
- tooltipText = textString;
- game.global.lockTooltip = true;
- costText = "<div class='maxCenter'><div class='btn btn-info' onclick='cancelTooltip()'>Sweet, thanks.</div></div>";
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- if (what == "Portal"){
- tooltipText = "The portal device you found shines green in the lab. Such a familiar shade...";
- costText = "";
- }
- if (what == "Repeat Map"){
- tooltipText = "Allow the Trimps to find their way back to square 1 once they finish without your help. They grow up so fast.";
- costText = "";
- }
- if (what == "Reset"){
- tooltipText = "Are you sure you want to reset? This will really actually reset your game. You won't get anything cool. It will be gone. <b style='color: red'>This is not the soft-reset you're looking for. This will delete your save.</b>";
- costText="<div class='maxCenter'><div class='btn btn-danger' onclick='resetGame();unlockTooltip();tooltip(\"hide\")'>Delete Save</div> <div class='btn btn-info' onclick='cancelTooltip()'>Cancel</div></div>";
- game.global.lockTooltip = true;
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- if (what == "Fight"){
- tooltipText = "Send your poor Trimps to certain doom in the battlefield. You'll get cool stuff though, they'll understand.";
- costText = (game.resources.trimps.maxSoldiers > 1) ? "s" : "";
- costText = game.resources.trimps.maxSoldiers + " Trimp" + costText;
- }
- if (what == "AutoFight"){
- tooltipText = "Allow the Trimps to start fighting on their own whenever their town gets overcrowded";
- costText = "";
- }
- if (what == "Queue"){
- tooltipText = "This is a building in your queue, you'll need to click \"Build\" to build it. Clicking an item in the queue will cancel it for a full refund.";
- costText = "";
- }
- if (what == "Custom"){
- customUp = (textString) ? 2 : 1;
- tooltipText = "Type a number below to purchase a specific amount. You can also use shorthand such as 2e5 or 200k."
- if (textString) tooltipText += " <b>Max of 1,000 for perks</b>";
- tooltipText += "<br/><br/><input id='customNumberBox' style='width: 50%' value='" + prettify(game.global.lastCustomAmt) + "'></input>";
- costText = "<div class='maxCenter'><div class='btn btn-info' onclick='numTab(5, " + textString + ")'>Apply</div><div class='btn btn-info' onclick='cancelTooltip()'>Cancel</div></div>";
- game.global.lockTooltip = true;
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- ondisplay = function() {
- var box = document.getElementById("customNumberBox");
- // Chrome chokes on setSelectionRange on a number box; fall back to select()
- try { box.setSelectionRange(0, box.value.length); }
- catch (e) { box.select(); }
- box.focus();
- };
- }
- if (what == "Export"){
- if (textString){
- tooltipText = textString + "<br/><br/><textarea style='width: 100%' rows='5'>" + save(true) + "</textarea>";
- what = "Thanks!";
- }
- else
- tooltipText = "This is your save string. There are many like it but this one is yours. Save this save somewhere safe so you can save time next time. <br/><br/><textarea style='width: 100%' rows='5'>" + save(true) + "</textarea>";
- costText = "<div class='maxCenter'><div class='btn btn-info' onclick='cancelTooltip()'>Got it</div></div>";
- game.global.lockTooltip = true;
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- if (what == "Import"){
- tooltipText = "Import your save string! It'll be fun, I promise.<br/><br/><textarea id='importBox' style='width: 100%' rows='5'></textarea>";
- costText="<div class='maxCenter'><div class='btn btn-info' onclick='load(true); cancelTooltip()'>Import</div><div class='btn btn-info' onclick='cancelTooltip()'>Cancel</div></div>";
- game.global.lockTooltip = true;
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- if (what == "Fire Trimps"){
- if (!game.global.firing)
- tooltipText = "Activate firing mode, turning the job buttons red, and forcing them to fire trimps rather than hire them. The newly unemployed Trimps will start breeding instead of working, but you will not receive a refund on resources.";
- else
- tooltipText = "Disable firing mode";
- costText = "";
- }
- if (what == "Maps"){
- if (!game.global.preMapsActive)
- tooltipText = "Travel to the Map Chamber. Maps are filled with goodies, and for each max level map you clear you will gain a 20% stacking damage bonus for that zone (stacks up to 10 times).";
- else
- tooltipText = "Go back to to the World Map.";
- costText = "";
- }
- if (isItIn == "jobs"){
- var buyAmt = game.global.buyAmt;
- if (game.global.firing){
- tooltipText = "Fire a " + what + ". Refunds no resources, but frees up some workspace for your Trimps.";
- costText = "";
- }
- else{
- var workspaces = Math.ceil(game.resources.trimps.realMax() / 2) - game.resources.trimps.employed;
- if (workspaces < buyAmt && workspaces > 0) buyAmt = workspaces;
- costText = getTooltipJobText(what, buyAmt);
- }
- if (game.global.buyAmt > 1) what += " X" + buyAmt;
- }
- if (isItIn == "buildings"){
- costText = canAffordBuilding(what, false, true);
- if (game.global.buyAmt > 1) {
- if (game.buildings[what].percent){
- tooltipText += " <b>You can only purchase 1 " + what + " at a time.</b>";
- what += " X1";
- }
- else {
- what += " X" + game.global.buyAmt;
- }
- }
- }
- if (isItIn == "portal"){
- var resAppend = (game.global.kongBonusMode) ? " Bonus Points" : " Helium Canisters";
- var perkItem = game.portal[what];
- if (!perkItem.max || perkItem.max > perkItem.level + perkItem.levelTemp) costText = prettify(getPortalUpgradePrice(what)) + resAppend;
- else costText = "";
- if (game.global.buyAmt > 1) what += " X" + game.global.buyAmt;
- }
- if (isItIn == "equipment"){
- costText = canAffordBuilding(what, false, true, true);
- if (what == "Shield" && game.equipment.Shield.blockNow){
- var blockPerShield = game.equipment.Shield.blockCalculated + (game.equipment.Shield.blockCalculated * game.jobs.Trainer.owned * (game.jobs.Trainer.modifier / 100));
- tooltipText += " (" + prettify(blockPerShield) + " after Trainers)";
- }
- if (game.global.buyAmt > 1) {
- what += " X" + game.global.buyAmt;
- }
- // BEGIN @PURE CHANGES
- costText = canAffordBuilding(what, false, true, true);
- if (game.global.buyAmt > 1) {
- what += " X" + game.global.buyAmt;
- }
- // END CHANGES
- }
- if (isItIn == "upgrades"){
- if (typeof tooltipText.split('@')[1] !== 'undefined'){
- var prestigeCost = "<b>You may not want to do this right away.</b> Your next " + game.upgrades[what].prestiges + " will grant " + getNextPrestigeValue(what) + ".";
- tooltipText = tooltipText.replace('@', prestigeCost);
- }
- if (typeof tooltipText.split('$')[1] !== 'undefined'){
- var upgradeTextSplit = tooltipText.split('$');
- var color = game.upgrades[what].specialFilter();
- color = color ? "green" : "red";
- tooltipText = upgradeTextSplit[0] + "<span style='color: " + color + "; font-weight: bold;'>" + upgradeTextSplit[1] + "</span>";
- }
- if (typeof tooltipText.split('?')[1] !== 'undefined'){
- var percentNum = (game.global.frugalDone) ? '60' : '50';
- tooltipText = tooltipText.replace('?', percentNum);
- }
- if (what == "Coordination"){
- var coordReplace = (game.portal.Coordinated.level) ? (25 * Math.pow(game.portal.Coordinated.modifier, game.portal.Coordinated.level)).toFixed(3) : 25;
- tooltipText = tooltipText.replace('<coord>', coordReplace);
- if (!canAffordCoordinationTrimps()){
- var nextCount = (game.portal.Coordinated.level) ? game.portal.Coordinated.currentSend : game.resources.trimps.maxSoldiers;
- var amtToGo = ((nextCount * 3) - game.resources.trimps.realMax());
- tooltipText += "<b>You need enough room for " + prettify(nextCount * 3) + " max Trimps. You are short " + prettify(Math.floor(amtToGo)) + " Trimps.</b>";
- }
- }
- }
- if (isItIn == "maps"){
- tooltipText = "This is a map. Click it to see its properties or to run it. Maps can be run as many times as you want.";
- costText = "";
- }
- if (what == 'confirm'){
- if (!renameBtn) renameBtn = "Confirm";
- what = numCheck;
- tooltipText = textString;
- if (!noHide) attachFunction = attachFunction + "; cancelTooltip()";
- costText = ' <div class="maxCenter" id="confirmTipCost"><div class="btn btn-info" onclick="' + attachFunction + '">' + renameBtn + '</div><div class="btn btn-danger" onclick="cancelTooltip()">Cancel</div></div>';
- game.global.lockTooltip = true;
- elem.style.left = "32.5%";
- elem.style.top = "25%";
- }
- 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);
- tooltipText = tipSplit[0] + prettify(increase) + tipSplit[2];
- }
- else if (isItIn == "jobs" && game.portal.Motivation.level && toTip.increase != "custom"){
- tooltipText = tipSplit[0] + prettify(toTip[tipSplit[1]] * ((game.portal.Motivation.level * 0.05) + 1)) + tipSplit[2];
- }
- else
- tooltipText = tipSplit[0] + prettify(toTip[tipSplit[1]]) + tipSplit[2];
- }
- if (typeof tooltipText.split('~') !== 'undefined') {
- var percentIncrease = game.upgrades.Gymystic.done;
- var text = ".";
- if (percentIncrease > 0){
- percentIncrease += 4;
- text = " and increase the base block of all other Gyms by " + percentIncrease + "%.";
- }
- tooltipText = tooltipText.replace('~', text);
- }
- document.getElementById("tipTitle").innerHTML = what;
- document.getElementById("tipText").innerHTML = tooltipText;
- document.getElementById("tipCost").innerHTML = costText;
- elem.style.display = "block";
- if (ondisplay !== null)
- ondisplay();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement