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>
|
<p>After all groups, I'll be able to tell you your number! 🎩✨</p>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 20px 0;">
|
<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;">
|
<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);">
|
<input type="checkbox" id="randomizeToggle" style="transform: scale(1.2);">
|
||||||
Randomize numbers within groups
|
Randomize numbers within groups
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<button class="btn btn-primary" onclick="startGame()">Start Game</button>
|
<button class="btn btn-primary" onclick="startGame()">Start Game</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -235,7 +241,7 @@
|
|||||||
let currentGroup = 0;
|
let currentGroup = 0;
|
||||||
let groups = [];
|
let groups = [];
|
||||||
|
|
||||||
function generateNumberGroups(maxNumber = 100, shouldRandomize = false) {
|
function generateNumberGroups(maxNumber = 100, shouldRandomize = false, shouldShuffleGroups = false) {
|
||||||
const generatedGroups = [];
|
const generatedGroups = [];
|
||||||
let bitPosition = 1; // Start from bit position 1 to skip the first group (odd numbers)
|
let bitPosition = 1; // Start from bit position 1 to skip the first group (odd numbers)
|
||||||
|
|
||||||
@ -250,11 +256,13 @@
|
|||||||
bitPosition++;
|
bitPosition++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldShuffleGroups) {
|
||||||
// Shuffle the groups to make it more mysterious
|
// Shuffle the groups to make it more mysterious
|
||||||
for (let i = generatedGroups.length - 1; i > 0; i--) {
|
for (let i = generatedGroups.length - 1; i > 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
[generatedGroups[i], generatedGroups[j]] = [generatedGroups[j], generatedGroups[i]];
|
[generatedGroups[i], generatedGroups[j]] = [generatedGroups[j], generatedGroups[i]];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldRandomize) {
|
if (shouldRandomize) {
|
||||||
// Shuffle numbers within each group but keep first number in place
|
// Shuffle numbers within each group but keep first number in place
|
||||||
@ -280,7 +288,8 @@
|
|||||||
|
|
||||||
function startGame() {
|
function startGame() {
|
||||||
const shouldRandomize = document.getElementById('randomizeToggle').checked;
|
const shouldRandomize = document.getElementById('randomizeToggle').checked;
|
||||||
groups = generateNumberGroups(100, shouldRandomize);
|
const shouldShuffleGroups = document.getElementById('shuffleGroupsToggle').checked;
|
||||||
|
groups = generateNumberGroups(100, shouldRandomize, shouldShuffleGroups);
|
||||||
currentGroup = 0;
|
currentGroup = 0;
|
||||||
|
|
||||||
document.getElementById('welcome').classList.remove('active');
|
document.getElementById('welcome').classList.remove('active');
|
||||||
|
Reference in New Issue
Block a user