refactored PlayerModel to Player
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
import { useNakama } from "./providers/NakamaProvider";
|
import { useNakama } from "./providers/NakamaProvider";
|
||||||
import Player from "./Player";
|
import Player from "./Player";
|
||||||
import { PlayerModel } from "./interfaces/models";
|
import { Player } from "./interfaces/models";
|
||||||
|
|
||||||
import TicTacToeBoard from "./games/tictactoe/TicTacToeBoard";
|
import TicTacToeBoard from "./games/tictactoe/TicTacToeBoard";
|
||||||
import BattleShipBoard from "./games/battleship/BattleShipBoard";
|
import BattleShipBoard from "./games/battleship/BattleShipBoard";
|
||||||
@@ -13,7 +13,7 @@ export default function App() {
|
|||||||
const [turn, setTurn] = useState<number>(0);
|
const [turn, setTurn] = useState<number>(0);
|
||||||
const [winner, setWinner] = useState<string | null>(null);
|
const [winner, setWinner] = useState<string | null>(null);
|
||||||
const [gameOver, setGameOver] = useState<boolean | null>(null);
|
const [gameOver, setGameOver] = useState<boolean | null>(null);
|
||||||
const [players, setPlayers] = useState<PlayerModel[]>([]);
|
const [players, setPlayers] = useState<Player[]>([]);
|
||||||
const [metadata, setMetadata] = useState<Record<string, any>>({});
|
const [metadata, setMetadata] = useState<Record<string, any>>({});
|
||||||
|
|
||||||
const { sendMatchData, onMatchData, matchId, session } = useNakama();
|
const { sendMatchData, onMatchData, matchId, session } = useNakama();
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
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 { Player } from "../../interfaces/models";
|
||||||
|
|
||||||
import PlacementGrid from "./placement/PlacementGrid";
|
import PlacementGrid from "./placement/PlacementGrid";
|
||||||
import ShotGrid from "./battle/ShotGrid";
|
import ShotGrid from "./battle/ShotGrid";
|
||||||
|
|
||||||
interface BattleBoardProps {
|
interface BattleBoardProps {
|
||||||
boards: Record<string, { grid: string[][] }>;
|
boards: Record<string, { grid: string[][] }>;
|
||||||
players: PlayerModel[];
|
players: Player[];
|
||||||
myUserId: string | null;
|
myUserId: string | null;
|
||||||
turn: number;
|
turn: number;
|
||||||
winner: string | null;
|
winner: string | null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Board,
|
Board,
|
||||||
PlayerModel,
|
Player,
|
||||||
} from '../../interfaces/models'
|
} from '../../interfaces/models'
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ export interface BattleShipBoardProps {
|
|||||||
turn: number;
|
turn: number;
|
||||||
winner: string | null;
|
winner: string | null;
|
||||||
gameOver: boolean | null;
|
gameOver: boolean | null;
|
||||||
players: PlayerModel[];
|
players: Player[];
|
||||||
myUserId: string | null;
|
myUserId: string | null;
|
||||||
metadata: Record<string, any>;
|
metadata: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ 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 { Player } from "../../interfaces/models";
|
||||||
|
|
||||||
interface BoardProps {
|
interface BoardProps {
|
||||||
boards: Record<string, { grid: string[][] }>;
|
boards: Record<string, { grid: string[][] }>;
|
||||||
turn: number;
|
turn: number;
|
||||||
winner: string | null;
|
winner: string | null;
|
||||||
gameOver: boolean | null;
|
gameOver: boolean | null;
|
||||||
players: PlayerModel[];
|
players: Player[];
|
||||||
myUserId: string | null;
|
myUserId: string | null;
|
||||||
onCellClick: (row: number, col: number) => void;
|
onCellClick: (row: number, col: number) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Board,
|
Board,
|
||||||
PlayerModel,
|
Player,
|
||||||
} from '../../interfaces/models'
|
} from '../../interfaces/models'
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ export interface TicTacToeBoardProps {
|
|||||||
turn: number;
|
turn: number;
|
||||||
winner: string | null;
|
winner: string | null;
|
||||||
gameOver: boolean | null;
|
gameOver: boolean | null;
|
||||||
players: PlayerModel[];
|
players: Player[];
|
||||||
myUserId: string | null;
|
myUserId: string | null;
|
||||||
onCellClick: (row: number, col: number) => void;
|
onCellClick: (row: number, col: number) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface PlayerModel {
|
export interface Player {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
username: string;
|
username: string;
|
||||||
index: number;
|
index: number;
|
||||||
@@ -20,7 +20,7 @@ export interface GameState {
|
|||||||
turn: number;
|
turn: number;
|
||||||
winner: string | null;
|
winner: string | null;
|
||||||
gameOver: boolean;
|
gameOver: boolean;
|
||||||
players: PlayerModel[];
|
players: Player[];
|
||||||
metadata: Record<string, any>;
|
metadata: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user