From 798bfc971b0b9f0c06bd26e7f42838b5b146bde2 Mon Sep 17 00:00:00 2001 From: carlospelazas Date: Wed, 3 Apr 2024 10:01:24 +0200 Subject: [PATCH] fix styles single player --- webapp/src/components/game/LobbyGame.scss | 29 +++++++++----- .../singleplayer/LobbyGameSinglePlayer.tsx | 38 ++++++++++++++----- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/webapp/src/components/game/LobbyGame.scss b/webapp/src/components/game/LobbyGame.scss index 2e70893..581e59c 100644 --- a/webapp/src/components/game/LobbyGame.scss +++ b/webapp/src/components/game/LobbyGame.scss @@ -1,28 +1,37 @@ table { width: 100%; border-collapse: collapse; + border:none; th, td { padding: 8px; text-align: center; + border:none; } - + /* tr:nth-child(even) { background-color: #f2f2f2; - } - + }*/ + /* &:hover { tr { background-color: #ddd; } - } + }*/ - img { - max-width: 100px; // Cambia el tamaño máximo de la imagen según sea necesario - height: auto; - display: block; - margin: 0 auto; // Centra la imagen horizontalmente - } + + } + + .player-item { + display: flex; + flex-direction: row; + justify-content: stretch; + } + + img { + max-width: 100px; // Cambia el tamaño máximo de la imagen según sea necesario + height: auto; + display: block; } .lobby-title { diff --git a/webapp/src/components/game/singleplayer/LobbyGameSinglePlayer.tsx b/webapp/src/components/game/singleplayer/LobbyGameSinglePlayer.tsx index 1ff8f01..2a92715 100644 --- a/webapp/src/components/game/singleplayer/LobbyGameSinglePlayer.tsx +++ b/webapp/src/components/game/singleplayer/LobbyGameSinglePlayer.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react' +import { FC, useRef } from 'react' import { Player } from './GameSinglePlayer'; import '../LobbyGame.scss'; @@ -11,10 +11,21 @@ interface LobbyGameProps { const LobbyGame: FC = ({setPlayers, players, setCurrentStage, isFetched}) => { + function* botCounter(){ + let count=0; + while(true){ + count++; + yield count; + } + + }; + const botGen = useRef(botCounter()); // Assign the function to the variable + const addBotPlayer = () => { if (players.length < 4) { - setPlayers([...players, { username: `Bot ${players.length + 1}`, points: 0, isBot: true }]); + setPlayers([...players, { username: `Bot ${botGen.current.next().value}`, + points: 0, isBot: true }]); } }; @@ -26,15 +37,22 @@ const LobbyGame: FC = ({setPlayers, players, setCurrentStage, is return (
-

Lobby

- {players.map((player, index) => ( -
-

Name: {player.username}

-

Total points: {player.points}

- {player.isBot && } - {!player.isBot && } +

Lobby - Single player

+
+ {players.map((player, index) => ( +
+ {player.username} +

{player.username}

+

Total points: {player.points}

+ {!player.isBot && ( + + )} + {player.isBot && ( + + )} +
+ ))}
- ))}