BATTLESHIP
Two-player naval combat — open on two devices!
{/* Two Player Join Sections */}
{/* Player 1 Section */}
Player 1
{player1Name
? (
{player1Name}
{player1Name}
{isGameStarted ? "In Game" : "Ready"}
{isGameStarted
? (
Rejoin Game
)
: <>>}
)
: (
<>
Join as Player 1
>
)}
{/* Player 2 Section */}
Player 2
{player2Name
? (
{player2Name}
{player2Name}
{isGameStarted ? "In Game" : "Ready"}
{isGameStarted
? (
Rejoin Game
)
: <>>}
)
: (
<>
Join as Player 2
>
)}
{/* Status message */}
{isGameStarted
? "Game in progress! Click 'Rejoin Game' to continue playing."
: player1Name && player2Name
? "Both players ready - game starting!"
: player1Name || player2Name
? "Waiting for the other player to join..."
: "Each player should join from their own device"}
{/* Reset Button */}
Reset Game
),
gameName,
player1: player1Data,
player2: player2Data,
shots: computed(() => shots.get()),
gameState: gameStateData,
// Streams for testing and programmatic control
joinPlayer1,
joinPlayer2,
reset,
};
},
);
// Navigation function setup
createGameAndNavigate = (
gameName: string,
player1: Writable