Do some improvements
This commit is contained in:
13
index.html
13
index.html
@ -204,11 +204,17 @@
|
||||
<p>After all groups, I'll be able to tell you your number! 🎩✨</p>
|
||||
</div>
|
||||
<div style="margin: 20px 0;">
|
||||
<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,11 +256,13 @@
|
||||
bitPosition++;
|
||||
}
|
||||
|
||||
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) {
|
||||
// Shuffle numbers within each group but keep first number in place
|
||||
@ -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');
|
||||
|
Reference in New Issue
Block a user