Do some improvements

This commit is contained in:
2025-09-21 18:06:04 +03:00
parent c7e274ff29
commit 72f0cca98d

View File

@ -204,10 +204,16 @@
<p>After all groups, I'll be able to tell you your number! 🎩✨</p>
</div>
<div style="margin: 20px 0;">
<label style="display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.1em; color: #555;">
<input type="checkbox" id="randomizeToggle" style="transform: scale(1.2);">
Randomize numbers within groups
</label>
<div style="display: flex; flex-direction: column; gap: 15px;">
<label style="display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.1em; color: #555;">
<input type="checkbox" id="shuffleGroupsToggle" style="transform: scale(1.2);">
Shuffle group order
</label>
<label style="display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.1em; color: #555;">
<input type="checkbox" id="randomizeToggle" style="transform: scale(1.2);">
Randomize numbers within groups
</label>
</div>
</div>
<button class="btn btn-primary" onclick="startGame()">Start Game</button>
</div>
@ -235,7 +241,7 @@
let currentGroup = 0;
let groups = [];
function generateNumberGroups(maxNumber = 100, shouldRandomize = false) {
function generateNumberGroups(maxNumber = 100, shouldRandomize = false, shouldShuffleGroups = false) {
const generatedGroups = [];
let bitPosition = 1; // Start from bit position 1 to skip the first group (odd numbers)
@ -250,10 +256,12 @@
bitPosition++;
}
// Shuffle the groups to make it more mysterious
for (let i = generatedGroups.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[generatedGroups[i], generatedGroups[j]] = [generatedGroups[j], generatedGroups[i]];
if (shouldShuffleGroups) {
// Shuffle the groups to make it more mysterious
for (let i = generatedGroups.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[generatedGroups[i], generatedGroups[j]] = [generatedGroups[j], generatedGroups[i]];
}
}
if (shouldRandomize) {
@ -280,7 +288,8 @@
function startGame() {
const shouldRandomize = document.getElementById('randomizeToggle').checked;
groups = generateNumberGroups(100, shouldRandomize);
const shouldShuffleGroups = document.getElementById('shuffleGroupsToggle').checked;
groups = generateNumberGroups(100, shouldRandomize, shouldShuffleGroups);
currentGroup = 0;
document.getElementById('welcome').classList.remove('active');