Shuffle question order on each new game so every run is different

This commit is contained in:
Justin Oros
2026-05-20 11:59:12 -07:00
parent 4c0034a37a
commit eff440d1f2
+9 -1
View File
@@ -944,7 +944,15 @@ class Game {
if (this.state.questions.length>0) { cb(); return; }
fetch('./questions.json')
.then(r=>r.json())
.then(data=>{ this.state.questions=data.levels[0].questions; cb(); })
.then(data=>{
const qs = data.levels[0].questions;
for (let i = qs.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[qs[i], qs[j]] = [qs[j], qs[i]];
}
this.state.questions = qs;
cb();
})
.catch(()=>this.toast('❌ Could not load questions.json'));
}