fixed map display and fixed some routing issues for if the hunt timer runs out.

Grey = cant click
Red = current
Green = complete
blue = skipped?
This commit is contained in:
bobbert committed 2025-03-15 20:13:00 +00:00
1 parent 0afa6817a8
commit 6d1cbe9195
5 files changed
+67 -27

No files matched your search

+12
View File
@@ -12,6 +12,7 @@ export default function HuntNotStarted() {
// Add aggressive hunt status checking // Add aggressive hunt status checking
useEffect(() => { useEffect(() => {
let redirectAttempted = false; let redirectAttempted = false;
let huntWasActive = null;
// Function to check hunt status // Function to check hunt status
async function checkHuntStatus() { async function checkHuntStatus() {
@@ -32,11 +33,22 @@ export default function HuntNotStarted() {
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
// Check if hunt ended (was active before but not active now)
if (huntWasActive === true && !data.active) {
console.log("Hunt ended! Redirecting to leaderboard");
redirectAttempted = true;
window.location.replace("/leaderboard?huntEnded=true");
return;
}
// If hunt becomes active while on this page, immediately redirect to map // If hunt becomes active while on this page, immediately redirect to map
if (data.active) { if (data.active) {
huntWasActive = true;
console.log("Hunt now active! Redirecting to map page"); console.log("Hunt now active! Redirecting to map page");
redirectAttempted = true; redirectAttempted = true;
window.location.replace("/map"); window.location.replace("/map");
} else {
huntWasActive = false;
} }
} }
} catch (err) { } catch (err) {
+19 -22
View File
@@ -64,50 +64,47 @@
height: 100%; height: 100%;
background-color: #69b5a8; /* Background color */ background-color: #69b5a8; /* Background color */
overflow: auto; /* Enable scrolling */ overflow: auto; /* Enable scrolling */
display: flex; /* Add flexbox to center content */ display: block; /* Change from flex to block for proper scrolling */
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
} }
.treasure-map { .treasure-map {
position: relative; position: relative;
width: 100%; width: fit-content; /* Change from 100% to fit-content to allow natural svg size */
height: 100%; min-width: 100%; /* Ensure it's at least full width */
display: flex; /* Add flexbox for centering */ height: fit-content;
justify-content: center; min-height: 100%;
align-items: center; display: flex; /* Keep flex for alignment */
justify-content: flex-end; /* Align to the right */
align-items: flex-start; /* Align to the top */
} }
/* SVG container for better scrolling and zooming */ /* SVG container for better scrolling and zooming */
.svg-container { .svg-container {
position: relative; position: relative;
width: 100%; width: fit-content; /* Allow natural width */
height: 100%; height: fit-content; /* Allow natural height */
display: flex; display: block; /* Change to block for proper scrolling */
justify-content: center; overflow: visible; /* Show content beyond boundaries */
align-items: center;
overflow: visible; /* Change from auto to visible */
} }
.svg-container svg { .svg-container svg {
max-width: 100%; max-width: none; /* Remove max-width limitation */
max-height: 90vh; /* Limit height to 90% of viewport height */
width: auto; width: auto;
height: auto; height: auto;
display: block; display: block;
object-fit: contain; /* Ensure the entire SVG is visible */ object-fit: none; /* Don't constrain the SVG */
} }
/* Map background - display as full-page map */ /* Map background - display as full-page map */
.map-background { .map-background {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; right: 0; /* Align to the right */
width: 100%; width: 100vw; /* Full viewport width */
height: 100%; height: auto;
background-image: url("/images/map.svg"); background-image: url("/images/map.svg");
background-size: contain; background-size: auto; /* Don't resize the background */
background-position: center; background-position: top right; /* Position at top right */
background-repeat: no-repeat; background-repeat: no-repeat;
z-index: 5; z-index: 5;
} }
+20 -4
View File
@@ -483,8 +483,23 @@ export default function MapPage() {
const data = await response.json(); const data = await response.json();
console.log("Map page hunt status check:", data); console.log("Map page hunt status check:", data);
// If hunt is not active, force redirect to waiting page // If hunt is not active, check if it was active before (hunt ended)
if (!data.active) { if (!data.active) {
// Check if we had an active hunt before
const timerData = getHuntTimer();
if (timerData && timerData.isActive) {
// Hunt was active before but not now - it has ended
console.log("Hunt has ended, redirecting to leaderboard");
clearHuntTimer();
if (isMounted.current) {
hardRedirect("/leaderboard?huntEnded=true");
}
return;
}
// If hunt was never active, redirect to waiting page
console.log("Hunt not active, redirecting to waiting page"); console.log("Hunt not active, redirecting to waiting page");
if (isMounted.current) { if (isMounted.current) {
softRedirect("/waiting"); softRedirect("/waiting");
@@ -496,7 +511,8 @@ export default function MapPage() {
if (data.endTime && new Date(data.endTime) <= new Date()) { if (data.endTime && new Date(data.endTime) <= new Date()) {
console.log("Timer expired, redirecting to leaderboard"); console.log("Timer expired, redirecting to leaderboard");
if (isMounted.current) { if (isMounted.current) {
softRedirect("/leaderboard?huntEnded=true"); clearHuntTimer();
hardRedirect("/leaderboard?huntEnded=true");
} }
return; return;
} }
@@ -515,7 +531,7 @@ export default function MapPage() {
const intervalId = setInterval(checkHuntStatus, 1000); const intervalId = setInterval(checkHuntStatus, 1000);
return () => clearInterval(intervalId); return () => clearInterval(intervalId);
}, [softRedirect]); }, [softRedirect, hardRedirect]);
if (status === "loading" || loading) { if (status === "loading" || loading) {
return ( return (
@@ -572,7 +588,7 @@ export default function MapPage() {
<div className={styles["team-code"]}>{teamData?.team?.code || ""}</div> <div className={styles["team-code"]}>{teamData?.team?.code || ""}</div>
</div> </div>
{/* Main map content area - map fills the entire container */} {/* Main map content area - now allows scrolling with right alignment */}
<div className={styles["map-container"]} ref={mapContainerRef}> <div className={styles["map-container"]} ref={mapContainerRef}>
<div className={styles["treasure-map"]}> <div className={styles["treasure-map"]}>
{mapSvg ? ( {mapSvg ? (
+16 -1
View File
@@ -17,6 +17,7 @@ export default function WaitingPage() {
useEffect(() => { useEffect(() => {
let redirectAttempted = false; let redirectAttempted = false;
let lastKnownHuntStatus = false; let lastKnownHuntStatus = false;
let lastHuntData = null;
async function checkHuntStatus() { async function checkHuntStatus() {
if (redirectAttempted) return; if (redirectAttempted) return;
@@ -102,8 +103,22 @@ export default function WaitingPage() {
return; return;
} }
// If this is a new session but we detect signs of a hunt that ended
if (!lastHuntData && !data.active && data.startTime && data.endTime) {
// Handle case where user lands directly on waiting page after hunt ended
console.log("Hunt appears to have already ended");
setHuntEnded(true);
// Redirect to leaderboard after a brief delay
setTimeout(() => {
window.location.href = "/leaderboard?huntEnded=true";
}, 2000);
return;
}
// Save the current hunt data for next comparison // Save the current hunt data for next comparison
setLastHuntData(data); lastHuntData = data;
if (data.active) { if (data.active) {
// Store the global start time in the centralized timer service // Store the global start time in the centralized timer service
BIN
View File
Binary file not shown.