-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
185 lines (155 loc) · 4.62 KB
/
Copy pathindex.html
File metadata and controls
185 lines (155 loc) · 4.62 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Generals ZH Randomizer</title>
<style>
*{
margin:0;
padding:0;
box-sizing:border-box;
}
body{
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background:
radial-gradient(circle at top,#3b3b3b 0%,#1d1d1d 40%,#0b0b0b 100%);
color:#eee;
min-height:100vh;
display:flex;
flex-direction:column;
align-items:center;
padding:50px 20px;
}
h1{
font-size:42px;
letter-spacing:3px;
color:#f4c542;
text-transform:uppercase;
text-shadow:
0 0 8px rgba(255,196,0,.5),
0 0 20px rgba(255,196,0,.2);
margin-bottom:40px;
}
button{
background:linear-gradient(#d79b28,#8b5b00);
color:white;
border:none;
padding:16px 45px;
font-size:20px;
font-weight:bold;
letter-spacing:2px;
border-radius:8px;
cursor:pointer;
transition:.25s;
box-shadow:
0 8px 20px rgba(0,0,0,.4),
inset 0 1px rgba(255,255,255,.25);
}
button:hover{
transform:translateY(-3px);
background:linear-gradient(#f2b632,#a56b00);
box-shadow:
0 15px 30px rgba(0,0,0,.5);
}
button:active{
transform:scale(.97);
}
.result{
margin-top:35px;
width:min(850px,95%);
background:rgba(32,32,32,.95);
border:2px solid #8b5b00;
border-radius:12px;
padding:30px;
text-align:left;
box-shadow:
0 20px 45px rgba(0,0,0,.45);
animation:fade .4s ease;
}
.result h3{
color:#f4c542;
border-bottom:1px solid #555;
padding-bottom:8px;
margin:
20px 0 15px;
text-transform:uppercase;
letter-spacing:1px;
}
.result h3:first-child{
margin-top:0;
}
.result br{
margin-bottom:8px;
}
b{
color:#6bd3ff;
}
@keyframes fade{
from{
opacity:0;
transform:translateY(15px);
}
to{
opacity:1;
transform:translateY(0);
}
}
</style>
</head>
<body>
<h1>Generals ZH LAN Randomizer</h1>
<button onclick="randomize()">DEPLOY TEAMS !</button>
<div id="output" class="result"></div>
<script>
function randomize() {
// Define your teams, spots, and factions
const teamA = ["Player 1", "Player 2", "Player 3"]; // Replace with actual names
const teamB = ["Player 1", "Player 2", "Player 3"];
const spotsA = ["Middle", "Left", "Right"];
const spotsB = ["Middle", "Left", "Right"];
const loc = ["Top","Bottom"] ;
const factions = [
"USA", "USA Laser", "USA Air Force", "USA Superweapon",
"China", "China Infantry", "China Nuke",
"GLA", "GLA Demolition", "GLA Tox", "GLA Stealth"
];
// Shuffle helper function for positions
function shuffle(array) {
return array.sort(() => Math.random() - 0.5);
}
// Helper function to pick a random item from an array (allows duplicates)
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function getSecureRandomInt(max) {
const array = new Uint32Array(1);
window.crypto.getRandomValues(array);
return array[0] % max;
}
let sA = shuffle([...spotsA]);
let sB = shuffle([...spotsB]);
let L = shuffle([...loc]) ;
let LA = L[getSecureRandomInt(L.length)];
let LB = "";
if(LA=="Top"){
LB = "Bottom" ;
}else{
LB="Top" ;
}
let html = `<h3>Team 1 ${LA}</h3>`;
teamA.forEach((player, index) => {
//let randomFaction = getRandomItem(factions);
let randomFaction = factions[getSecureRandomInt(factions.length)];
html += `${player} ➔ <b>${sA[index]}</b> ➔ ${randomFaction}<br>`;
});
html += `<h3 style='margin-top:20px;'>Team 2 ${LB}</h3>`;
teamB.forEach((player, index) => {
//let randomFaction = getRandomItem(factions);
let randomFaction = factions[getSecureRandomInt(factions.length)];
html += `${player} ➔ <b>${sB[index]}</b> ➔ ${randomFaction}<br>`;
});
document.getElementById("output").innerHTML = html;
}
</script>
</body>
</html>