-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
367 lines (336 loc) · 11.2 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gachapon Simulator</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
padding: 0;
background-color: #f0f0f0; /* Default light mode background color */
color: #333; /* Default light mode text color */
transition: background-color 0.3s, color 0.3s;
}
body.dark-mode {
background-color: #333; /* Dark mode background color */
color: #f0f0f0; /* Dark mode text color */
}
.switch {
position: relative;
display: inline-block;
width: 40px;
height: 24px;
margin-bottom: 10px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 24px;
}
.slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: #007bff;
}
input:checked + .slider:before {
transform: translateX(16px);
}
.slider.round {
border-radius: 24px;
}
.slider.round:before {
border-radius: 50%;
}
.button {
display: inline-block;
padding: 10px 20px;
margin: 10px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
font-size: 16px;
}
.button:hover {
background-color: #0056b3;
}
#container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
max-width: 800px;
height: 100%;
}
#results {
text-align: left;
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
flex-grow: 1;
overflow-y: auto;
width: 100%;
}
#output {
margin-top: 10px;
text-align: left;
}
#totals {
margin-top: 10px;
list-style-type: none;
padding: 0;
text-align: left;
}
#counters {
display: flex;
justify-content: space-between;
width: 100%;
margin-top: 20px;
}
.counter {
flex-basis: 50%;
text-align: center;
}
#rarity-selection {
margin: 15px 0;
display: flex;
justify-content: center;
gap: 20px;
}
#rarity-selection label {
font-size: 18px;
cursor: pointer;
}
#rarity-selection input {
margin-right: 5px;
}
#coin-container {
margin-top: 20px;
display: flex;
align-items: center;
gap: 10px;
}
#coin-container input {
width: 100px;
padding: 5px;
font-size: 16px;
text-align: center;
}
#coin-container span {
font-size: 18px;
}
</style>
</head>
<body>
<h1>Gachapon Simulator</h1>
<div id="container">
<div>
<button class="button" onclick="drawGachapon(1)">1 Draw</button>
<button class="button" onclick="drawGachapon(5)">5 Draws</button>
<button class="button" onclick="drawGachapon(10)">10 Draws</button>
<button class="button" onclick="resetSimulation()">Reset</button>
</div>
<!-- Cosmetic Radial Buttons -->
<div id="rarity-selection">
<label>
<input type="radio" name="rarity" value="common" checked>
⚪ Common
</label>
<label>
<input type="radio" name="rarity" value="uncommon">
🟢 Uncommon
</label>
<label>
<input type="radio" name="rarity" value="rare">
🔵 Rare
</label>
</div>
<!-- Coin Input -->
<div id="coin-container">
<input type="number" id="coinInput" value="10000" min="0">
<span>Coins</span>
</div>
<div id="results">
<div id="output"></div>
<ul id="totals"></ul>
</div>
<div id="counters">
<div class="counter" id="pityCounterHits">Pity Counter Hits: 0</div>
<div class="counter" id="untilPity">Until Pity: 10</div>
</div>
<label class="switch">
<input type="checkbox" onclick="toggleDarkMode()">
<span class="slider round"></span>
</label>
</div>
<script>
// Define the items
const items = [
'Berserker\'s armor', 'BF Cannon', 'Big Club', 'Chumby Chicken', 'Cleansing Flames',
'Curse of Exhaustion', 'Dark Ritual', 'Draining Dagger', 'Fiery Thorns', 'Fire Sword',
'Halberd', 'Healing Pendant', 'Love Letter', 'Magic Parasol', 'Martyr Armor',
'Mocking Armor', 'Pet Imp', 'Poison Dagger', 'Riot Shield', 'Rock Companion',
'Sacrificial Tome', 'Seeking Missiles', 'Special Delivery', 'Survival Kit',
'Whirlwind Axe', 'Witch\'s Armor', 'Boosting Bugle', 'Challenger Arrow',
'Energetic Ally', 'Explosion Powder', 'Festive Feast', 'Freezing Popsicle',
'Knight\'s Lance', 'Plague Bringer', 'POGable Forge', 'Punching Bag', 'The BOX'
];
// Define the tiers with their base probabilities
const tiers = [
{ name: 'Tier 1', probability: 0.4 },
{ name: 'Tier 2', probability: 0.5 },
{ name: 'Tier 3', probability: 0.08 },
{ name: 'Tier 4', probability: 0.02 }
];
let pityCounter = 0;
let pityCounterHits = 0;
let untilPity = 10;
let results = {
'Tier 1': 0,
'Tier 2': 0,
'Tier 3': 0,
'Tier 4': 0
};
// Array to store draw history
let drawHistory = [];
function drawGachapon(numDraws) {
let selectedRarity = document.querySelector('input[name="rarity"]:checked').value;
let coinCost = getCoinCost(selectedRarity);
let coinInput = document.getElementById('coinInput');
let currentCoins = parseInt(coinInput.value);
if (currentCoins < coinCost * numDraws) {
alert("Not enough coins!");
return;
}
currentCoins -= coinCost * numDraws;
coinInput.value = currentCoins;
for (let i = 0; i < numDraws; i++) {
let random = Math.random();
let cumulativeProbability = 0;
pityCounter++;
untilPity--;
// Check for pity
if (pityCounter >= 10) {
pityCounter = 0;
pityCounterHits++;
untilPity = 10; // Reset untilPity
if (Math.random() < 0.8) {
pullItem('Tier 3');
} else {
pullItem('Tier 4');
}
continue;
}
// Normal draw
for (let tier of tiers) {
cumulativeProbability += tier.probability;
if (random < cumulativeProbability) {
pullItem(tier.name);
if (tier.name === 'Tier 3' || tier.name === 'Tier 4') {
pityCounter = 0; // Reset pity counter if Tier 3 or Tier 4 is drawn
untilPity = 10; // Reset untilPity
}
break;
}
}
}
// Update the UI with results
updateResults();
}
function getCoinCost(rarity) {
switch (rarity) {
case 'common':
return 200;
case 'uncommon':
return 600;
case 'rare':
return 1200;
default:
return 200;
}
}
function pullItem(tierName) {
// Randomly select one item from the list
let selectedItem = items[Math.floor(Math.random() * items.length)];
results[tierName]++;
drawHistory.push(`${selectedItem} (${tierName})`);
}
function updateResults() {
// Display the cumulative results for pulled items
let outputDiv = document.getElementById('output');
let totalsList = document.getElementById('totals');
// Clear the output before appending new results
outputDiv.innerHTML = '';
totalsList.innerHTML = '';
// Append to the end of the output log
drawHistory.forEach(item => {
let p = document.createElement('p');
p.textContent = item;
outputDiv.appendChild(p);
});
// Display the total numbers of each tier that was pulled
tiers.forEach(tier => {
let li = document.createElement('li');
li.textContent = `${tier.name}: ${results[tier.name]}`;
totalsList.appendChild(li);
});
// Display the pity counter hits
document.getElementById('pityCounterHits').textContent = `Pity Counter Hits: ${pityCounterHits}`;
// Display the until pity
document.getElementById('untilPity').textContent = `Until Pity: ${untilPity}`;
}
function resetSimulation() {
// Reset all counters and results
pityCounter = 0;
pityCounterHits = 0;
untilPity = 10;
results = {
'Tier 1': 0,
'Tier 2': 0,
'Tier 3': 0,
'Tier 4': 0
};
drawHistory = [];
// Update the UI with reset results
updateResults();
}
function toggleDarkMode() {
document.body.classList.toggle('dark-mode');
}
window.onload = function() {
document.body.classList.add('dark-mode');
};
</script>
</body>
</html>