-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoomPicker.html
123 lines (110 loc) · 5.93 KB
/
RoomPicker.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<head>
<meta charset="utf-8">
<title>Room Picker - Spoopsquad</title>
<meta name="description" content="A tool for drawing random floor tiles for a shifting haunted house">
<meta name="author" content="Alexander Damrath">
</head>
<body style="background:black;" onload="checkUsed()">
<div style="text-align:center;margin-top:25vh;">
<span style="text-align:center;color:darkgrey;font-size:120px;" id="result">Pick A Floor</span>
</div>
<br>
<div style="text-align:center;color:gray;">
<span id="used"></span>
</div>
<div style="text-align:center;position:absolute;bottom:0px;margin:15px;">
<button style="border:none;background-color:darkred;color:white;border-radius:5px;padding:10px;margin:10px" onClick="roll('middle');">1st Floor</button>
<button style="border:none;background-color:teal;color:white;border-radius:5px;padding:10px;margin:10px" onClick="roll('upper');">2nd Floor</button>
<button style="border:none;background-color:olivedrab;color:white;border-radius:5px;padding:10px;margin:10px" onClick="roll('lower');">Basement</button>
</div>
<script>
var middle_rooms = ["Mystic Elevator","Abandoned Room","Ballroom","Bloody Room","Chapel","Charred Room","Coal Chute (to Furnace Room)","Collaped Room (to random basement)","Conservatory","Creaky Hallway","Dusty Hallway","Gallery","Game Room","Garden","Graveyard","Junkroom","Library","Organ Room","Patio","Servant's Quarters","Stairs to Basement","Statuary Room"];
var upper_rooms = ["Mystic Elevator","Abandoned Room","Attic","Balcony","Bedroom","Bloody Room","Charred Room","Collapsed Room (to random 1st floor)","Creaky Hallway","Dusty Hallway","Gallery","Game Room","Gymnasium","Junkroom","Library","Master Bedroom","Pentagram Room","Research Lab","Servant's Quarters","Tower"];
var lower_rooms = ["Mystic Elevator","Abandoned Room","Basement Landing","Bloody Room","Catacombs","Charred Room","Chasm","Creaky Hallway","Crypt","Dusty Hallway","Furnace Room","Larder","Operating Room","Pentagram Room","Research Lab","Servants Quarters","Store Room","Underground Lake","Vault","Wine Cellar"];
var used_rooms = [];
var colors = [];
var z = 0;
function checkUsed () {
used_rooms = JSON.parse(window.localStorage.getItem("usedRooms")) || [];
colors = JSON.parse(window.localStorage.getItem("colorList")) || [];
console.log(used_rooms);
fillUsed();
}
function fillUsed () {
document.getElementById("used").textContent="";
for (let x = 0; x < used_rooms.length; x++) {
const element = used_rooms[x];
document.getElementById("used").innerHTML+='<button style="border:none;background-color:'+colors[x]+';color:white;border-radius:5px;padding:5px;margin:4px;font-size:10px;" onClick="removeUsed('+x+')">'+element+'</button>';
}
}
function removeUsed (x) {
used_rooms.splice(x,1);
colors.splice(x,1);
window.localStorage.setItem("usedRooms", JSON.stringify(used_rooms));
window.localStorage.setItem("colorList", JSON.stringify(colors));
fillUsed();
}
function roll(x) {
if (z>=40) {
alert("No more rooms left in that deck!");
z=0;
} else {
switch(x) {
case "upper":
var uRoom = upper_rooms[Math.floor(Math.random()*upper_rooms.length)];
console.log(uRoom);
var used = used_rooms.includes(uRoom);
if (used) {
z++;
roll(x);
} else {
document.getElementById("result").textContent=uRoom;
used_rooms.push(uRoom);
colors.push("teal");
window.localStorage.setItem("usedRooms", JSON.stringify(used_rooms));
window.localStorage.setItem("colorList", JSON.stringify(colors));
fillUsed();
z=0;
}
break;
case "lower":
var lRoom = lower_rooms[Math.floor(Math.random()*lower_rooms.length)];
console.log(lRoom);
var used = used_rooms.includes(lRoom);
if (used) {
z++;
roll(x);
} else {
document.getElementById("result").textContent=lRoom;
used_rooms.push(lRoom);
colors.push("olivedrab");
window.localStorage.setItem("usedRooms", JSON.stringify(used_rooms));
window.localStorage.setItem("colorList", JSON.stringify(colors));
fillUsed();
z=0;
}
break;
case "middle":
var mRoom = middle_rooms[Math.floor(Math.random()*middle_rooms.length)];
console.log(mRoom);
var used = used_rooms.includes(mRoom);
if (used) {
z++;
roll(x);
} else {
document.getElementById("result").textContent=mRoom;
used_rooms.push(mRoom);
colors.push("darkred");
window.localStorage.setItem("usedRooms", JSON.stringify(used_rooms));
window.localStorage.setItem("colorList", JSON.stringify(colors));
fillUsed();
z=0;
}
break;
default:
document.getElementById("result").textContent="This shouldn't happen. Let Alex know the default state was triggered.";
}
}
}
</script>
</body>