renamed BattleShipGame.tsx to BattleshipGame.tsx to match props name. using props interface for both instead of using commonProps

This commit is contained in:
2025-12-04 19:22:07 +05:30
parent 06bdc92190
commit fc7cb8efb6
3 changed files with 15 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ import { useNakama } from "./providers/NakamaProvider";
import Player from "./Player"; import Player from "./Player";
import TicTacToeGame from "./games/tictactoe/TicTacToeGame"; import TicTacToeGame from "./games/tictactoe/TicTacToeGame";
import { TicTacToeGameProps } from "./games/tictactoe/props"; import { TicTacToeGameProps } from "./games/tictactoe/props";
import BattleShipGame from "./games/battleship/BattleShipGame"; import BattleshipGame from "./games/battleship/BattleshipGame"
import { BattleshipGameProps } from "./games/battleship/props"; import { BattleshipGameProps } from "./games/battleship/props";
import { GameState } from "./interfaces/states"; import { GameState } from "./interfaces/states";
@@ -33,6 +33,14 @@ export default function App() {
players: game.players, players: game.players,
myUserId: session?.user_id ?? null, myUserId: session?.user_id ?? null,
}; };
const ticTacToeProps: TicTacToeGameProps = {
...commonProps,
onCellClick: handleCellClick,
};
const battleshipProps: BattleshipGameProps = {
...commonProps,
metadata: game.metadata,
};
// --------------------------------------------------- // ---------------------------------------------------
// RENDER GAME BOARD // RENDER GAME BOARD
@@ -44,16 +52,14 @@ export default function App() {
case "tictactoe": case "tictactoe":
return ( return (
<TicTacToeGame <TicTacToeGame
{...commonProps} {...ticTacToeProps}
onCellClick={handleCellClick}
/> />
); );
case "battleship": case "battleship":
return ( return (
<BattleShipGame <BattleshipGame
{...commonProps} {...battleshipProps}
metadata={game.metadata}
/> />
); );

View File

@@ -1,7 +1,7 @@
import React, { useMemo } from "react"; import React, { useMemo } from "react";
import { motion } from "framer-motion"; import { motion } from "framer-motion";
import { useNakama } from "../../providers/NakamaProvider"; import { useNakama } from "../../providers/NakamaProvider";
import { PlayerModel } from "../../models/player"; import { PlayerModel } from "../../interfaces/models";
import PlacementGrid from "./placement/PlacementGrid"; import PlacementGrid from "./placement/PlacementGrid";
import ShotGrid from "./battle/ShotGrid"; import ShotGrid from "./battle/ShotGrid";
@@ -25,7 +25,7 @@ const Fleet: Record<string, number> = {
}; };
const FLEET_ORDER = ["carrier", "battleship", "cruiser", "submarine", "destroyer"]; const FLEET_ORDER = ["carrier", "battleship", "cruiser", "submarine", "destroyer"];
export default function BattleShipGame({ export default function BattleshipGame({
boards, boards,
players, players,
myUserId, myUserId,

View File

@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import { useNakama } from "../../providers/NakamaProvider"; import { useNakama } from "../../providers/NakamaProvider";
import getHaiku from "../../utils/haikus"; import getHaiku from "../../utils/haikus";
import { PlayerModel } from "../../models/player"; import { PlayerModel } from "../../interfaces/models";
interface BoardProps { interface BoardProps {
boards: Record<string, { grid: string[][] }>; boards: Record<string, { grid: string[][] }>;