From 00d476a0e51629f06407aed035fbc001d3f6b114 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 26 Jun 2026 21:55:46 -0700 Subject: initial guess MV mode --- src/app.tsx | 2 + src/components/Game/index.tsx | 54 ++++++++++---- src/components/InfoPopUp/index.tsx | 9 ++- src/components/MVPlayer/index.styled.ts | 73 +++++++++++++++++++ src/components/MVPlayer/index.tsx | 85 ++++++++++++++++++++++ src/components/Search/index.tsx | 8 +- src/components/index.ts | 1 + src/helpers/fetchSolution.ts | 32 ++++++++ src/helpers/searchSong.ts | 5 +- src/hooks/useGameState.ts | 39 +++++++--- src/pages/DailyPage.tsx | 2 +- src/pages/LandingPage.tsx | 125 ++++++++++++++++++++++++-------- src/pages/MVPage.tsx | 76 +++++++++++++++++++ src/pages/UnlimitedPage.tsx | 2 +- 14 files changed, 447 insertions(+), 66 deletions(-) create mode 100644 src/components/MVPlayer/index.styled.ts create mode 100644 src/components/MVPlayer/index.tsx create mode 100644 src/pages/MVPage.tsx (limited to 'src') diff --git a/src/app.tsx b/src/app.tsx index 044cbfc..163d769 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,6 +4,7 @@ import { BrowserRouter, Routes, Route } from "react-router-dom"; import { LandingPage } from "./pages/LandingPage"; import { DailyPage } from "./pages/DailyPage"; import { UnlimitedPage } from "./pages/UnlimitedPage"; +import { MVPage } from "./pages/MVPage"; function App() { return ( @@ -11,6 +12,7 @@ function App() { } /> } /> + } /> } /> diff --git a/src/components/Game/index.tsx b/src/components/Game/index.tsx index 8afa516..8e16d46 100644 --- a/src/components/Game/index.tsx +++ b/src/components/Game/index.tsx @@ -3,8 +3,9 @@ import React from "react"; import { GuessType } from "../../types/guess"; import { Song } from "../../types/song"; import { playTimes } from "../../constants"; +import { musicVideos } from "../../../server/data/mvs"; -import { Button, Guess, YTPlayer, Search, Result, Player } from "../"; +import { Button, Guess, YTPlayer, Search, Result, Player, MVPlayer } from "../"; import * as Styled from "./index.styled"; @@ -17,7 +18,7 @@ interface Props { setSelectedSong: React.Dispatch>; skip: () => void; guess: () => void; - mode?: "daily" | "unlimited"; + mode?: "daily" | "unlimited" | "dailyMV"; onPlayAgain?: () => void; isSubmitting?: boolean; } @@ -39,27 +40,36 @@ export function Game({ onPlayAgain, isSubmitting = false, }: Props) { - const recentFinishedPlay = localStorage.getItem("recentFinishedPlay"); + const recentFinishedPlay = + mode === "dailyMV" + ? localStorage.getItem("recentFinishedPlayMV") + : localStorage.getItem("recentFinishedPlay"); const hasFinishedCurrentRound = didGuess || currentTry >= guesses.length; const hasFinishedResponseDaily = - mode === "daily" && !!dailyDate && recentFinishedPlay === dailyDate; - const isGameOver = hasFinishedCurrentRound || hasFinishedResponseDaily; + (mode === "daily" || mode === "dailyMV") && + !!dailyDate && + recentFinishedPlay === dailyDate; const isBlocked = - mode === "daily" && + (mode === "daily" || mode === "dailyMV") && !!dailyDate && !hasFinishedResponseDaily && new Date(getUtcDate()) > new Date(dailyDate); const sessionDate = dailyDate ?? getUtcDate(); React.useEffect(() => { - if (mode !== "daily") return; + if (mode !== "daily" && mode !== "dailyMV") return; if (!hasFinishedCurrentRound) return; - localStorage.setItem("recentFinishedPlay", sessionDate); - const historicalPlayData = localStorage.getItem("historicalPlayData"); + const storageKey = + mode === "dailyMV" ? "recentFinishedPlayMV" : "recentFinishedPlay"; + localStorage.setItem(storageKey, sessionDate); + + const historicalKey = + mode === "dailyMV" ? "historicalPlayDataMV" : "historicalPlayData"; + const historicalPlayData = localStorage.getItem(historicalKey); if (historicalPlayData === null) { localStorage.setItem( - "historicalPlayData", + historicalKey, JSON.stringify({ sessionDates: [sessionDate], guesses: [currentTry], @@ -70,7 +80,7 @@ export function Game({ const parsedData = JSON.parse(historicalPlayData); if (parsedData.sessionDates.includes(sessionDate)) return; localStorage.setItem( - "historicalPlayData", + historicalKey, JSON.stringify({ sessionDates: [...parsedData.sessionDates, sessionDate], guesses: [...parsedData.guesses, currentTry], @@ -81,17 +91,23 @@ export function Game({ }, [mode, hasFinishedCurrentRound, sessionDate, currentTry, didGuess]); if (isBlocked) { - return

Daily MIXX is not available yet. Check back soon!

; + return ( +

+ {mode === "dailyMV" + ? "Daily MV is not available yet. Check back soon!" + : "Daily MIXX is not available yet. Check back soon!"} +

+ ); } - if (isGameOver) { + if (hasFinishedCurrentRound || hasFinishedResponseDaily) { return ( @@ -105,17 +121,25 @@ export function Game({ ))} {mode === "unlimited" ? ( + ) : mode === "dailyMV" ? ( + ) : ( )} - +