-
Notifications
You must be signed in to change notification settings - Fork 0
/
libertalia.html
136 lines (122 loc) · 3.55 KB
/
libertalia.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
<!DOCTYPE html>
<!-- SPDX-License-Identifier: 0BSD -->
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Symbols+2" rel="stylesheet">
<style>
html,
body {
width: 100vw;
font-size: 3vmax;
}
div {
width: 100%;
font-size: 4vmax;
}
button {
width: 99%;
font-size: 4vmax;
margin-left: 0;
}
@font-face {
font-family: "Noto Sans Symbols 2";
src: url("NotoSansSymbols2-Regular.woff2") format("woff2");
}
div.customfont {
font-family: "Noto Sans Symbols 2";
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Libertalia: Winds of Galecrest</title>
</head>
<body>
Libertalia: Winds of Galecrest<br>
Deck Randomizer<br><br>
<button onclick="reschuffle()">Shuffle Deck (Press Twice)</button>
<br>
<br>
<button onclick="show('day1')">Show Day 1</button>
<div id="day1" style="display: none;"></div>
<br>
<br>
<button onclick="show('day2')">Show Day 2</button>
<div id="day2" style="display: none;"></div>
<br>
<br>
<button onclick="show('day3')">Show Day 3</button>
<div id="day3" style="display: none;"></div>
<div class="customfont" style="text-align:center;font-size:6vmax">
<span id="o0"></span>
<span id="o1"></span>
<span id="o2"></span>
<span id="o3"></span>
<span id="o4"></span>
<span id="o5"></span>
</div>
<script>
var deck;
// Shuffles an array of numbers
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
var first_click = true;
// Unhide a div block
function show(div) {
document.getElementById(div).style.display = 'block';
first_click = true;
}
// Updates the numbers in each day
function update() {
document.getElementById("day1").innerHTML = deck.slice(0, 6).sort().join(' ');
document.getElementById("day2").innerHTML = deck.slice(6, 12).sort().join(' ');
document.getElementById("day3").innerHTML = deck.slice(12, 18).sort().join(' ');
}
// Generate a new shuffled list, updates the web page, and saves the list in a cookie
function generate() {
deck = Uint8Array.from({length: 40}, (v, k) => k+1);
shuffle(deck);
update();
document.cookie = deck.toString() + "; max-age=" + (60 * 60 * 24 * 7) + ";";
}
// Reshuffle the deck and update the web page
// Require the button to be pressed twice, for safety
function reschuffle() {
if (first_click) {
first_click = false;
} else {
document.getElementById('day1').style.display = 'none';
document.getElementById('day2').style.display = 'none';
document.getElementById('day3').style.display = 'none';
generate();
first_click = true;
}
}
function check(num) {
return Number.isInteger(num) && (num >= 1) && (num <= 40);
}
colors = [ "color:purple",
"color:white;text-shadow:-1px -1px black, 1px 1px black, 1px -1px black, -1px 1px black",
"color:black",
"color:green",
"color:blue",
"color:red" ];
shuffle(colors);
for (let i = 0; i < 6; i++) {
document.getElementById('o' + i).innerHTML = `<span style="${colors[i]}">⯃</span>`;
}
deck = Uint8Array.from(document.cookie.split(',').map(Number));
if ((deck.length == 40) && deck.every(check)) {
// If the cookie contains a valid shuffled list, just use it
update();
} else {
// Otherwise, generate a new one
generate();
}
</script>
</body></html>