[Fix] clean & true randomness
This commit is contained in:
parent
353f75bf5d
commit
89feb1bc32
3 changed files with 122 additions and 44 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"name": "closingin",
|
||||
"destructive": false
|
||||
"destructive": true
|
||||
},
|
||||
{
|
||||
"name": "horse_fog",
|
||||
|
|
@ -21,13 +21,11 @@
|
|||
},
|
||||
{
|
||||
"name": "outpost",
|
||||
"destructive": true,
|
||||
"time": 8
|
||||
"destructive": false
|
||||
},
|
||||
{
|
||||
"name": "tower_small",
|
||||
"destructive": true,
|
||||
"time": 8
|
||||
"destructive": false
|
||||
},
|
||||
{
|
||||
"name": "tower_large",
|
||||
|
|
@ -38,11 +36,11 @@
|
|||
"destructive": false
|
||||
},
|
||||
{
|
||||
"name": "mountain_horse",
|
||||
"name": "armoury",
|
||||
"destructive": false
|
||||
},
|
||||
{
|
||||
"name": "armoury",
|
||||
"name": "mountain_horse",
|
||||
"destructive": false
|
||||
},
|
||||
{
|
||||
|
|
@ -71,6 +69,6 @@
|
|||
},
|
||||
{
|
||||
"name": "secondsbeforedisaster",
|
||||
"destructive": true
|
||||
"destructive": false
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ function initParallax() {
|
|||
update();
|
||||
}
|
||||
|
||||
// ─── Hero Slideshow with Destructive Theme ───
|
||||
// ─── Hero Slideshow ───
|
||||
let currentBackdrop = null;
|
||||
const NEAR_TOP_THRESHOLD = 1800;
|
||||
|
||||
|
|
@ -63,8 +63,19 @@ function initHeroSlideshow(allBackdrops, usedNames) {
|
|||
|
||||
let idx = 0;
|
||||
|
||||
function showSlide(index) {
|
||||
const backdrop = slides[index];
|
||||
function pickRandomSlide(exclude) {
|
||||
if (slides.length === 1) return slides[0];
|
||||
|
||||
let pick;
|
||||
do {
|
||||
pick = slides[Math.floor(Math.random() * slides.length)];
|
||||
} while (pick.name === exclude?.name);
|
||||
|
||||
return pick;
|
||||
}
|
||||
|
||||
function showSlide() {
|
||||
const backdrop = pickRandomSlide(currentBackdrop);
|
||||
currentBackdrop = backdrop;
|
||||
|
||||
layer.style.opacity = "0";
|
||||
|
|
@ -76,18 +87,17 @@ function initHeroSlideshow(allBackdrops, usedNames) {
|
|||
}, 600);
|
||||
|
||||
const delayMs = (backdrop.time || 6) * 1000;
|
||||
idx = (index + 1) % slides.length;
|
||||
setTimeout(() => showSlide(idx), delayMs);
|
||||
setTimeout(showSlide, delayMs);
|
||||
}
|
||||
|
||||
currentBackdrop = slides[0];
|
||||
layer.style.backgroundImage = `url('/assets/${slides[0].name}.png')`;
|
||||
const first = pickRandomSlide();
|
||||
currentBackdrop = first;
|
||||
|
||||
layer.style.backgroundImage = `url('/assets/${first.name}.png')`;
|
||||
layer.style.opacity = "1";
|
||||
checkDestructiveTheme();
|
||||
|
||||
idx = 1;
|
||||
const initialDelay = (slides[0].time || 6) * 1000;
|
||||
setTimeout(() => showSlide(idx), initialDelay);
|
||||
setTimeout(showSlide, (first.time || 6) * 1000);
|
||||
}
|
||||
|
||||
// ─── Load Backdrops ───
|
||||
|
|
@ -124,7 +134,7 @@ async function loadBackdrops() {
|
|||
}
|
||||
}
|
||||
|
||||
// ─── Load Staff (in Socials section) ───
|
||||
// ─── Load Staff ───
|
||||
async function loadStaff() {
|
||||
try {
|
||||
const response = await fetch("/api/staff.json");
|
||||
|
|
|
|||
Loading…
Reference in a new issue