using correct props instead of internal props for TicTacToeGame.tsx and BattleshipGame.tsx

This commit is contained in:
2025-12-04 19:24:14 +05:30
parent fc7cb8efb6
commit 8dc41fca2c
2 changed files with 4 additions and 23 deletions

View File

@@ -1,20 +1,10 @@
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 "../../interfaces/models";
import PlacementGrid from "./placement/PlacementGrid"; import PlacementGrid from "./placement/PlacementGrid";
import ShotGrid from "./battle/ShotGrid"; import ShotGrid from "./battle/ShotGrid";
import { BattleshipGameProps } from "./props";
interface BattleBoardProps {
boards: Record<string, { grid: string[][] }>;
players: PlayerModel[];
myUserId: string | null;
turn: number;
winner: string | null;
gameOver: boolean | null;
metadata: Record<string, any>;
}
const Fleet: Record<string, number> = { const Fleet: Record<string, number> = {
carrier: 5, carrier: 5,
@@ -33,7 +23,7 @@ export default function BattleshipGame({
winner, winner,
gameOver, gameOver,
metadata, metadata,
}: BattleBoardProps) { }: BattleshipGameProps) {
const { sendMatchData, matchId } = useNakama(); const { sendMatchData, matchId } = useNakama();
const myIndex = players.findIndex((p) => p.user_id === myUserId); const myIndex = players.findIndex((p) => p.user_id === myUserId);

View File

@@ -2,17 +2,8 @@ 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 "../../interfaces/models";
interface BoardProps { import { TicTacToeGameProps } from "./props";
boards: Record<string, { grid: string[][] }>;
turn: number;
winner: string | null;
gameOver: boolean | null;
players: PlayerModel[];
myUserId: string | null;
onCellClick: (row: number, col: number) => void;
}
export default function TicTacToeGame({ export default function TicTacToeGame({
boards, boards,
@@ -22,7 +13,7 @@ export default function TicTacToeGame({
players, players,
myUserId, myUserId,
onCellClick, onCellClick,
}: BoardProps) { }: TicTacToeGameProps) {
const myIndex = players.findIndex(p => p.user_id === myUserId); const myIndex = players.findIndex(p => p.user_id === myUserId);
const gameReady = players.length === 2; const gameReady = players.length === 2;
const { const {