-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
187 lines (183 loc) · 7.07 KB
/
index.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="/ammo.js"></script>
<title>Dice Roller</title>
<script type="module" src="/src/style.ts"></script>
<script type="module" src="/src/alpine.ts"></script>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="fixed top-0 left-0 right-0 bottom-0 pointer-events-none">
<!-- Dice Chooser -->
<div
class="absolute bottom-0 left-0 p-5 flex flex-col items-start pointer-events-auto"
x-data="rolls"
>
<!-- Dice Buttons -->
<div x-show="open" class="flex gap-2 text-white">
<div class="flex flex-col gap-2">
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d100 += 1"
>
d100
<template x-if="rolls.d100 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d100"
></div>
</template>
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d20 += 1"
>
d20
<template x-if="rolls.d20 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d20"
></div>
</template>
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d12 += 1"
>
d12
<template x-if="rolls.d12 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d12"
></div>
</template>
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d10 += 1"
>
d10
<template x-if="rolls.d10 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d10"
></div>
</template>
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d8 += 1"
>
d8
<template x-if="rolls.d8 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d8"
></div>
</template>
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d6 += 1"
>
d6
<template x-if="rolls.d6 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d6"
></div>
</template>
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rolls.d4 += 1"
>
d4
<template x-if="rolls.d4 > 0">
<div
class="absolute -top-2 -right-3 text-sm bg-neutral-300 rounded-full shadow border border-neutral-600 aspect-square w-7 text-black flex items-center justify-center"
x-text="rolls.d4"
></div>
</template>
</button>
</div>
<!-- Preset buttons -->
<div class="flex flex-col justify-end gap-2">
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rollAdv()"
>
Adv.
</button>
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="rollDis()"
>
Dis.
</button>
</div>
</div>
<!-- Toggle/Roll buttons -->
<div class="flex gap-2 text-white mt-2">
<button
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="open ? hide() : show()"
x-text="open ? 'X' : '^'"
></button>
<button
x-show="canRoll()"
class="bg-neutral-900 w-14 aspect-square rounded-full shadow relative"
x-on:click="roll()"
>
Roll
</button>
</div>
</div>
<!-- Results -->
<div
x-data
id="hud-results"
class="absolute bottom-0 right-0 p-5 pointer-events-auto"
x-bind:class="$store.result.visible ? 'translate-y-0 transition-transform ease-in-out' : 'translate-y-full'"
>
<div class="flex flex-col-reverse items-end">
<template x-for="(result, index) in $store.result.results">
<button
class="bg-neutral-900 rounded-2xl p-4 text-white shadow flex items-center mb-3"
@click="$store.result.removeResult(index)"
>
<div style="max-width: 150px" class="text-left">
<div
class="text-xl truncate"
x-text="$store.result.line1Str(index)"
></div>
<div
class="text-base text-neutral-500 truncate"
x-text="$store.result.line2Str(index)"
></div>
</div>
<div class="text-neutral-500 mx-3">=</div>
<div
class="output-results text-4xl font-bold"
x-text="$store.result.totalStr(index)"
></div>
</button>
</template>
</div>
<div class="flex justify-end">
<button
class="rounded-3xl text-base bg-neutral-900 text-white px-3 py-1 shadow"
x-on:click="$store.result.clearResult()"
>
Clear Results
</button>
</div>
</div>
</div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>