From f4abf200dfe2a29770f62b3b8e77f6d6c6107be1 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 5 Jun 2018 15:06:38 -0400 Subject: [PATCH] Added logic for cooldowns --- game.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ style.css | 8 ++++++++ 2 files changed, 54 insertions(+) diff --git a/game.js b/game.js index ab1d423..e8b1be7 100644 --- a/game.js +++ b/game.js @@ -3604,6 +3604,52 @@ function paw_vore() macro.arouse(5); } +function cooldown_start(name) { + let button = document.querySelector("#" + "button-action-" + name); + let parent = button.parentElement; + + let category = parent.id.replace("actions-", ""); + + Array.from(parent.children).forEach(function(x) { + x.disabled = true; + x.classList.add("action-button-disabled"); + }); + + cooldown(category, 100, 100); +} + +function cooldown(category, time, timestart) { + if (time <= 0) { + cooldown_end(category); + } else { + let button = document.getElementById("action-part-" + category); + + let amount = Math.round((timestart - time) / timestart * 100); + console.log(amount); + + let unselect = dark ? "#111" : "#ddd"; + let select = dark ? "#444" : "#555"; + + button.style.setProperty("background", "linear-gradient(to right, " + select + " 0%, " + select + " " + amount + "%, " + unselect + " " + amount + "%, " + unselect + " 100%"); + setTimeout(function() { cooldown(category, time - 1, timestart); }, 20); + } + +} + +function cooldown_end(category) { + + let button = document.getElementById("action-part-" + category); + + button.style.setProperty("background", null); + + let parent = document.querySelector("#actions-" + category); + + Array.from(parent.children).forEach(function(x) { + x.disabled = false; + x.classList.remove("action-button-disabled"); + }); +} + function transformNumbers(line) { return line.toString().replace(/[0-9]+(\.[0-9]+)?(e\+[0-9]+)?/g, function(text) { return number(text, numbers); }); diff --git a/style.css b/style.css index 15c1885..6135977 100644 --- a/style.css +++ b/style.css @@ -211,6 +211,14 @@ progress { display: none; } +body.light .action-button-disabled { + color: #777 !important; +} + +body.dark .action-button-disabled { + color: #aaa !important; +} + #victim-table { display: none; margin: auto;