|
|
@@ -6,14 +6,7 @@ let actions = []; |
|
|
let time = 9*60; |
|
|
let time = 9*60; |
|
|
let newline = " "; |
|
|
let newline = " "; |
|
|
|
|
|
|
|
|
let player = { |
|
|
|
|
|
name: "Fen", |
|
|
|
|
|
height: 1.55, |
|
|
|
|
|
health: 75, |
|
|
|
|
|
maxHealth: 100, |
|
|
|
|
|
fullness: 35, |
|
|
|
|
|
maxFullness: 200 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
let player = new Player(); |
|
|
|
|
|
|
|
|
function Object(name="Potato") { |
|
|
function Object(name="Potato") { |
|
|
this.name = name; |
|
|
this.name = name; |
|
|
@@ -31,7 +24,7 @@ function Burger() { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function updateExplore() { |
|
|
|
|
|
|
|
|
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]; |
|
|
if (currentRoom.exits[i] == null) { |
|
|
if (currentRoom.exits[i] == null) { |
|
|
@@ -46,12 +39,23 @@ function updateExplore() { |
|
|
button.innerHTML = currentRoom.exits[i].name; |
|
|
button.innerHTML = currentRoom.exits[i].name; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (let i = 0; i < actionButtons.length && i < actions.length; i++) { |
|
|
|
|
|
actionButtons[i].innerHTML = actions[i].name; |
|
|
|
|
|
actionButtons[i].addEventListener("click", function() { actions[i].action(); }); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
function updateExploreActions() { |
|
|
|
|
|
for (let i = 0; i < actionButtons.length; i++) { |
|
|
|
|
|
if (i < actions.length) |
|
|
|
|
|
actionButtons[i].innerHTML = actions[i].name; |
|
|
|
|
|
else |
|
|
|
|
|
actionButtons[i].innerHTML = ""; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
function updateExplore() { |
|
|
|
|
|
|
|
|
|
|
|
updateExploreCompass(); |
|
|
|
|
|
|
|
|
|
|
|
updateExploreActions(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function updateCombat() { |
|
|
function updateCombat() { |
|
|
|
|
|
|
|
|
@@ -117,8 +121,8 @@ function moveTo(room) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
window.addEventListener('load', function(event) { |
|
|
window.addEventListener('load', function(event) { |
|
|
|
|
|
loadActions(); |
|
|
loadCompass(); |
|
|
loadCompass(); |
|
|
actionButtons = Array.from( document.querySelectorAll(".action-button")); |
|
|
|
|
|
currentRoom = createWorld(); |
|
|
currentRoom = createWorld(); |
|
|
currentRoom.objects.push(new Burger()); |
|
|
currentRoom.objects.push(new Burger()); |
|
|
moveTo(currentRoom); |
|
|
moveTo(currentRoom); |
|
|
@@ -135,6 +139,17 @@ function update(lines=[]) { |
|
|
updateDisplay(); |
|
|
updateDisplay(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function actionClicked(index) { |
|
|
|
|
|
actions[index].action(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function loadActions() { |
|
|
|
|
|
actionButtons = Array.from( document.querySelectorAll(".action-button")); |
|
|
|
|
|
for (let i = 0; i < actionButtons.length; i++) { |
|
|
|
|
|
actionButtons[i].addEventListener("click", function() { actionClicked(i); }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function loadCompass() { |
|
|
function loadCompass() { |
|
|
dirButtons[NORTH_WEST] = document.getElementById("compass-north-west"); |
|
|
dirButtons[NORTH_WEST] = document.getElementById("compass-north-west"); |
|
|
dirButtons[NORTH_WEST].addEventListener("click", function() { |
|
|
dirButtons[NORTH_WEST].addEventListener("click", function() { |
|
|
|