|
|
|
@@ -13,9 +13,28 @@ function initGamePostSetup(state) { |
|
|
|
const holder = document.querySelector("#player-info"); |
|
|
|
|
|
|
|
Object.entries(state.player.stats).forEach(([key, val]) => { |
|
|
|
const field = document.createElement("div"); |
|
|
|
field.id = "player-info-" + key; |
|
|
|
holder.appendChild(field); |
|
|
|
|
|
|
|
if (val.type == "meter") { |
|
|
|
const field = document.createElement("div"); |
|
|
|
field.id = "player-info-" + key; |
|
|
|
field.setAttribute("max", val.max); |
|
|
|
field.setAttribute("value", val.value); |
|
|
|
field.classList.add("stat-bar-holder"); |
|
|
|
|
|
|
|
const label = document.createElement("div"); |
|
|
|
label.classList.add("stat-bar-label"); |
|
|
|
label.textContent = val.name; |
|
|
|
|
|
|
|
const bar = document.createElement("div"); |
|
|
|
bar.classList.add("stat-bar"); |
|
|
|
bar.style["background-color"] = val.color; |
|
|
|
|
|
|
|
field.appendChild(label); |
|
|
|
field.appendChild(bar); |
|
|
|
|
|
|
|
holder.appendChild(field); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -43,8 +62,12 @@ function updateWorldInfo(state) { |
|
|
|
|
|
|
|
function updatePlayerInfo(state) { |
|
|
|
Object.entries(state.player.stats).forEach(([key, val]) => { |
|
|
|
const field = document.querySelector("#player-info-" + key); |
|
|
|
field.textContent = val.name + ": " + val.value; |
|
|
|
|
|
|
|
if (val.type == "meter") { |
|
|
|
const field = document.querySelector("#player-info-" + key + " > .stat-bar"); |
|
|
|
field.style.width = (val.value / val.max * 100) + "%"; |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|