pull/83/head
Baptiste MARCEL 1 year ago
parent 423e487e14
commit 512e7aaa06

@ -44,7 +44,8 @@ let lastNodes: NodePerson[] = []
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, addToHistory, showLast, setNetwork}) => { const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, addToHistory, showLast, setNetwork}) => {
let cptTour: number = 0 let cptTour: number = 0
const {user} = useAuth() const {isLoggedIn, user} = useAuth()
console.log('isLoggedIn : ' + isLoggedIn);
const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData } = useGame(); const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData } = useGame();
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
@ -448,15 +449,35 @@ let cptTour: number = 0
}) })
socket.on("end game", (winnerIndex) =>{ socket.on("end game", (winnerIndex) =>{
const currentPlayer = players[actualPlayerIndex];
const winner = players[winnerIndex];
setNodeIdData(-1) setNodeIdData(-1)
setActualPlayerIndexData(-1) setActualPlayerIndexData(-1)
setLastIndex(-1) setLastIndex(-1)
setPlayerTouched(-1) setPlayerTouched(-1)
setWinnerData(players[winnerIndex]) setWinnerData(players[winnerIndex])
console.log('isLoggedIn : ' + isLoggedIn);
if(isLoggedIn){
if(solo){
}
else{
if(winner.id === currentPlayer.id){
console.log("Vous avez gagné !");
}
else{
console.log("Vous avez perdu !");
}
}
}
first = true first = true
cptHistory = 0 cptHistory = 0
askedWrong=false askedWrong=false
askedWrongBot=false askedWrongBot=false
socket.off("end game") socket.off("end game")
socket.off("asked all") socket.off("asked all")
socket.off("opacity activated") socket.off("opacity activated")

@ -22,12 +22,8 @@ import { useGame } from '../Contexts/GameContext';
import ScoreBoard from '../Components/ScoreBoard'; import ScoreBoard from '../Components/ScoreBoard';
/* Types */ /* Types */
import { PlayerProps } from '../types/Player';
import Player from '../model/Player';
import Human from '../model/User';
import User from '../model/User'; import User from '../model/User';
function Play() { function Play() {
const theme=useTheme() const theme=useTheme()
const {isLoggedIn, login, user, setUserData } = useAuth(); const {isLoggedIn, login, user, setUserData } = useAuth();
@ -72,6 +68,7 @@ function Play() {
} }
}; };
console.log('isLoggedIn : ', isLoggedIn);
fetchUserInformation(); fetchUserInformation();
}, [isLoggedIn]); }, [isLoggedIn]);

@ -1,6 +1,6 @@
import { io } from "socket.io-client"; import { io } from "socket.io-client";
const socket = io("http://172.20.10.4:3002"); const socket = io("http://localhost:3002");
export {socket} export {socket}

@ -12,7 +12,7 @@ class AuthService{
static async signUp(data: any) { static async signUp(data: any) {
try { try {
const response = await fetch('http://172.20.10.4:3003/auth/signup', { const response = await fetch('http://localhost:3003/auth/signup', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -36,7 +36,7 @@ class AuthService{
static async signIn(data: any) { static async signIn(data: any) {
try { try {
const response = await fetch('http://172.20.10.4:3003/auth/signin', { const response = await fetch('http://localhost:3003/auth/signin', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -61,7 +61,7 @@ class AuthService{
static async logout() { static async logout() {
try { try {
const response = await fetch('http://172.20.10.4:3003/auth/logout', { const response = await fetch('http://localhost:3003/auth/logout', {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

@ -1,7 +1,7 @@
class SessionService { class SessionService {
static async getSession() { static async getSession() {
try { try {
const response = await fetch('http://172.20.10.4:3003/session', { const response = await fetch('http://localhost:3003/session', {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save