Download index.html from Jocaa91/stop: direct link, hf CLI and curl.
- Browser
- Download file 42.6 kB
-
https://huggingface.co/spaces/Jocaa91/stop/resolve/main/index.html
- Command line
-
hf download hf://spaces/Jocaa91/stop/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Jocaa91/stop/resolve/main/index.html
42.6 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
| <title>Stop Game - Multiplayer Word Challenge</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| @keyframes pulse { | |
| 0%, 100% { opacity: 1; } | |
| 50% { opacity: 0.5; } | |
| } | |
| .animate-pulse-custom { | |
| animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; | |
| } | |
| .category-input:focus { | |
| outline: none; | |
| box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); | |
| } | |
| .flip-card { | |
| perspective: 1000px; | |
| } | |
| .flip-card-inner { | |
| transition: transform 0.6s; | |
| transform-style: preserve-3d; | |
| } | |
| .flip-card.flipped .flip-card-inner { | |
| transform: rotateY(180deg); | |
| } | |
| .flip-card-front, .flip-card-back { | |
| backface-visibility: hidden; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| } | |
| .flip-card-back { | |
| transform: rotateY(180deg); | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen"> | |
| <!-- Audio elements for sound effects and music --> | |
| <audio id="bgMusic" loop src="https://assets.mixkit.co/music/preview/mixkit-game-show-suspense-waiting-668.mp3" preload="auto"></audio> | |
| <audio id="tickSound" src="https://assets.mixkit.co/sfx/preview/mixkit-clock-countdown-bleeps-916.mp3" preload="auto"></audio> | |
| <audio id="stopSound" src="https://assets.mixkit.co/sfx/preview/mixkit-game-show-suspense-waiting-668.mp3" preload="auto"></audio> | |
| <audio id="correctSound" src="https://assets.mixkit.co/sfx/preview/mixkit-correct-answer-tone-2870.mp3" preload="auto"></audio> | |
| <audio id="wrongSound" src="https://assets.mixkit.co/sfx/preview/mixkit-wrong-answer-fail-notification-946.mp3" preload="auto"></audio> | |
| <audio id="winSound" src="https://assets.mixkit.co/sfx/preview/mixkit-winning-chimes-2015.mp3" preload="auto"></audio> | |
| <div class="container mx-auto px-4 py-8 max-w-6xl"> | |
| <!-- Header --> | |
| <header class="text-center mb-8"> | |
| <h1 class="text-4xl md:text-5xl font-bold text-indigo-800 mb-2">STOP!</h1> | |
| <p class="text-lg text-indigo-600">The Ultimate Word Challenge Game</p> | |
| <a href="path/to/game.apk" class="mt-4 inline-block bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-lg transition"> | |
| <i class="fas fa-download mr-2"></i> Download Android App | |
| </a> | |
| <button id="musicToggle" class="mt-4 ml-4 inline-block bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded-lg transition"> | |
| <i class="fas fa-music mr-2"></i> Toggle Music | |
| </button> | |
| </header> | |
| <!-- Game Setup Modal --> | |
| <div id="setupModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4"> | |
| <div class="bg-white rounded-xl shadow-2xl p-6 w-full max-w-md max-h-[80vh] overflow-y-auto"> | |
| <h2 class="text-2xl font-bold text-indigo-800 mb-4">Game Setup</h2> | |
| <div class="mb-6"> | |
| <h3 class="text-lg font-semibold text-gray-800 mb-2">Game Mode</h3> | |
| <div class="grid grid-cols-2 gap-3"> | |
| <button onclick="setGameMode('multiplayer')" class="mode-btn bg-indigo-100 hover:bg-indigo-200 text-indigo-800 py-4 px-4 rounded-lg transition flex flex-col items-center" style="min-height: 80px;"> | |
| <i class="fas fa-users text-2xl mb-1"></i> | |
| <span>Multiplayer</span> | |
| </button> | |
| <button onclick="setGameMode('computer')" class="mode-btn bg-indigo-100 hover:bg-indigo-200 text-indigo-800 py-4 px-4 rounded-lg transition flex flex-col items-center" style="min-height: 80px;"> | |
| <i class="fas fa-robot text-2xl mb-1"></i> | |
| <span>Vs Computer</span> | |
| </button> | |
| </div> | |
| </div> | |
| <div id="playerSetup" class="mb-6"> | |
| <h3 class="text-lg font-semibold text-gray-800 mb-2">Players</h3> | |
| <div id="playerInputs" class="space-y-2"> | |
| <div class="flex items-center"> | |
| <input type="text" placeholder="Player 1" class="player-name flex-1 border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500"> | |
| <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)" disabled> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <button onclick="addPlayer()" class="mt-2 text-indigo-600 hover:text-indigo-800 flex items-center"> | |
| <i class="fas fa-plus-circle mr-1"></i> Add Player | |
| </button> | |
| </div> | |
| <div class="mb-6"> | |
| <h3 class="text-lg font-semibold text-gray-800 mb-2">Categories</h3> | |
| <div class="grid grid-cols-2 gap-2"> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Name"> Name | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="City"> City | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Animal"> Animal | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Food"> Food | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Job"> Job | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Verb"> Verb | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Object"> Object | |
| </label> | |
| </div> | |
| </div> | |
| <button onclick="startGame()" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-4 rounded-lg transition"> | |
| Start Game <i class="fas fa-play ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Game Container --> | |
| <div id="gameContainer" class="hidden"> | |
| <!-- Game Controls --> | |
| <div class="bg-white rounded-xl shadow-lg p-4 mb-6"> | |
| <div class="flex flex-wrap items-center justify-between gap-4"> | |
| <div> | |
| <h2 class="text-xl font-bold text-indigo-800">Round <span id="roundNumber">1</span></h2> | |
| <p class="text-gray-600">Letter: <span id="currentLetter" class="font-bold text-2xl text-indigo-600">A</span></p> | |
| </div> | |
| <div class="flex items-center space-x-3"> | |
| <div id="timerContainer" class="flex items-center"> | |
| <i class="fas fa-clock text-indigo-600 mr-2"></i> | |
| <span id="timer" class="font-mono text-xl">60</span> | |
| </div> | |
| <button id="stopBtn" class="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-8 rounded-full transition flex items-center text-lg"> | |
| STOP <i class="fas fa-hand-paper ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Game Board --> | |
| <div class="bg-white rounded-xl shadow-lg overflow-hidden mb-6"> | |
| <div class="overflow-x-auto"> | |
| <table class="w-full"> | |
| <thead> | |
| <tr class="bg-indigo-100 text-indigo-800"> | |
| <th class="py-3 px-4 text-left">Player</th> | |
| <th id="nameHeader" class="py-3 px-4 text-left">Name</th> | |
| <th id="cityHeader" class="py-3 px-4 text-left">City</th> | |
| <th id="animalHeader" class="py-3 px-4 text-left">Animal</th> | |
| <th id="foodHeader" class="py-3 px-4 text-left">Food</th> | |
| <th id="jobHeader" class="py-3 px-4 text-left">Job</th> | |
| <th id="verbHeader" class="py-3 px-4 text-left">Verb</th> | |
| <th id="objectHeader" class="py-3 px-4 text-left">Object</th> | |
| <th class="py-3 px-4 text-left">Score</th> | |
| </tr> | |
| </thead> | |
| <tbody id="scoreboardBody" class="divide-y divide-gray-200"> | |
| <!-- Player rows will be added here --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| <!-- Player Input Area --> | |
| <div id="playerInputArea" class="bg-white rounded-xl shadow-lg p-6 mb-6"> | |
| <h3 class="text-lg font-semibold text-gray-800 mb-4">Your Answers</h3> | |
| <div class="grid grid-cols-1 sm:grid-cols-2 gap-3"> | |
| <div id="nameInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Name</label> | |
| <input type="text" id="nameInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| <div id="cityInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">City</label> | |
| <input type="text" id="cityInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| <div id="animalInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Animal</label> | |
| <input type="text" id="animalInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| <div id="foodInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Food</label> | |
| <input type="text" id="foodInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| <div id="jobInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Job</label> | |
| <input type="text" id="jobInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| <div id="verbInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Verb</label> | |
| <input type="text" id="verbInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| <div id="objectInputContainer" class="category-input-container"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Object</label> | |
| <input type="text" id="objectInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with..."> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Game Actions --> | |
| <div class="flex flex-wrap justify-between gap-4"> | |
| <button onclick="showSetupModal()" class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold py-2 px-4 rounded-lg transition flex items-center"> | |
| <i class="fas fa-cog mr-2"></i> Settings | |
| </button> | |
| <button id="nextRoundBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition flex items-center"> | |
| Next Round <i class="fas fa-arrow-right ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Results Modal --> | |
| <div id="resultsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4 hidden"> | |
| <div class="bg-white rounded-xl shadow-2xl p-6 w-full max-w-2xl"> | |
| <h2 class="text-2xl font-bold text-indigo-800 mb-4">Round Results</h2> | |
| <div class="mb-4"> | |
| <div class="overflow-x-auto mb-6"> | |
| <table class="w-full"> | |
| <thead> | |
| <tr class="bg-indigo-100 text-indigo-800"> | |
| <th class="py-3 px-4 text-left">Player</th> | |
| <th class="py-3 px-4 text-left">Score</th> | |
| <th class="py-3 px-4 text-left">Details</th> | |
| </tr> | |
| </thead> | |
| <tbody id="resultsBody" class="divide-y divide-gray-200"> | |
| <!-- Results will be added here --> | |
| </tbody> | |
| </table> | |
| </div> | |
| <div class="bg-gray-50 rounded-lg p-4"> | |
| <h3 class="text-lg font-semibold text-gray-800 mb-3">Answer Comparison</h3> | |
| <div class="overflow-x-auto"> | |
| <table class="w-full text-sm"> | |
| <thead> | |
| <tr class="text-left border-b"> | |
| <th class="py-2 px-3">Category</th> | |
| <th class="py-2 px-3" id="currentPlayerName"></th> | |
| <th class="py-2 px-3">Others</th> | |
| </tr> | |
| </thead> | |
| <tbody id="comparisonBody"> | |
| <!-- Comparison will be added here --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="flex justify-end"> | |
| <button onclick="nextRound()" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition"> | |
| Continue <i class="fas fa-arrow-right ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Winner Modal --> | |
| <div id="winnerModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4 hidden"> | |
| <div class="bg-white rounded-xl shadow-2xl p-8 w-full max-w-md text-center"> | |
| <div class="text-6xl mb-4 text-yellow-500"> | |
| <i class="fas fa-trophy"></i> | |
| </div> | |
| <h2 class="text-3xl font-bold text-indigo-800 mb-2">Game Over!</h2> | |
| <p class="text-xl mb-6"><span id="winnerName" class="font-bold text-indigo-600">Player 1</span> wins!</p> | |
| <div class="mb-6"> | |
| <p class="text-gray-600 mb-1">Final Scores:</p> | |
| <div id="finalScores" class="space-y-1"> | |
| <!-- Final scores will be added here --> | |
| </div> | |
| </div> | |
| <button onclick="resetGame()" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition"> | |
| Play Again <i class="fas fa-redo ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Game state | |
| const gameState = { | |
| players: [], | |
| currentPlayerIndex: 0, | |
| categories: [], | |
| currentLetter: '', | |
| round: 1, | |
| timer: null, | |
| timeLeft: 60, | |
| gameMode: 'multiplayer', // 'multiplayer' or 'computer' | |
| isGameRunning: false, | |
| playerAnswers: {}, | |
| computerAnswers: { | |
| Name: ["Alice", "Adam", "Anna", "Alex", "Amy", "Andrew", "Aaron", "Abigail", "Austin", "Ava"], | |
| City: ["Amsterdam", "Athens", "Atlanta", "Austin", "Ankara", "Auckland", "Albuquerque", "Anchorage", "Alexandria", "Antalya"], | |
| Animal: ["Ant", "Ape", "Albatross", "Alligator", "Anaconda", "Armadillo", "Aardvark", "Alpaca", "Angelfish", "Anemone"], | |
| Food: ["Apple", "Avocado", "Asparagus", "Almond", "Apricot", "Artichoke", "Arugula", "Acai", "Anchovy", "Angelcake"], | |
| Job: ["Actor", "Accountant", "Architect", "Artist", "Astronaut", "Athlete", "Author", "Attorney", "Auditor", "Animator"], | |
| Verb: ["Act", "Ask", "Arrange", "Assist", "Attach", "Adjust", "Admire", "Advise", "Agree", "Announce"], | |
| Object: ["Album", "Anchor", "Apron", "Arrow", "Atlas", "Amulet", "Amplifier", "Antenna", "Automobile", "Awl"] | |
| } | |
| }; | |
| // DOM elements | |
| const setupModal = document.getElementById('setupModal'); | |
| const gameContainer = document.getElementById('gameContainer'); | |
| const resultsModal = document.getElementById('resultsModal'); | |
| const winnerModal = document.getElementById('winnerModal'); | |
| const timerElement = document.getElementById('timer'); | |
| const stopBtn = document.getElementById('stopBtn'); | |
| const nextRoundBtn = document.getElementById('nextRoundBtn'); | |
| // Initialize the game | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Set up music toggle | |
| const musicToggle = document.getElementById('musicToggle'); | |
| const bgMusic = document.getElementById('bgMusic'); | |
| musicToggle.addEventListener('click', () => { | |
| if (bgMusic.paused) { | |
| bgMusic.play(); | |
| musicToggle.innerHTML = '<i class="fas fa-music mr-2"></i> Pause Music'; | |
| } else { | |
| bgMusic.pause(); | |
| musicToggle.innerHTML = '<i class="fas fa-music mr-2"></i> Play Music'; | |
| } | |
| }); | |
| // Set up event listeners for input fields | |
| document.querySelectorAll('.category-input').forEach(input => { | |
| input.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter') { | |
| stopGame(); | |
| } | |
| }); | |
| }); | |
| // Show setup modal initially | |
| showSetupModal(); | |
| }); | |
| // Game setup functions | |
| function showSetupModal() { | |
| if (gameState.isGameRunning) { | |
| pauseGame(); | |
| } | |
| setupModal.classList.remove('hidden'); | |
| } | |
| function setGameMode(mode) { | |
| gameState.gameMode = mode; | |
| document.querySelectorAll('.mode-btn').forEach(btn => { | |
| btn.classList.remove('bg-indigo-600', 'text-white'); | |
| btn.classList.add('bg-indigo-100', 'text-indigo-800'); | |
| }); | |
| const selectedBtn = mode === 'multiplayer' | |
| ? document.querySelector('button[onclick="setGameMode(\'multiplayer\')"]') | |
| : document.querySelector('button[onclick="setGameMode(\'computer\')"]'); | |
| selectedBtn.classList.remove('bg-indigo-100', 'text-indigo-800'); | |
| selectedBtn.classList.add('bg-indigo-600', 'text-white'); | |
| // Clear existing players | |
| const playerInputs = document.getElementById('playerInputs'); | |
| playerInputs.innerHTML = ''; | |
| // Add human player | |
| const humanDiv = document.createElement('div'); | |
| humanDiv.className = 'flex items-center'; | |
| humanDiv.innerHTML = ` | |
| <input type="text" placeholder="Player 1" class="player-name flex-1 border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500"> | |
| <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)" disabled> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| `; | |
| playerInputs.appendChild(humanDiv); | |
| // Add computer player if in computer mode | |
| if (mode === 'computer') { | |
| const computerDiv = document.createElement('div'); | |
| computerDiv.className = 'flex items-center'; | |
| computerDiv.innerHTML = ` | |
| <input type="text" value="Computer" readonly class="player-name flex-1 border border-gray-300 rounded px-3 py-2 bg-gray-100"> | |
| <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| `; | |
| playerInputs.appendChild(computerDiv); | |
| } | |
| } | |
| function addPlayer() { | |
| const playerInputs = document.getElementById('playerInputs'); | |
| const playerCount = playerInputs.children.length + 1; | |
| const playerDiv = document.createElement('div'); | |
| playerDiv.className = 'flex items-center'; | |
| playerDiv.innerHTML = ` | |
| <input type="text" placeholder="Player ${playerCount}" class="player-name flex-1 border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500"> | |
| <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| `; | |
| playerInputs.appendChild(playerDiv); | |
| // Disable remove button if there's only one player left | |
| if (playerInputs.children.length === 1) { | |
| playerDiv.querySelector('button').disabled = true; | |
| } else { | |
| playerInputs.querySelectorAll('button').forEach(btn => { | |
| btn.disabled = false; | |
| }); | |
| } | |
| } | |
| function removePlayer(button) { | |
| const playerDiv = button.parentNode; | |
| const playerInputs = document.getElementById('playerInputs'); | |
| const playerName = playerDiv.querySelector('.player-name').value; | |
| // Don't allow removing the last human player | |
| const humanPlayers = Array.from(playerInputs.children).filter(div => | |
| !div.querySelector('.player-name').value.includes('Computer') | |
| ); | |
| if (humanPlayers.length > 1 || playerName.includes('Computer')) { | |
| playerDiv.remove(); | |
| // Disable remove buttons if only one human player left | |
| const remainingHumanPlayers = Array.from(playerInputs.children).filter(div => | |
| !div.querySelector('.player-name').value.includes('Computer') | |
| ); | |
| if (remainingHumanPlayers.length === 1) { | |
| remainingHumanPlayers[0].querySelector('button').disabled = true; | |
| } | |
| } | |
| } | |
| function startGame() { | |
| // Start background music | |
| document.getElementById('bgMusic').play(); | |
| document.getElementById('musicToggle').innerHTML = '<i class="fas fa-music mr-2"></i> Pause Music'; | |
| // Get player names | |
| gameState.players = []; | |
| const playerNames = document.querySelectorAll('.player-name'); | |
| playerNames.forEach(input => { | |
| let name = input.value.trim(); | |
| if (!name) { | |
| name = input.hasAttribute('readonly') ? 'Computer' : `Player ${gameState.players.length + 1}`; | |
| } | |
| gameState.players.push({ | |
| name: name, | |
| score: 0, | |
| completedCategories: 0, | |
| isComputer: name.includes('Computer') | |
| }); | |
| }); | |
| // Get selected categories | |
| gameState.categories = []; | |
| document.querySelectorAll('input[type="checkbox"]:checked').forEach(checkbox => { | |
| gameState.categories.push(checkbox.value); | |
| }); | |
| // Hide/show category columns | |
| const allCategories = ['Name', 'City', 'Animal', 'Food', 'Job', 'Verb', 'Object']; | |
| allCategories.forEach(category => { | |
| const header = document.getElementById(`${category.toLowerCase()}Header`); | |
| const inputContainer = document.getElementById(`${category.toLowerCase()}InputContainer`); | |
| if (gameState.categories.includes(category)) { | |
| if (header) header.classList.remove('hidden'); | |
| if (inputContainer) inputContainer.classList.remove('hidden'); | |
| } else { | |
| if (header) header.classList.add('hidden'); | |
| if (inputContainer) inputContainer.classList.add('hidden'); | |
| } | |
| }); | |
| // Initialize game state | |
| gameState.round = 1; | |
| gameState.isGameRunning = false; | |
| gameState.playerAnswers = {}; | |
| gameState.players.forEach(player => { | |
| gameState.playerAnswers[player.name] = {}; | |
| }); | |
| // Update UI | |
| setupModal.classList.add('hidden'); | |
| gameContainer.classList.remove('hidden'); | |
| updateScoreboard(); | |
| // Start first round | |
| startRound(); | |
| } | |
| function resetGame() { | |
| // Pause background music when resetting | |
| document.getElementById('bgMusic').pause(); | |
| document.getElementById('musicToggle').innerHTML = '<i class="fas fa-music mr-2"></i> Play Music'; | |
| winnerModal.classList.add('hidden'); | |
| showSetupModal(); | |
| } | |
| // Game round functions | |
| function startRound() { | |
| gameState.isGameRunning = true; | |
| gameState.timeLeft = 60; | |
| updateTimerDisplay(); | |
| // Select a random letter (excluding Q, X, Y, Z for better gameplay) | |
| const letters = 'ABCDEFGHIJKLMNOPRSTUVW'; | |
| gameState.currentLetter = letters[Math.floor(Math.random() * letters.length)]; | |
| document.getElementById('currentLetter').textContent = gameState.currentLetter; | |
| document.getElementById('roundNumber').textContent = gameState.round; | |
| // Clear previous answers | |
| gameState.players.forEach(player => { | |
| gameState.playerAnswers[player.name] = {}; | |
| }); | |
| // Clear input fields | |
| document.querySelectorAll('.category-input').forEach(input => { | |
| input.value = ''; | |
| }); | |
| // Focus first input | |
| const firstInput = document.querySelector('.category-input'); | |
| if (firstInput) firstInput.focus(); | |
| // Start timer | |
| gameState.timer = setInterval(() => { | |
| gameState.timeLeft--; | |
| updateTimerDisplay(); | |
| if (gameState.timeLeft <= 0) { | |
| stopGame(); | |
| } | |
| }, 1000); | |
| // Enable stop button | |
| stopBtn.disabled = false; | |
| stopBtn.classList.remove('opacity-50'); | |
| stopBtn.classList.add('hover:bg-red-700'); | |
| // Disable next round button | |
| nextRoundBtn.disabled = true; | |
| nextRoundBtn.classList.add('opacity-50'); | |
| // If playing against computer, set computer answers | |
| if (gameState.gameMode === 'computer') { | |
| setTimeout(() => { | |
| gameState.players.forEach(player => { | |
| if (player.name.startsWith('Computer')) { | |
| gameState.categories.forEach(category => { | |
| const possibleAnswers = gameState.computerAnswers[category].filter(word => | |
| word.charAt(0).toUpperCase() === gameState.currentLetter | |
| ); | |
| if (possibleAnswers.length > 0) { | |
| gameState.playerAnswers[player.name][category] = possibleAnswers[Math.floor(Math.random() * possibleAnswers.length)]; | |
| } | |
| }); | |
| } | |
| }); | |
| updateScoreboard(); | |
| }, Math.random() * 20000 + 5000); // Computer answers between 5-25 seconds | |
| } | |
| } | |
| function pauseGame() { | |
| clearInterval(gameState.timer); | |
| gameState.isGameRunning = false; | |
| } | |
| function resumeGame() { | |
| if (!gameState.isGameRunning) { | |
| gameState.isGameRunning = true; | |
| gameState.timer = setInterval(() => { | |
| gameState.timeLeft--; | |
| updateTimerDisplay(); | |
| if (gameState.timeLeft <= 0) { | |
| stopGame(); | |
| } | |
| }, 1000); | |
| } | |
| } | |
| function stopGame() { | |
| if (!gameState.isGameRunning) return; | |
| clearInterval(gameState.timer); | |
| gameState.isGameRunning = false; | |
| // Disable stop button | |
| stopBtn.disabled = true; | |
| stopBtn.classList.add('opacity-50'); | |
| stopBtn.classList.remove('hover:bg-red-700'); | |
| // Enable next round button | |
| nextRoundBtn.disabled = false; | |
| nextRoundBtn.classList.remove('opacity-50'); | |
| // Get human player answers | |
| gameState.categories.forEach(category => { | |
| const input = document.getElementById(`${category.toLowerCase()}Input`); | |
| if (input) { | |
| const playerName = gameState.players[0].name; // Assuming first player is human | |
| gameState.playerAnswers[playerName][category] = input.value.trim(); | |
| } | |
| }); | |
| // Calculate scores | |
| calculateScores(); | |
| // Show results and answer comparison | |
| showResults(); | |
| showAnswerComparison(); | |
| } | |
| function nextRound() { | |
| resultsModal.classList.add('hidden'); | |
| // Check if game is over (all categories completed by any player) | |
| const winner = gameState.players.find(player => | |
| player.completedCategories >= gameState.categories.length | |
| ); | |
| if (winner) { | |
| showWinner(winner); | |
| } else { | |
| gameState.round++; | |
| startRound(); | |
| } | |
| } | |
| function updateTimerDisplay() { | |
| timerElement.textContent = gameState.timeLeft; | |
| if (gameState.timeLeft <= 10) { | |
| timerElement.classList.add('text-red-600', 'animate-pulse-custom'); | |
| if (gameState.timeLeft > 0) { | |
| document.getElementById('tickSound').play(); | |
| } | |
| } else { | |
| timerElement.classList.remove('text-red-600', 'animate-pulse-custom'); | |
| } | |
| } | |
| // Scoreboard functions | |
| function updateScoreboard() { | |
| const scoreboardBody = document.getElementById('scoreboardBody'); | |
| scoreboardBody.innerHTML = ''; | |
| gameState.players.forEach(player => { | |
| const row = document.createElement('tr'); | |
| row.className = 'hover:bg-gray-50'; | |
| // Player name cell | |
| const nameCell = document.createElement('td'); | |
| nameCell.className = 'py-3 px-4 font-medium'; | |
| nameCell.textContent = player.name; | |
| row.appendChild(nameCell); | |
| // Category cells | |
| gameState.categories.forEach(category => { | |
| const cell = document.createElement('td'); | |
| cell.className = 'py-3 px-4'; | |
| const answer = gameState.playerAnswers[player.name][category]; | |
| if (answer !== undefined && answer !== '') { | |
| cell.textContent = answer; | |
| } else { | |
| cell.innerHTML = '<span class="text-gray-400">-</span>'; | |
| } | |
| row.appendChild(cell); | |
| }); | |
| // Score cell | |
| const scoreCell = document.createElement('td'); | |
| scoreCell.className = 'py-3 px-4 font-bold'; | |
| scoreCell.textContent = player.score; | |
| row.appendChild(scoreCell); | |
| scoreboardBody.appendChild(row); | |
| }); | |
| } | |
| function calculateScores() { | |
| // Reset completed categories count | |
| gameState.players.forEach(player => { | |
| player.completedCategories = 0; | |
| }); | |
| // Calculate scores for each category | |
| gameState.categories.forEach(category => { | |
| const answers = {}; | |
| // Count occurrences of each answer | |
| gameState.players.forEach(player => { | |
| const answer = gameState.playerAnswers[player.name][category]; | |
| if (answer && answer !== '') { | |
| const key = answer.toLowerCase(); | |
| answers[key] = (answers[key] || 0) + 1; | |
| } | |
| }); | |
| // Assign points | |
| gameState.players.forEach(player => { | |
| const answer = gameState.playerAnswers[player.name][category]; | |
| if (answer && answer !== '') { | |
| const key = answer.toLowerCase(); | |
| if (answers[key] === 1) { | |
| // Unique answer - 10 points | |
| player.score += 10; | |
| } else { | |
| // Repeated answer - 5 points | |
| player.score += 5; | |
| } | |
| // Count completed categories | |
| player.completedCategories++; | |
| } | |
| }); | |
| }); | |
| updateScoreboard(); | |
| } | |
| function showResults() { | |
| document.getElementById('stopSound').play(); | |
| const resultsBody = document.getElementById('resultsBody'); | |
| resultsBody.innerHTML = ''; | |
| // Sort players by score (descending) | |
| const sortedPlayers = [...gameState.players].sort((a, b) => b.score - a.score); | |
| sortedPlayers.forEach((player, index) => { | |
| const row = document.createElement('tr'); | |
| // Player name cell | |
| const nameCell = document.createElement('td'); | |
| nameCell.className = 'py-3 px-4 font-medium'; | |
| nameCell.textContent = player.name; | |
| row.appendChild(nameCell); | |
| // Score cell | |
| const scoreCell = document.createElement('td'); | |
| scoreCell.className = 'py-3 px-4 font-bold'; | |
| scoreCell.textContent = player.score; | |
| row.appendChild(scoreCell); | |
| // Details cell | |
| const detailsCell = document.createElement('td'); | |
| detailsCell.className = 'py-3 px-4'; | |
| const completedCount = player.completedCategories; | |
| const totalCategories = gameState.categories.length; | |
| detailsCell.textContent = `${completedCount}/${totalCategories} categories`; | |
| row.appendChild(detailsCell); | |
| resultsBody.appendChild(row); | |
| }); | |
| resultsModal.classList.remove('hidden'); | |
| } | |
| function showAnswerComparison() { | |
| const comparisonBody = document.getElementById('comparisonBody'); | |
| comparisonBody.innerHTML = ''; | |
| const currentPlayer = gameState.players[0]; // Assuming first player is human | |
| document.getElementById('currentPlayerName').textContent = currentPlayer.name; | |
| gameState.categories.forEach(category => { | |
| const row = document.createElement('tr'); | |
| row.className = 'border-b border-gray-200'; | |
| // Category cell | |
| const categoryCell = document.createElement('td'); | |
| categoryCell.className = 'py-2 px-3 font-medium'; | |
| categoryCell.textContent = category; | |
| row.appendChild(categoryCell); | |
| // Player's answer cell | |
| const playerAnswerCell = document.createElement('td'); | |
| playerAnswerCell.className = 'py-2 px-3'; | |
| const playerAnswer = gameState.playerAnswers[currentPlayer.name][category] || '-'; | |
| playerAnswerCell.textContent = playerAnswer; | |
| row.appendChild(playerAnswerCell); | |
| // Others' answers cell | |
| const othersCell = document.createElement('td'); | |
| othersCell.className = 'py-2 px-3'; | |
| const otherAnswers = []; | |
| gameState.players.slice(1).forEach(player => { | |
| const answer = gameState.playerAnswers[player.name][category]; | |
| if (answer) otherAnswers.push(`${player.name}: ${answer}`); | |
| }); | |
| othersCell.textContent = otherAnswers.join(', ') || '-'; | |
| row.appendChild(othersCell); | |
| comparisonBody.appendChild(row); | |
| }); | |
| } | |
| function showWinner(winner) { | |
| document.getElementById('winSound').play(); | |
| document.getElementById('winnerName').textContent = winner.name; | |
| const finalScores = document.getElementById('finalScores'); | |
| finalScores.innerHTML = ''; | |
| // Sort players by score (descending) | |
| const sortedPlayers = [...gameState.players].sort((a, b) => b.score - a.score); | |
| sortedPlayers.forEach((player, index) => { | |
| const scoreDiv = document.createElement('div'); | |
| scoreDiv.className = 'flex justify-between items-center'; | |
| const nameSpan = document.createElement('span'); | |
| nameSpan.className = 'font-medium'; | |
| nameSpan.textContent = player.name; | |
| const scoreSpan = document.createElement('span'); | |
| scoreSpan.className = 'font-bold'; | |
| scoreSpan.textContent = player.score; | |
| scoreDiv.appendChild(nameSpan); | |
| scoreDiv.appendChild(scoreSpan); | |
| finalScores.appendChild(scoreDiv); | |
| }); | |
| winnerModal.classList.remove('hidden'); | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Jocaa91/stop" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |