浏览代码

Added logic for cooldowns

tags/v0.7.1
Fen Dweller 7 年前
父节点
当前提交
f4abf200df
共有 2 个文件被更改,包括 54 次插入0 次删除
  1. +46
    -0
      game.js
  2. +8
    -0
      style.css

+ 46
- 0
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); });


+ 8
- 0
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;


正在加载...
取消
保存