-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiceRoller.html
151 lines (130 loc) · 5.83 KB
/
diceRoller.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html>
<head>
<title>Dice Roller</title>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="js/dice.js"></script>
<style>
body
{
background-image: url("images/stars.png");
}
input
{
width: 35pt;
position: absolute;
left: 200pt;
margin-bottom: 10pt;
height: 15pt;
}
button:hover
{
background-color: grey;
}
image
{
width: 35pt;
float: left;
}
</style>
</head>
<body>
<div style="background-color: #aaaaaa; width: 400pt; height: 450pt; top: 50%; left: 50%; transform: translate(-50%, -50%); position: fixed; border-radius: 10pt; padding: 15pt;">
<lable for="Ability">Ability</lable>
<input type="number" min="0" id="Ability" name="Ability">
<br>
<lable for="Proficency">Proficency</lable>
<input type="number" min="0" id="Proficency" name="Proficency">
<br>
<lable for="Boost">Boost</lable>
<input type="number" min="0" id="Boost" name="Boost">
<br>
<br>
<lable for="dificulty">Dificulty</lable>
<input type="number" min="0" id="dificulty" name="dificulty">
<br>
<lable for="Challenge">Challenge</lable>
<input type="number" min="0" id="Challenge" name="Challenge">
<br>
<lable for="Setback">Setback</lable>
<input type="number" min="0" id="Setback" name="Setback">
<br>
<br>
<Label for="erase">Clear Dice After Roll</Label>
<input type="checkbox" name="erase" id="erase">
<br>
<br>
<br>
<div id="rolls" style="width: 370pt; position: absolute; background-color: #f8f9fa; height: 100pt; border-radius: 10pt; padding: 15pt; text-align: center;">
</div>
<script>
function removeAllChildNodes(parent)
{
while (parent.firstChild)
{
parent.removeChild(parent.firstChild);
}
}
function rollFromInput()
{
var pool = [];
pool.ability = document.querySelector("#Ability").value;
pool.proficency = document.querySelector("#Proficency").value;
pool.boost = document.querySelector("#Boost").value;
pool.dificulty = document.querySelector("#dificulty").value;
pool.challenge = document.querySelector("#Challenge").value;
pool.setback = document.querySelector("#Setback").value;
var results = roll(pool);
var erase = document.querySelector("#erase").checked;
if (erase == true)
{
document.querySelector("#Ability").value = null;
document.querySelector("#Proficency").value = null;
document.querySelector("#Boost").value = null;
document.querySelector("#dificulty").value = null;
document.querySelector("#Challenge").value = null;
document.querySelector("#Setback").value = null;
}
removeAllChildNodes(document.querySelector("#rolls"));
for (let i = 0; i < results.sucsess; i++)
{
var img = document.createElement("img");
img.src = "images/success.png";
document.querySelector("#rolls").appendChild(img);
}
for (let i = 0; i < results.failure; i++)
{
var img = document.createElement("img");
img.src = "images/failure.png";
document.querySelector("#rolls").appendChild(img);
}
for (let i = 0; i < results.advantage; i++)
{
var img = document.createElement("img");
img.src = "images/advantage.png";
document.querySelector("#rolls").appendChild(img);
}
for (let i = 0; i < results.disadvantage; i++)
{
var img = document.createElement("img");
img.src = "images/disadvantage.png";
document.querySelector("#rolls").appendChild(img);
}
for (let i = 0; i < results.triumph; i++)
{
var img = document.createElement("img");
img.src = "images/triumph.png";
document.querySelector("#rolls").appendChild(img);
}
for (let i = 0; i < results.despair; i++)
{
var img = document.createElement("img");
img.src = "images/despair.png";
document.querySelector("#rolls").appendChild(img);
}
}
</script>
<button onclick="rollFromInput()" style="width: 100%; position: relative; top: 260pt; border-radius: 10pt; border: none; height: 35pt;">Roll</button>
</div>
</body>
</html>