import React, { useState } from "react" import { getVerticalOffset } from "../../utils/randomUtils" import Dice from "../../utils/dice/Dice" const GameScreen = () => { const boardRows = 5 const boardCols = 20 const totalCells = boardRows * boardCols const cellSize = 40 const cellMargin = 2.5 const rowSpacing = 70 // Extra spacing between rows const topOffset = rowSpacing * 0.5 // Increase topOffset for more spacing const bottomOffset = rowSpacing * 0.5 // Increase bottomOffset for more spacing const boardWidthPx = boardCols * (cellSize + cellMargin * 2) const boardHeightPx = boardRows * (cellSize + cellMargin * 2 + rowSpacing) + topOffset + bottomOffset - rowSpacing // Generate a snake-like path with vertical spacing and vertical offsets const generateWindingPath = () => { const path = [] let currentNum = 1 for (let row = 0; row < boardRows && currentNum <= totalCells; row++) { // Calculate the y position with extra row spacing const baseYPosition = topOffset + row * (cellSize + cellMargin * 2 + rowSpacing) // If row number is even, go right; if odd, go left if (row % 2 === 0) { // Left to right for (let col = 0; col < boardCols && currentNum <= totalCells; col++) { path.push({ number: currentNum++, x: col * (cellSize + cellMargin * 2), y: baseYPosition + getVerticalOffset(currentNum - 1), type: getFieldType(currentNum - 1), }) } } else { // Right to left for (let col = boardCols - 1; col >= 0 && currentNum <= totalCells; col--) { path.push({ number: currentNum++, x: col * (cellSize + cellMargin * 2), y: baseYPosition + getVerticalOffset(currentNum - 1), type: getFieldType(currentNum - 1), }) } } } return path } const getFieldType = (count) => { if (count % 17 === 0) return "clover" if (count % 13 === 0) return "bad" if ((count + 5) % 13 === 0) return "good" return "regular" } const [path, setPath] = useState(generateWindingPath()) const [players, setPlayers] = useState([ { id: 1, name: "Béla", position: 34, score: 25, color: "bg-blue-600", emoji: "🐍" }, { id: 2, name: "Juci", position: 50, score: 30, color: "bg-green-600", emoji: "🐢" }, { id: 3, name: "Kati", position: 70, score: 15, color: "bg-purple-600", emoji: "🐇" }, { id: 3, name: "Fürtös", position: 68, score: 14, color: "bg-yellow-600", emoji: "😂" }, ]) // New: selected dice value from dropdown (null = none) const [selectedDice, setSelectedDice] = useState(null) // Sort players by position in descending order const sortedPlayers = [...players].sort((a, b) => b.position - a.position) // Handle dice roll completion const handleDiceRoll = (value) => { console.log("Rolled:", value) // reset dropdown selection after roll setSelectedDice(null) // You can add logic here to move the current player based on the dice value } console.log("Generated path length:", path.length) const getFieldStyle = (type) => { switch (type) { case "clover": return "bg-teal-700 border-teal-500 shadow-teal-800" case "bad": return "bg-red-800 border-red-600 shadow-red-900" case "good": return "bg-blue-800 border-blue-600 shadow-blue-900" default: return "bg-gray-800 border-gray-600 shadow-gray-900" } } const getPlayerPosition = (playerPosition) => { const field = path.find((p) => p.number === playerPosition) return field ? { top: `${field.y}px`, left: `${field.x}px` } : { top: 0, left: 0 } } // Function to get medal style based on rank const getMedalStyle = (rank) => { switch (rank) { case 1: return "bg-yellow-400 text-yellow-900 border-yellow-500 shadow-yellow-600" case 2: return "bg-gray-400 text-gray-900 border-gray-500 shadow-gray-600" case 3: return "bg-orange-500 text-orange-900 border-orange-600 shadow-orange-700" default: return "bg-gray-700 text-gray-300 border-gray-600 shadow-gray-800" } } return (
{/* Game Board */}
{/* Háttér */}
{[...Array(35)].map((_, i) => (
))}
{/* Mezők */} {path.map((field) => (
{field.number}
))} {/* Player tokens */} {players.map((player) => (
{player.emoji}
))}
{/* Game information */} {/*

Sima Lóhere Rossz

*/}
{/* Right sidebar */}

Játékosok

{sortedPlayers.map((player, index) => (
{player.emoji}
{player.name} {index + 1 === 1 ? "🥇 1st" : index + 1 === 2 ? "🥈 2nd" : index + 1 === 3 ? "🥉 3rd" : `${index + 1}th`}
Pozíció: {player.position} • Pontszám: {player.score}
))}
{/* Dice Container */}

Dobókocka

Kattints a kockára dobáshoz vagy válassz egy számot az alábbiból!

{/* Dropdown to select number 1-6 (triggers animated roll to that number) */}
) } export default GameScreen