| @@ -11,6 +11,10 @@ let newline = " "; | |||||
| let player = new Player(); | let player = new Player(); | ||||
| function round(number, digits) { | |||||
| return Math.round(number * Math.pow(10,digits)) / Math.pow(10,digits); | |||||
| } | |||||
| function updateExploreCompass() { | function updateExploreCompass() { | ||||
| for (let i = 0; i < dirButtons.length; i++) { | for (let i = 0; i < dirButtons.length; i++) { | ||||
| let button = dirButtons[i]; | let button = dirButtons[i]; | ||||
| @@ -96,7 +100,7 @@ function updateDisplay() { | |||||
| document.getElementById("time").innerHTML = "Time: " + renderTime(time); | document.getElementById("time").innerHTML = "Time: " + renderTime(time); | ||||
| document.getElementById("stat-name").innerHTML = "Name: " + player.name; | document.getElementById("stat-name").innerHTML = "Name: " + player.name; | ||||
| document.getElementById("stat-health").innerHTML = "Health: " + player.health + "/" + player.maxHealth; | document.getElementById("stat-health").innerHTML = "Health: " + player.health + "/" + player.maxHealth; | ||||
| document.getElementById("stat-fullness").innerHTML = "Fullness: " + player.fullness(); | |||||
| document.getElementById("stat-fullness").innerHTML = "Fullness: " + round(player.fullness(),0); | |||||
| } | } | ||||
| function advanceTime(amount) { | function advanceTime(amount) { | ||||
| @@ -55,6 +55,10 @@ function Container(name) { | |||||
| let damage = Math.min(prey.health, this.damageRate * time); | let damage = Math.min(prey.health, this.damageRate * time); | ||||
| prey.health -= damage; | prey.health -= damage; | ||||
| time -= damage / this.damageRate; | time -= damage / this.damageRate; | ||||
| if (prey.health <= 0) { | |||||
| lines.push(this.describeKill(prey)); | |||||
| } | |||||
| } | } | ||||
| if (prey.health <= 0) { | if (prey.health <= 0) { | ||||
| @@ -66,7 +70,7 @@ function Container(name) { | |||||
| } | } | ||||
| if (prey.mass <= 0) { | if (prey.mass <= 0) { | ||||
| lines.push(this.describeDigest(prey)); | |||||
| lines.push(this.describeFinish(prey)); | |||||
| this.finish(prey); | this.finish(prey); | ||||
| } | } | ||||
| @@ -91,7 +95,11 @@ function Container(name) { | |||||
| function Stomach(bowels) { | function Stomach(bowels) { | ||||
| Container.call(this, "stomach"); | Container.call(this, "stomach"); | ||||
| this.describeDigest = function(prey) { | |||||
| this.describeKill = function(prey) { | |||||
| return "The " + prey.description() + "'s struggles wane as your stomach overpowers them."; | |||||
| } | |||||
| this.describeFinish = function(prey) { | |||||
| return "Your churning guts have reduced a " + prey.description() + " to meaty chyme."; | return "Your churning guts have reduced a " + prey.description() + " to meaty chyme."; | ||||
| }; | }; | ||||
| @@ -56,7 +56,7 @@ let locationsSrc = [ | |||||
| "conn": [ | "conn": [ | ||||
| { | { | ||||
| "name": "North Street", | "name": "North Street", | ||||
| "dir": NORTH, | |||||
| "dir": WEST, | |||||
| "desc": "You step outside." | "desc": "You step outside." | ||||
| }, | }, | ||||
| { | { | ||||
| @@ -77,12 +77,17 @@ let locationsSrc = [ | |||||
| { | { | ||||
| "name": "Alley", | "name": "Alley", | ||||
| "dir": WEST, | "dir": WEST, | ||||
| "desc": "You wander into the dark alley." | |||||
| "desc": "You wander into the dark alley" | |||||
| }, | }, | ||||
| { | { | ||||
| "name": "Living Room", | "name": "Living Room", | ||||
| "dir": EAST, | "dir": EAST, | ||||
| "desc": "You step back into your apartment." | |||||
| "desc": "You step back into your apartment" | |||||
| }, | |||||
| { | |||||
| "name": "Crossroads", | |||||
| "dir": SOUTH, | |||||
| "desc": "You walk south" | |||||
| } | } | ||||
| ], | ], | ||||
| "objs": [ | "objs": [ | ||||
| @@ -94,7 +99,7 @@ let locationsSrc = [ | |||||
| "desc": "A suspicious alley", | "desc": "A suspicious alley", | ||||
| "conn": [ | "conn": [ | ||||
| { | { | ||||
| "name": "Street", | |||||
| "name": "North Street", | |||||
| "dir": EAST, | "dir": EAST, | ||||
| "desc": "You hurry back into the open street." | "desc": "You hurry back into the open street." | ||||
| }, | }, | ||||
| @@ -115,7 +120,40 @@ let locationsSrc = [ | |||||
| { | { | ||||
| "name": "Alley", | "name": "Alley", | ||||
| "dir": SOUTH, | "dir": SOUTH, | ||||
| "desc": "You step out of the bar." | |||||
| "desc": "You step out of the bar" | |||||
| } | |||||
| ], | |||||
| "objs": [ | |||||
| ] | |||||
| }, | |||||
| { | |||||
| "name": "Crossroads", | |||||
| "desc": "Where the roads cross", | |||||
| "conn": [ | |||||
| { | |||||
| "name": "North Street", | |||||
| "dir": NORTH, | |||||
| "desc": "You walk north" | |||||
| }, | |||||
| { | |||||
| "name": "South Street", | |||||
| "dir": SOUTH, | |||||
| "desc": "You walk south" | |||||
| } | |||||
| ], | |||||
| "objs": [ | |||||
| ] | |||||
| }, | |||||
| { | |||||
| "name": "South Street", | |||||
| "desc": "This street is in the south", | |||||
| "conn": [ | |||||
| { | |||||
| "name": "Crossroads", | |||||
| "dir": NORTH, | |||||
| "desc": "You walk to the crossroads" | |||||
| } | } | ||||
| ], | ], | ||||
| "objs": [ | "objs": [ | ||||