diff --git a/assets/en/svg/text/scene/stage/tx_fesmatch-2cee60cbe41a1594b8d5ef867138f99d843cfce6efe0c490a41632b2e99ec685.svg b/assets/en/svg/text/scene/stage/tx_fesmatch-2cee60cbe41a1594b8d5ef867138f99d843cfce6efe0c490a41632b2e99ec685.svg new file mode 100644 index 0000000..68a41fe --- /dev/null +++ b/assets/en/svg/text/scene/stage/tx_fesmatch-2cee60cbe41a1594b8d5ef867138f99d843cfce6efe0c490a41632b2e99ec685.svg @@ -0,0 +1,13 @@ + + diff --git a/assets/en/svg/ui/ico_stage_fes-d2041f3d0fc360ad6c7c00dc4f5bfd1aa626a251d35af88c076b5498d8eb991d.svg b/assets/en/svg/ui/ico_stage_fes-d2041f3d0fc360ad6c7c00dc4f5bfd1aa626a251d35af88c076b5498d8eb991d.svg new file mode 100644 index 0000000..ced91a5 --- /dev/null +++ b/assets/en/svg/ui/ico_stage_fes-d2041f3d0fc360ad6c7c00dc4f5bfd1aa626a251d35af88c076b5498d8eb991d.svg @@ -0,0 +1,17 @@ + + diff --git a/assets/en/ui/Splatnet_its_splatfest_time!.png b/assets/en/ui/Splatnet_its_splatfest_time!.png new file mode 100644 index 0000000..0b35a35 Binary files /dev/null and b/assets/en/ui/Splatnet_its_splatfest_time!.png differ diff --git a/stages/stages.js b/stages/stages.js index 80731a2..af3fbb6 100644 --- a/stages/stages.js +++ b/stages/stages.js @@ -105,7 +105,7 @@ window.loadHeader(async function(headerContainer) { if (nameEl) { const parsedName = miiBlob ? extractMiiName(miiBlob) : null; - nameEl.textContent = parsedName || (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; + nameEl.textContent = parsedName || (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "Loading..."; } if (imgEl && miiBlob) { @@ -189,13 +189,39 @@ async function fetchRotations() { const res = await fetch(API_URL); if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`); const data = await res.json(); - const rotations = data?.pretendo?.rotations ?? {}; const now = new Date(); - let allData = Object.keys(rotations).map(ts => { + + const fest = data?.splatfestivalSplatfest; + let currentFest = null; + + if (fest && fest.stages && fest.stages.length > 0) { + const festStart = new Date(fest.time.start * 1000); + const festEnd = new Date(fest.time.end * 1000); + + if (now >= festStart && now <= festEnd) { + currentFest = { + isFest: true, + turf: stageNames(fest.stages), + startTime: festStart, + endTime: festEnd, + isExpired: false + }; + } + } + + if (currentFest) { + return [currentFest]; + } + + const rotations = data?.pretendo?.rotations ?? {}; + + let standardRotations = Object.keys(rotations).map(ts => { const start = new Date(Number(ts)); - const end = new Date(start.getTime() + 2 * 60 * 60 * 1000); const r = rotations[ts]; + const end = new Date(start.getTime() + (r.duration * 60 * 60 * 1000)); + return { + isFest: false, turf: stageNames(r.turfStages), ranked: stageNames(r.rankedStages), ranked_mode: r.rankedMode.replace(/([a-z])([A-Z])/g, "$1 $2"), @@ -204,8 +230,10 @@ async function fetchRotations() { isExpired: end < now }; }); - const active = allData.filter(r => !r.isExpired).sort((a, b) => a.startTime - b.startTime); - const past = allData.filter(r => r.isExpired).sort((a, b) => b.startTime - a.startTime); + + const active = standardRotations.filter(r => !r.isExpired).sort((a, b) => a.startTime - b.startTime); + const past = standardRotations.filter(r => r.isExpired).sort((a, b) => b.startTime - a.startTime); + return [...active, ...past]; } catch (error) { console.error(error); @@ -215,32 +243,25 @@ async function fetchRotations() { async function renderStages() { const container = document.getElementById("stages-container"); - try { allRotations = await fetchRotations(); if (!allRotations.length) { container.innerHTML = `