Parcourir la source

Added logic for cooldowns

tags/v0.7.1
Fen Dweller il y a 7 ans
Parent
révision
f4abf200df
2 fichiers modifiés avec 54 ajouts et 0 suppressions
  1. +46
    -0
      game.js
  2. +8
    -0
      style.css

+ 46
- 0
game.js Voir le fichier

@@ -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); });


+ 8
- 0
style.css Voir le fichier

@@ -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;


Chargement…
Annuler
Enregistrer