From 781904f63b49e691d5aee73dc6d9893ef18b4adf Mon Sep 17 00:00:00 2001 From: Pierre Ferreira Date: Wed, 29 Nov 2023 14:01:23 +0100 Subject: [PATCH] ajout de la page lobby de lobby pour rejoindre un jeu :rocket: --- cryptide_project/src/App.tsx | 5 +- .../src/Components/LobbyContainer.tsx | 30 ++++++++++ cryptide_project/src/Pages/Lobbies.css | 35 +++++++++++ cryptide_project/src/Pages/Lobbies.tsx | 59 +++++++++++++++++++ cryptide_project/src/Pages/Play.tsx | 2 +- 5 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 cryptide_project/src/Components/LobbyContainer.tsx create mode 100644 cryptide_project/src/Pages/Lobbies.css create mode 100644 cryptide_project/src/Pages/Lobbies.tsx diff --git a/cryptide_project/src/App.tsx b/cryptide_project/src/App.tsx index f6a601f..408b5eb 100644 --- a/cryptide_project/src/App.tsx +++ b/cryptide_project/src/App.tsx @@ -13,9 +13,10 @@ import Play from './Pages/Play'; import Profile from './Pages/Profile'; import Lobby from './Pages/Lobby'; import InGame from './Pages/InGame'; - import EndGame from './Pages/EndGame'; import InfoPage from './Pages/InfoPage'; +import SoloGame from './Pages/SoloGame'; +import Lobbies from './Pages/Lobbies'; /* Component */ import AppNavbar from './Components/NavBar'; @@ -38,7 +39,6 @@ import 'bootstrap/dist/css/bootstrap.min.css'; /* Internationnalisation */ import messagesFr from './Translations/fr.json'; import messagesEn from './Translations/en.json'; -import SoloGame from './Pages/SoloGame'; const messages = { fr: messagesFr, @@ -86,6 +86,7 @@ function App() { }/> } /> } /> + }/> {/* }/> */} diff --git a/cryptide_project/src/Components/LobbyContainer.tsx b/cryptide_project/src/Components/LobbyContainer.tsx new file mode 100644 index 0000000..e38d1d5 --- /dev/null +++ b/cryptide_project/src/Components/LobbyContainer.tsx @@ -0,0 +1,30 @@ +import React, { useEffect, useState } from 'react'; +import { useTheme } from '../Style/ThemeContext'; +import Player from '../model/Player'; + + +interface LobbyContainerProps { + roomNum : string + HeadPlayer : Player + nbPlayer : number + //? mettre un "nbplayermax" si le nombre de joueur max peut etre fixé ? +} + +const LobbyContainer: React.FC = ({roomNum, HeadPlayer, nbPlayer}) => { + const theme=useTheme(); + + return( +
+
+
Room : {roomNum}
+
+
+

{HeadPlayer.pseudo}

+
+

{nbPlayer}/6

+
+
+ ); +} + +export default LobbyContainer; diff --git a/cryptide_project/src/Pages/Lobbies.css b/cryptide_project/src/Pages/Lobbies.css new file mode 100644 index 0000000..b32dfe0 --- /dev/null +++ b/cryptide_project/src/Pages/Lobbies.css @@ -0,0 +1,35 @@ +.lobbyMainContainer{ + display: flex; + flex-direction: column; + + background-color: white; + + border: solid 1px whitesmoke; + border-radius: 15px; + box-shadow: 5px 5px 5px rgb(246, 246, 246); + + width: 300px; + /* max-width: 300px; */ + /* max-width: 20%; */ + max-height: 200px; + + padding: 20px; + margin: 20px; +} + +.lobbyList{ + display: flex; + /* justify-content: space-around; */ + /* columns: 4; */ + flex-wrap: wrap; + + justify-content: center; +} + +.searchLobby{ + border: solid 1px whitesmoke; + border-radius: 15px; + padding: 15px; + + width: 50%; +} \ No newline at end of file diff --git a/cryptide_project/src/Pages/Lobbies.tsx b/cryptide_project/src/Pages/Lobbies.tsx new file mode 100644 index 0000000..a73ad56 --- /dev/null +++ b/cryptide_project/src/Pages/Lobbies.tsx @@ -0,0 +1,59 @@ +import React, { useEffect, useState } from 'react'; + +/* Style */ +import './Lobbies.css'; +import "../Style/Global.css" +import { useTheme } from '../Style/ThemeContext'; +import LobbyContainer from '../Components/LobbyContainer'; +import Player from '../model/Player'; +import User from '../model/User'; + + +function Lobbies() { + const theme=useTheme(); + + + const lobbyData = [ + { roomNum: '63194', headPlayer: new User('1', 'Emma', '', null, null), nbPlayer: 6 }, + { roomNum: '81194', headPlayer: new User('2', 'Ray', '', null, null), nbPlayer: 1 }, + { roomNum: '22194', headPlayer: new User('3', 'Norman', '', null, null), nbPlayer: 4 }, + { roomNum: 'null', headPlayer: new User('null', 'tnull', '', null, null), nbPlayer: 1 }, + { roomNum: '111111', headPlayer: new User('11', '1111111', '', null, null), nbPlayer: 1 }, + { roomNum: '741852963', headPlayer: new User('3', 'Guest_741852963', '', null, null), nbPlayer: 6 }, + ]; + + + const [searchTerm, setSearchTerm] = useState(''); + + const filteredLobbies = lobbyData.filter((lobby) => + lobby.roomNum.toLowerCase().includes(searchTerm.toLowerCase()) || + lobby.headPlayer.pseudo.toLowerCase().includes(searchTerm.toLowerCase()) +); + + + + return( +
+

Bienvenue dans le lobby des lobbies

+ setSearchTerm(e.target.value)} + /> +
+ {filteredLobbies.map((lobby, index) => ( + + ))} +
+
+ ); +} + +export default Lobbies; diff --git a/cryptide_project/src/Pages/Play.tsx b/cryptide_project/src/Pages/Play.tsx index 4b2cc93..f9442f7 100644 --- a/cryptide_project/src/Pages/Play.tsx +++ b/cryptide_project/src/Pages/Play.tsx @@ -253,7 +253,7 @@ function Play() { - +