-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript-js.js
59 lines (47 loc) · 2.68 KB
/
javascript-js.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function parseInput(action, position, locations, buttons, shopItems, shopCosts)
{
if(action == "MOVE")
{
position += 1;
reloadElements(position, locations, buttons, shopItems, shopCosts);
document.getElementById("optionalInfo").innerHTML = "";
} else if(action == "SHOP")
{
document.getElementById("optionalInfo").style.visibility = "visible";
document.getElementById("optionalInfo").innerHTML = "Currently staying put.\nThere is a shop here.";
document.getElementById("actionButton").style.visibility = "visible";
document.getElementById("actionButton").innerHTML = "Enter Shop";
document.getElementById("actionButton").onclick = function (){ enterShop(position, locations, buttons, shopItems, shopCosts); }
}
}
function reloadElements(position, locations, buttons, shopItems, shopCosts)
{
// console.log(position, locations, buttons, buttonActions);
loadData(position, locations, buttons, shopItems, shopCosts);
}
function loadData(position, locations, buttons, shopItems, shopCosts)
{
items();
document.getElementById("actionButton").style.visibility = "hidden";
document.getElementById("optionalInfo").style.visibility = "hidden";
document.getElementById("extraHeader").style.visibility = "hidden";
document.getElementById("infoHeader").style.visibility = "hidden";
document.getElementById("extraSubHeader").style.visibility = "hidden";
document.getElementById("list").style.visibility = "hidden";
document.getElementById("optionalInfo").style.visibility = "hidden";
var totalPrice = 0;
localStorage.setItem("totalPrice", totalPrice)
document.getElementById("header").style.visibility = "visible";
document.getElementById("option1").style.visibility = "visible";
document.getElementById("option2").style.visibility = "visible";
document.getElementById("stats").style.visibility = "visible";
var position = parseInt(position);
document.getElementById("header").innerHTML = (locations[position].name + " - " + locations[position].description);
document.getElementById("option1").innerHTML = (buttons[position].optionOne + " [" + buttons[position].actionOne + "]");
document.getElementById("option2").innerHTML = (buttons[position].optionTwo + " [" + buttons[position].actionTwo + "]");
document.getElementById("option1").onclick = function (){ parseInput(buttons[position].actionOne, position, locations, buttons, shopItems, shopCosts); }
document.getElementById("option2").onclick = function (){ parseInput(buttons[position].actionTwo, position, locations, buttons, shopItems, shopCosts); }
var option1Action = buttons[position].actionOne;
var option2Action = buttons[position].actionTwo;
document.getElementById("stats").innerHTML = ("Health: " + health + " / Gold: " + gold);
}