浏览代码

Add number stat type

tags/v0.1.2
Fen Dweller 6 年前
父节点
当前提交
03d7d17d1b
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. +15
    -0
      game.js
  2. +1
    -0
      stories/demo.js

+ 15
- 0
game.js 查看文件

@@ -34,6 +34,18 @@ function initGamePostSetup(state) {
field.appendChild(label);
field.appendChild(bar);

holder.appendChild(field);
} else if (val.type == "counter") {
const field = document.createElement("div");
field.id = "player-info-" + key;
field.setAttribute("max", val.max);
field.setAttribute("value", val.value);
field.classList.add("counter-holder");

const counter = document.createElement("div");
counter.classList.add("stat-counter");
field.appendChild(counter);

holder.appendChild(field);
}

@@ -76,6 +88,9 @@ function updatePlayerInfo(state) {
if (val.type == "meter") {
const field = document.querySelector("#player-info-" + key + " > .stat-bar");
field.style.width = (val.value / val.max * 100) + "%";
} else if (val.type == "counter") {
const field = document.querySelector("#player-info-" + key + " > .stat-counter");
field.innerText = val.name + ": " + val.value;
}

});


+ 1
- 0
stories/demo.js 查看文件

@@ -9,6 +9,7 @@ stories.push({
"setup": state => {
state.info.time = 0;
state.player.stats.oofs = {name: "Oofs", type: "meter", value: 0, max: 10, color: "rgb(255,0,0)"};
state.player.stats.number = {name: "Number", type: "counter", value: 0, max: 10, color: "rgb(255,255,255)"};
},
"intro": state => {
print(["don't fall down the stairs ok"]);


正在加载...
取消
保存