From 93f207cf12987b255be2f19310ae77acd9cc5355 Mon Sep 17 00:00:00 2001 From: pb-coding <71174645+pb-coding@users.noreply.github.com> Date: Sat, 23 Sep 2023 20:17:35 +0200 Subject: [PATCH] see card cache of other players --- src/components/CardCache.tsx | 17 +++++------------ src/components/PlayerCards.tsx | 8 ++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/components/CardCache.tsx b/src/components/CardCache.tsx index 59f9d3d..be7fca5 100644 --- a/src/components/CardCache.tsx +++ b/src/components/CardCache.tsx @@ -1,15 +1,15 @@ import { FC, useEffect, useState } from "react"; import { Vector3, Object3D } from "three"; -import { socket } from "../socket"; import { createCard } from "../objects/cards"; import { Player } from "../types/gameTypes"; type CardCacheProps = { - playersData: Player[]; + playerData: Player; + position: Vector3; }; -const CardCache: FC = ({ playersData }) => { +const CardCache: FC = ({ playerData, position }) => { const [cardCacheCard, setCardCacheCard] = useState(null); const updateCardCache = (playerData: Player) => { @@ -18,21 +18,14 @@ const CardCache: FC = ({ playersData }) => { return; } const showFaceUp = true; - const card = createCard( - playerData.cardCache, - new Vector3(9, 20, 4), - showFaceUp - ); + const card = createCard(playerData.cardCache, position, showFaceUp); setCardCacheCard(card); }; useEffect(() => { - const playerData = playersData.find( - (player) => player.socketId === socket.id - ); if (!playerData) return; updateCardCache(playerData); - }, [playersData]); + }, [playerData]); if (!cardCacheCard) return null; diff --git a/src/components/PlayerCards.tsx b/src/components/PlayerCards.tsx index 39b9692..11a8de7 100644 --- a/src/components/PlayerCards.tsx +++ b/src/components/PlayerCards.tsx @@ -5,6 +5,7 @@ import { Vector3 } from "three"; import { createPlayerCards } from "../objects/cards"; import PlayerCard from "./PlayerCard"; import { PlayerWithVisualCards, Player } from "../types/gameTypes"; +import CardCache from "./CardCache"; type PlayerCardsProps = { playersData: Player[]; @@ -64,6 +65,11 @@ const PlayerCards: FC = ({ playersData }) => { isCurrentPlayer={playerIndex === 0} /> ))} + ))} @@ -71,3 +77,5 @@ const PlayerCards: FC = ({ playersData }) => { }; export default PlayerCards; +// ich (0) --> 4 +// andere (1) --> -8