From 7451857b0b2110f52700ae1a7e2e3dd4b2013d46 Mon Sep 17 00:00:00 2001 From: Pierre Ferreira Date: Wed, 29 Nov 2023 09:47:27 +0100 Subject: [PATCH] ajout du lien d'invitation et selecteur de nombre de noeud dans lobby --- cryptide_project/src/Pages/Lobby.css | 10 +++ cryptide_project/src/Pages/Lobby.tsx | 99 +++++++++++++++++++++++++--- 2 files changed, 101 insertions(+), 8 deletions(-) diff --git a/cryptide_project/src/Pages/Lobby.css b/cryptide_project/src/Pages/Lobby.css index 60dfcf0..0428a83 100644 --- a/cryptide_project/src/Pages/Lobby.css +++ b/cryptide_project/src/Pages/Lobby.css @@ -59,4 +59,14 @@ .centerButton { display: flex; justify-content: center; +} + +.lobbyR{ + display: flex; + flex-direction: column; + align-items: center; +} + +.lobbyR *{ + margin: 20px 10px; } \ No newline at end of file diff --git a/cryptide_project/src/Pages/Lobby.tsx b/cryptide_project/src/Pages/Lobby.tsx index 6fcd06f..1bef7b7 100644 --- a/cryptide_project/src/Pages/Lobby.tsx +++ b/cryptide_project/src/Pages/Lobby.tsx @@ -42,6 +42,10 @@ import { socket } from "../SocketConfig"; import { random } from 'lodash'; import SessionService from '../services/SessionService'; +import { useRef } from 'react'; +import Button from 'react-bootstrap/Button'; +import Overlay from 'react-bootstrap/Overlay'; + let gameStarted = false @@ -62,7 +66,14 @@ function Lobby() { socket.emit("lobby joined", room, new EasyBot("botId" + Math.floor(Math.random() * 1000), "Bot" + Math.floor(Math.random() * 100), "").toJson()) } - + //* nb Node + const [enteredNumber, setEnteredNumber] = useState(20); + + //@ts-ignore + const handleNumberChange = (event) => { + const newNumber = Math.max(20, Math.min(60, parseInt(event.target.value, 10))); + setEnteredNumber(newNumber); + }; useEffect(() => { if (first){ @@ -146,7 +157,7 @@ function Lobby() { function StartGame(){ - const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(players.length, 30) + const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(players.length, enteredNumber) setPersonData(choosenPerson) setPersonNetworkData(networkPerson) setIndicesData(choosenIndices) @@ -159,6 +170,21 @@ function Lobby() { socket.emit('network created', JSON.stringify(networkPerson, null, 2), JSON.stringify(choosenPerson), JSON.stringify(choosenIndices), room, start); } + const copyGameLink = () => { + setShow(!show) + + const gameLink = "http://localhost:3000/lobby?room="+ room; + navigator.clipboard.writeText(gameLink) + .then(() => { + console.log('Lien copié avec succès !'); + }) + .catch((err) => { + console.error('Erreur lors de la copie du lien :', err); + }); + }; + + const [show, setShow] = useState(false); + const target = useRef(null); return (
@@ -191,7 +217,7 @@ function Lobby() {
-
+ {/*
param

Paramètre de la partie

@@ -200,21 +226,78 @@ function Lobby() {
  • paramètre super important pour la partie

  • paramètre super important pour la partie

  • paramètre super important pour la partie

  • -
  • Niveau des bots : Facile

  • {/* mettre un dropdown ou un swiper */} -
  • Thèmes : basique

  • {/* mettre un dropdown*/} +
  • Niveau des bots : Facile

  • +
  • Thèmes : basique

  • */} { //? mettre un timer pour chaques personne ? //? indice avancé ? ==> négation, voisin du 2e degré etc. } - + {/* */} {/*
    */} +
    +

    Bienvenue dans votre lobby !

    +

    Attendez que tous vos amis rejoignent avant de lancer la partie.

    + {/* Bouton pour copier le lien */} + + + {({ + placement: _placement, + arrowProps: _arrowProps, + show: _show, + popper: _popper, + hasDoneInitialMeasure: _hasDoneInitialMeasure, + ...props + }) => ( +
    + Lien copié +
    + )} +
    + +
    + + +

    La valeur saisie : {enteredNumber}

    +
    + -
    + + +
    + {/*
    -
    +
    */}
    );