diff --git a/game.js b/game.js
index 9311b78..b700f81 100644
--- a/game.js
+++ b/game.js
@@ -5,11 +5,20 @@ function initGame(story, state) {
state.info.time = 60 * 60 * 9;
state.player.stats = {};
- state.player.stats.health = 100;
state.timers = [];
}
+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);
+ });
+}
+
// TODO: format string this lol
function renderTime(time) {
let hours = Math.floor(time / 3600) % 12;
@@ -33,9 +42,10 @@ function updateWorldInfo(state) {
}
function updatePlayerInfo(state) {
- const health = document.querySelector("#player-info-health");
-
- health.textContent = "Health: " + state.player.stats.health;
+ Object.entries(state.player.stats).forEach(([key, val]) => {
+ const field = document.querySelector("#player-info-" + key);
+ field.textContent = val.name + ": " + val.value;
+ });
}
/*
diff --git a/satiate.html b/satiate.html
index fb22841..7589e7b 100644
--- a/satiate.html
+++ b/satiate.html
@@ -48,7 +48,6 @@
diff --git a/satiate.js b/satiate.js
index 3fe4bea..31068e5 100644
--- a/satiate.js
+++ b/satiate.js
@@ -83,6 +83,8 @@ function init(story) {
story.intro.setup(state);
+ initGamePostSetup(state);
+
refreshHook = story.refresh;
goToRoom(story.intro.start, state);
diff --git a/stories/fen-snack.js b/stories/fen-snack.js
index 2b2f52a..f837324 100644
--- a/stories/fen-snack.js
+++ b/stories/fen-snack.js
@@ -10,12 +10,15 @@ stories.push({
intro: {
start: "stomach",
setup: state => {
+ state.player.stats.health = {name: "Health", value: 100};
+ state.player.stats.stamina = {name: "Stamina", value: 100};
+
startTimer({
id: "digestion",
func: state => {
- state.player.stats.health -= 1;
+ state.player.stats.health.value -= 1;
- if (state.player.stats.health <= 0) {
+ if (state.player.stats.health.value <= 0) {
goToRoom("digested", state);
return false;
}
@@ -30,7 +33,7 @@ stories.push({
}
},
refresh: state => {
- setBackgroundColor(50 - state.player.stats.health/2, 0, 0)
+ setBackgroundColor(50 - state.player.stats.health.value/2, 0, 0)
},
world: {
stomach: {
@@ -61,7 +64,7 @@ stories.push({
name: "Submit",
desc: "Let Fen digest you",
execute: (room, state) => {
- state.player.stats.health = 0;
+ state.player.stats.health.value = 0;
goToRoom("digested", state);
}
}