Merge branch 'master' into CI/CD

CI/CD
Thomas Chazot 1 year ago
commit a41a0821f5

2
.gitignore vendored

@ -51,4 +51,4 @@ package-lock.json
socialgraph.db
# build
cryptide_project/build/
cryptide_project/build/*

@ -1,19 +0,0 @@
{
"files": {
"main.css": "/static/css/main.6888e917.css",
"main.js": "/static/js/main.b6842da5.js",
"static/js/787.a1c84483.chunk.js": "/static/js/787.a1c84483.chunk.js",
"static/media/Person.png": "/static/media/Person.f7ba6be9e4afca5ca897.png",
"static/media/bot.png": "/static/media/bot.057c187a23ead0769e7f.png",
"static/media/eye.png": "/static/media/eye.cd074d043a80f09623ac.png",
"static/media/reset.png": "/static/media/reset.82632189f4cbd1644b7a.png",
"index.html": "/index.html",
"main.6888e917.css.map": "/static/css/main.6888e917.css.map",
"main.b6842da5.js.map": "/static/js/main.b6842da5.js.map",
"787.a1c84483.chunk.js.map": "/static/js/787.a1c84483.chunk.js.map"
},
"entrypoints": [
"static/css/main.6888e917.css",
"static/js/main.b6842da5.js"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

@ -1 +0,0 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.b6842da5.js"></script><link href="/static/css/main.6888e917.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

@ -1,25 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,2 +0,0 @@
"use strict";(self.webpackChunkcryptide=self.webpackChunkcryptide||[]).push([[787],{787:(e,t,n)=>{n.r(t),n.d(t,{getCLS:()=>y,getFCP:()=>g,getFID:()=>C,getLCP:()=>P,getTTFB:()=>D});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},d=c("first-input",p);n=m(e,v,t),d&&f((function(){d.takeRecords().map(p),d.disconnect()}),!0),d&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=p,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
//# sourceMappingURL=787.a1c84483.chunk.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,123 +0,0 @@
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/*!
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/main/LICENSE
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/*! Hammer.JS - v2.0.17-rc - 2019-12-16
* http://naver.github.io/egjs
*
* Forked By Naver egjs
* Copyright (c) hammerjs
* Licensed under the MIT license */
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @remix-run/router v1.11.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
/**
* React Router DOM v6.18.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
/**
* React Router v6.18.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
//! Il faudra possiblement faire une gestion des mode de jeu, pour modifier les regles en fonction de ce dernier.

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

@ -26,6 +26,7 @@
"jspdf": "^2.5.1",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
"nuka-carousel": "^7.0.0",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-country-flag": "^3.1.0",
@ -14203,6 +14204,18 @@
"url": "https://github.com/fb55/nth-check?sponsor=1"
}
},
"node_modules/nuka-carousel": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/nuka-carousel/-/nuka-carousel-7.0.0.tgz",
"integrity": "sha512-KE0WV1MuE4Gq6ynL8P3qJH2rGq/DkJ0ej+ezo0IuZp4oklV8WNqu6P6O1utJqihHLGoEuFppq5wlHSHfhdCHXA==",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
}
},
"node_modules/nwsapi": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz",

@ -21,6 +21,7 @@
"jspdf": "^2.5.1",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
"nuka-carousel": "^7.0.0",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-country-flag": "^3.1.0",

@ -0,0 +1,209 @@
const path = require('path');
const DatabaseService = require(path.resolve(__dirname, '../services/DatabaseService'));
const ENIGME_FACILE = "enigme_facile";
const ENIGME_MOYEN = "enigme_moyenne";
const ENIGME_DIFFICILE = "enigme_difficile";
class SessionController {
// ---------------------------------------------------
// ----------------- GET DAILY STATS -----------------
// ---------------------------------------------------
static async getDailyMastermind(req, res){
const db = new DatabaseService();
try{
await db.connect();
const dailyMastermindStats = await db.getDailyMastermindStats();
res.status(200).json({ tab : dailyMastermindStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyMastermind.' });
}
finally{
await db.disconnect();
}
}
static async getDailyEasyEnigma(req, res){
const db = new DatabaseService();
try{
await db.connect();
const dailyEasyEnigmaStats = await db.getDailyEnigmaStats(ENIGME_FACILE);
res.status(200).json({ tab : dailyEasyEnigmaStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyEasyEnigma.' });
}
finally{
await db.disconnect();
}
}
static async getDailyMediumEnigma(req, res){
const db = new DatabaseService();
try{
await db.connect();
const dailyMediumEnigmaStats = await db.getDailyEnigmaStats(ENIGME_MOYEN);
res.status(200).json({ tab : dailyMediumEnigmaStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyMediumEnigma.' });
}
finally{
await db.disconnect();
}
}
static async getDailyHardEnigma(req, res){
const db = new DatabaseService();
try{
await db.connect();
const dailyHardEnigmaStats = await db.getDailyEnigmaStats(ENIGME_DIFFICILE);
res.status(200).json({ tab : dailyHardEnigmaStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyHardEnigma.' });
}
finally{
await db.disconnect();
}
}
static async getDailyOnline(req, res){
const db = new DatabaseService();
try{
await db.connect();
const dailyOnlineStats = await db.getDailyOnlineStats();
res.status(200).json({ tab : dailyOnlineStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyOnline' });
}
finally{
await db.disconnect();
}
}
// ---------------------------------------------------
// ---------------- GET WEEKLY STATS -----------------
// ---------------------------------------------------
static async getWeeklyMastermind(req, res){
const db = new DatabaseService();
try{
await db.connect();
const weeklyMastermindStats = await db.getWeeklyMastermindStats();
res.status(200).json({ tab : weeklyMastermindStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyMastermind.' });
}
finally{
await db.disconnect();
}
}
static async getWeeklyEasyEnigma(req, res){
const db = new DatabaseService();
try{
await db.connect();
const weeklyEasyEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_FACILE);
res.status(200).json({ tab : weeklyEasyEnigmaStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyEasyEnigma.' });
}
finally{
await db.disconnect();
}
}
static async getWeeklyMediumEnigma(req, res){
const db = new DatabaseService();
try{
await db.connect();
const weeklyMediumEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_MOYEN);
res.status(200).json({ tab : weeklyMediumEnigmaStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyMediumEnigma.' });
}
finally{
await db.disconnect();
}
}
static async getWeeklyHardEnigma(req, res){
const db = new DatabaseService();
try{
await db.connect();
const weeklyHardEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_DIFFICILE);
res.status(200).json({ tab : weeklyHardEnigmaStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyHardEnigma.' });
}
finally{
await db.disconnect();
}
}
static async getWeeklyOnline(req, res){
const db = new DatabaseService();
try{
await db.connect();
const weeklyOnlineStats = await db.getWeeklyOnlineStats();
res.status(200).json({ tab : weeklyOnlineStats });
}
catch(error){
console.error(error);
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyOnline' });
}
finally{
await db.disconnect();
}
}
}
module.exports = SessionController;

@ -88,8 +88,6 @@ class SessionController {
nbWins: nbWinsOL,
ratio: ratioOL};
console.log("[" + hour + ":" + minutes + "] " + req.session.user.pseudo + " have a session.");
res.status(200).json({ user: req.session.user });
}
catch(error){

@ -2,6 +2,7 @@ const express = require('express');
const router = express.Router();
const AuthController = require('../controllers/AuthController');
const SessionController = require('../controllers/SessionController');
const ScoreboardController = require('../controllers/ScoreboardController');
// Routes pour l'authentification
router.post('/auth/signup', AuthController.signUp);
@ -20,4 +21,19 @@ router.post('/session/addHardEnigmaStats', SessionController.addHardEnigmaStats)
router.post('/session/addOnlineStats', SessionController.addOnlineStats);
router.put('/session/updatePseudo', SessionController.UpdatePseudo);
// Routes pour le daily scoreboard
router.get('/scoreboard/getDailyMastermind', ScoreboardController.getDailyMastermind);
router.get('/scoreboard/getDailyEasyEnigma', ScoreboardController.getDailyEasyEnigma);
router.get('/scoreboard/getDailyMediumEnigma', ScoreboardController.getDailyMediumEnigma);
router.get('/scoreboard/getDailyHardEnigma', ScoreboardController.getDailyHardEnigma);
router.get('/scoreboard/getDailyOnline', ScoreboardController.getDailyOnline);
// Routes pour le weekly scoreboard
router.get('/scoreboard/getWeeklyMastermind', ScoreboardController.getWeeklyMastermind);
router.get('/scoreboard/getWeeklyEasyEnigma', ScoreboardController.getWeeklyEasyEnigma);
router.get('/scoreboard/getWeeklyMediumEnigma', ScoreboardController.getWeeklyMediumEnigma);
router.get('/scoreboard/getWeeklyHardEnigma', ScoreboardController.getWeeklyHardEnigma);
router.get('/scoreboard/getWeeklyOnline', ScoreboardController.getWeeklyOnline);
module.exports = router;

@ -14,7 +14,7 @@ const port = 3003;
// Middleware
app.use(cors(
{
origin: ["http://172.20.10.4:3000", "http://172.20.10.4:3000"],
origin: ["http://172.20.10.4:3000", "http://localhost:3000"],
credentials: true
}
)); // Autoriser les requêtes cross-origin

@ -127,6 +127,140 @@ class DatabaseService {
});
}
// ---------------------------------------------------------------
// ------------------- STATS JOURNALIERE -------------------------
// ---------------------------------------------------------------
async getDailyMastermindStats() {
return new Promise((resolve, reject) => {
// Obtenez la date actuelle au format AAAA-MM-JJ
const currentDate = new Date().toISOString().slice(0, 10);
// Récupérer les 5 meilleurs scores de la journée
this.client.all(
'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY score ASC LIMIT 10',
"mastermind",
currentDate,
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}
);
});
}
async getDailyEnigmaStats(enigmaLevel) {
return new Promise((resolve, reject) => {
const currentDate = new Date().toISOString().slice(0, 10);
this.client.all(
'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY time ASC LIMIT 10',
enigmaLevel,
currentDate,
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}
);
});
}
async getDailyOnlineStats() {
return new Promise((resolve, reject) => {
const currentDate = new Date().toISOString().slice(0, 10);
this.client.all(
'SELECT pseudo, COUNT(*) AS wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? AND win = ? GROUP BY users.idUser ORDER BY wins ASC LIMIT 10',
"multijoueur", currentDate, 1,
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}
);
});
}
// ---------------------------------------------------------------
// ------------------- STATS HEBDOMADAIRE ------------------------
// ---------------------------------------------------------------
async getWeeklyMastermindStats() {
return new Promise((resolve, reject) => {
const currentDate = new Date().toISOString().slice(0, 10);
const currentDay = new Date().getDay();
const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
this.client.all(
'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY score ASC LIMIT 10',
"mastermind",
firstDayOfWeek,
currentDate,
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}
);
});
}
async getWeeklyEnigmaStats(enigmaLevel) {
return new Promise((resolve, reject) => {
const currentDate = new Date().toISOString().slice(0, 10);
const currentDay = new Date().getDay();
const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
this.client.all(
'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY time ASC LIMIT 10',
enigmaLevel,
firstDayOfWeek,
currentDate,
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}
);
});
}
async getWeeklyOnlineStats() {
return new Promise((resolve, reject) => {
const currentDate = new Date().toISOString().slice(0, 10);
const currentDay = new Date().getDay();
const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
this.client.all(
'SELECT pseudo, COUNT(*) as wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? AND win = ? ORDER BY wins ASC LIMIT 10',
"multijoueur",
firstDayOfWeek,
currentDate,
1,
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}
);
});
}
// -------------------------------------------------------------
// ------------------- STATS MASTERMIND ------------------------
// -------------------------------------------------------------

@ -9,7 +9,7 @@ const server = http.createServer(app);
const io = socketIO(server, {
cors: {
origin: "*", // Remplacez par l'URL de votre application React
methods: ["GET", "POST"], //test
methods: ["GET", "POST"],
credentials: true
}
});
@ -26,12 +26,18 @@ io.on('connection', (socket) => {
console.log(socket.id);
socket.on('network created', (network, person, indices, room, start) =>{
io.to(room).emit("game created", network, person, indices, start)
map.get(room).started = true
map.get(room).actualPlayer=start
const playerArray = Array.from(map.entries()).map(([key, value]) => ({ key, value }))
const playerJson = JSON.stringify(playerArray);
io.emit("request lobbies", playerJson)
try{
io.to(room).emit("game created", network, person, indices, start)
map.get(room).started = true
map.get(room).actualPlayer=start
const playerArray = Array.from(map.entries()).map(([key, value]) => ({ key, value }))
const playerJson = JSON.stringify(playerArray);
io.emit("request lobbies", playerJson)
}
catch{
console.log("error")
}
});
socket.on("give network", (networkPerson, person, indices, start, room, nodes, playerId) => {
@ -146,17 +152,23 @@ io.on('connection', (socket) => {
})
socket.on("who plays", (room) => {
if (map.get(room) !== undefined){
let player = map.get(room).actualPlayer
if (map.get(room).tab[player].type != "User"){
player = player + 1
if (player == map.get(room).tab.length){
player=0
try{
if (map.get(room) !== undefined){
let player = map.get(room).actualPlayer
if (map.get(room).tab[player].type != "User"){
player = player + 1
if (player == map.get(room).tab.length){
player=0
}
}
// console.log(player)
io.to(room).emit("who plays", player, map.get(room).lastWorks)
}
// console.log(player)
io.to(room).emit("who plays", player, map.get(room).lastWorks)
}
catch{
}
})
socket.on("disconnect", () =>{
@ -217,9 +229,14 @@ io.on('connection', (socket) => {
})
socket.on("node checked", (id, works, color, room, playerIndex) =>{
map.get(room).actualPlayer=playerIndex
map.get(room).lastWorks=works
io.to(room).emit("node checked", id, works, color, playerIndex, socket.id)
try{
map.get(room).actualPlayer=playerIndex
map.get(room).lastWorks=works
io.to(room).emit("node checked", id, works, color, playerIndex, socket.id)
}
catch{
console.log("error")
}
})
socket.on("put correct background", (id) =>{

@ -1,6 +1,7 @@
const ADRESSE_WEBSERVER = "https://codefirst.iut.uca.fr/containers/Crypteam-server:8080"
const ADRESSE_DBSERVER = "http://172.20.10.4:3003"
// const ADRESSE_DBSERVER = "http://172.20.10.4:3003"
const ADRESSE_DBSERVER = "http://localhost:3003"
const tmp = ADRESSE_DBSERVER
const tmp2 = ADRESSE_WEBSERVER

@ -43,6 +43,7 @@ import ErrorBoundary from './Error/ErrorBoundary';
import ErrorPage from './Error/ErrorPage';
import DeducCheck from './Pages/DeducCheck';
import {basePath} from "./AdressSetup"
import Tutorial from './Pages/Tutorial';
@ -68,6 +69,7 @@ function App() {
//const location = useLocation();
const hasNavbarVisible = [basePath + "/", basePath + "/login", basePath + "/signup", basePath + "/lobby", basePath + "/endgame", basePath + "/deduc"]//.includes(window.location.pathname);
document.title = "Social Graph";
return (
<ErrorBoundary fallback={(error, errorInfo) => <ErrorPage />}>
@ -88,6 +90,7 @@ function App() {
<Route path={`${basePath}/endgame`} element={<EndGame/>} />
<Route path={`${basePath}/game`} element={<InGame locale={locale} changeLocale={changeLocale}/>}/>
<Route path={`${basePath}/info`} element={<InfoPage locale={locale} changeLocale={changeLocale}/>} />
<Route path={`${basePath}/tutorial`} element={<Tutorial locale={locale} changeLocale={changeLocale}/>} />
<Route path={`${basePath}/deduc`} element={<DeducCheck/>} />
<Route path={`${basePath}/TheRealDeduc`} element={<DeducGrid/>} />
<Route path={`${basePath}/profile`} element={<Profile/>} />

@ -19,6 +19,7 @@ const ChoiceBar = () => {
async function askEveryone(){
if (nodeId !== null){
//@ts-ignore
const person = personNetwork?.getPersons().find((p) => p.getId() == nodeId)
if (person != undefined){
const indiceTester = IndiceTesterFactory.Create(indices[actualPlayerIndex])

@ -41,6 +41,17 @@ interface MyGraphComponentProps {
setPlayerIndex: (playerIndex: number) => void
importToPdf: boolean
setImportToPdf: (imp: boolean) => void
importToJSON: boolean
setImportToJSON: (imp: boolean) => void
setPutCorrectBackground : (func: () => void) => void
setPutGreyBackground : (func: () => void) => void
setPutImposssibleGrey : (func: () => void) => void
putGreyBackground : () => void
putCorrectBackground : () => void
putImposssibleGrey : () => void
handleTurn :() => void
}
let lastAskingPlayer = 0
@ -67,17 +78,18 @@ let firstPlayer = 0
let cptBug = 0
let cptUseEffect = 0
let testPlayers: Player[] = []
let testTemps = 0
let testFirst = false
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf}) => {
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey, handleTurn}) => {
let cptTour: number = 0
//* Gestion du temps :
let initMtn = 0
const {isLoggedIn, user, manager} = useAuth();
const { indices, indice, person, personNetwork, setNodeIdData, players, setPlayersData, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData, dailyEnigme, setNbCoupData, settempsData, setNetworkDataData, setSeedData, nodesC} = useGame();
const { indices, indice, person, personNetwork, setNodeIdData, players, setPlayersData, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData, dailyEnigme, setNbCoupData, settempsData, setNetworkDataData, setSeedData, nodesC, temps} = useGame();
const params = new URLSearchParams(window.location.search);
const navigate = useNavigate();
@ -86,10 +98,16 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
const [elapsedTime, setElapsedTime] = useState(0);
useEffect(() => {
if (testFirst){
testTemps = 0
endgame = false
testFirst = false
}
// Démarrez le timer au montage du composant
const intervalId = setInterval(() => {
setElapsedTime((prevElapsedTime) => prevElapsedTime + 0.5);
settempsData(elapsedTime)
testTemps += 0.5
cptBug ++
if (cptBug > 10){
@ -101,12 +119,13 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
// Vérifiez si la durée est écoulée, puis arrêtez le timer
if (endgame) {
clearInterval(intervalId);
testTemps = 0
}
}, 500);
// Nettoyez l'intervalle lorsque le composant est démonté
return () => clearInterval(intervalId);
}, [elapsedTime, endgame]);
}, []);
useEffect(() => {
@ -119,17 +138,17 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
console.log(playerTouched)
if (touchedPlayer == -1){
if (!askedWrongLocal){
socket.emit("put correct background", socket.id)
putCorrectBackground()
}
}
else if (touchedPlayer < players.length && touchedPlayer>=0){
if(!askedWrongLocal){
socket.emit("put correct background", socket.id)
socket.emit("put grey background", socket.id, touchedPlayer)
putCorrectBackground()
putGreyBackground()
}
}
else if(touchedPlayer == players.length){
socket.emit("put imossible grey", socket.id)
putImposssibleGrey()
}
}, [playerTouched])
@ -168,6 +187,10 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
useEffect(() =>{
//* Gestion du sound des tours :
if (actualPlayerIndex == lastIndex){
handleTurn();
}
cptBug=0
if (actualPlayerIndex==firstPlayer){
const bot = testPlayers[lastIndex]
@ -188,6 +211,8 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
let i = 0
socket.emit("node checked", personIndex, true, lastIndex, room, lastIndex)
while(playerIndex != lastIndex){
// //! Play sound ?
// handleTurn();
i++
if (playerIndex == players.length){
playerIndex = 0
@ -320,6 +345,25 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
}, [importToPdf])
function downloadToJSON(jsonData: any, filename: string) {
const jsonBlob = new Blob([JSON.stringify(jsonData)], {type: 'application/json'});
const url = URL.createObjectURL(jsonBlob);
const link = document.createElement('a');
link.download = filename;
link.href = url;
link.click();
URL.revokeObjectURL(url);
}
useEffect(() => {
if (importToJSON){
setImportToJSON(false)
downloadToJSON(personNetwork, "graph.json")
downloadToJSON(JSON.stringify(indices), "indices.json")
}
}, [importToJSON])
useEffect(() => {
if (personNetwork == null){
return
@ -449,7 +493,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
p.indice=indices[index]
p.index=index
p.initiateMap(personNetwork)
console.log(p.indice.ToString("fr"))
}
})
}
@ -460,7 +503,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
bot.indice=indices[i]
bot.index=index
bot.initiateMap(personNetwork)
console.log(bot.indice.ToString("fr"))
}
}
if (i==playerIndex){
@ -492,6 +534,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setPlayerIndex(index)
setLastIndex(index)
if (actualPlayerIndex==index){
handleTurnBarTextChange("À vous de jouer")
handleShowTurnBar(true)
}
})
@ -522,6 +565,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
socket.on("node checked",(id, works, askedIndex, newPlayerIndex, socketId) => {
console.log("coucou")
cptBug=0
//@ts-ignore
const node = nodes.get().find((n) => id == n.id)
@ -551,7 +595,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
if (!node.label.includes(colorToEmoji(positionToColor(askedIndex), works))){
networkData.nodes.update({id: id, label: node.label + positionToEmoji(askedIndex, works)})
cptHistory++
if (cptHistory % 2 == 0){
if (cptHistory % 2 >= 0){
lastNodes.push(node)
addToHistory(testPlayers[askedIndex].pseudo + " à mis un " + positionToEmoji(askedIndex, works) + " à " + personNetwork.getPersons()[id].getName())
}
@ -577,7 +621,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
socket.on("asked wrong", () =>{
cptSquare++
if (cptSquare % 2 == 0){
if (cptSquare % 2 >= 0){
if (indice==null){
return
}
@ -604,7 +648,8 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
askedWrongBot=true
handleShowTurnBar(true)
handleTurnBarTextChange("Mauvais choix, posez un carré !")
socket.emit("put grey background", socket.id, actualPlayerIndex)
touchedPlayer = actualPlayerIndex
putGreyBackgroud()
}
else{
socket.emit("can't put square", actualPlayerIndex, room)
@ -615,7 +660,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
socket.on("can't put square", (askingPlayer) => {
cptBug=0
cptOnAskedWrong ++
if (cptOnAskedWrong % 2 == 0){
if (cptOnAskedWrong % 2 >= 0){
addToHistory(testPlayers[askingPlayer].pseudo + " ne peut plus poser de carré")
playerIndex = askingPlayer + 1
if(playerIndex == players.length){
@ -629,7 +674,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
else{
handleShowTurnBar(false)
socket.emit("put correct background", socket.id)
putCorrectBackground()
}
}
})
@ -688,18 +733,22 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
}
}
socket.on("put correct background", () =>{
const putCorrectBackground = () => {
if (personNetwork != null){
for(const person of personNetwork.getPersons()){
networkData.nodes.update({id: person.getId(), color: ColorToHexa(person.getColor())})
}
}
})
};
setPutCorrectBackground(() => putCorrectBackground)
socket.on("put grey background", (player) =>{
const putGreyBackgroud = () => {
if (personNetwork != null){
const player = touchedPlayer
const tab = mapIndexPersons.get(player)
if (tab != undefined){
if (player != actualPlayerIndex){
@ -727,9 +776,11 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
}
}
})
};
setPutGreyBackground(() => putGreyBackgroud)
socket.on("put imossible grey", ()=>{
const putGreyImpossible = () => {
if (personNetwork != null && indice!=null){
const tabNodes: any = []
const tester = IndiceTesterFactory.Create(indice)
@ -750,7 +801,9 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
networkData.nodes.update({id: n.id, color: "#808080"})
}
}
})
}
setPutImposssibleGrey(() => putGreyImpossible)
socket.on("end game", (winnerIndex) =>{
if (cptEndgame % 2 == 0){
@ -764,7 +817,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setLastIndex(-1)
setPlayerTouched(-1)
setWinnerData(winner)
setElapsedTime(0)
first = true
cptHistory = 0
@ -781,10 +834,10 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
// console.log("nbGames: " + user.onlineStats.nbGames + " nbWins: " + user.onlineStats.nbWins);
if(winner.id === currentPlayer.id){
// Ajouter une victoire
manager.userService.addOnlineStats(user.pseudo, 1, elapsedTime);
manager.userService.addOnlineStats(user.pseudo, 1, testTemps - 0.5);
}
else{
manager.userService.addOnlineStats(user.pseudo, 0, elapsedTime);
manager.userService.addOnlineStats(user.pseudo, 0, testTemps - 0.5);
}
}
else{
@ -797,6 +850,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
console.log(e);
}
finally{
setElapsedTime(0)
socket.off("end game")
socket.off("asked all")
socket.off("opacity activated")
@ -806,9 +860,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
socket.off("already asked")
socket.off("asked wrong")
socket.off("asked")
socket.off("put correct background")
socket.off("put grey background")
socket.off("put imossible grey")
socket.off("who plays")
navigate(`${basePath}/endgame`)
@ -870,7 +921,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
playerIndex = 0
}
socket.emit("node checked", params.nodes[0], false, actualPlayerIndex, room, playerIndex)
socket.emit("put correct background", socket.id)
putCorrectBackground()
touchedPlayer=-1
askedPersons.push(person)
askedWrongLocal=false
@ -908,7 +959,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
console.log("CE N'EST PAS UN BOT")
//@ts-ignore
socket.emit("ask player", params.nodes[0], players[touchedPlayer].id, players.find((p) => p.id === socket.id, actualPlayerIndex))
socket.emit("put correct background", socket.id)
putCorrectBackground()
touchedPlayer=-1
setPlayerTouched(-1)
}
@ -942,14 +993,14 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
if(!works){
socket.emit("node checked", params.nodes[0], works, playerIndex, room, actualPlayerIndex)
socket.emit("put correct background", socket.id)
putCorrectBackground()
socket.emit("asked wrong", players[actualPlayerIndex])
touchedPlayer=-1
setPlayerTouched(-1)
return
}
if (i == players.length - 1){
socket.emit("put correct background", socket.id)
putCorrectBackground()
await delay(1000)
socket.emit("end game", actualPlayerIndex, room)
return
@ -959,7 +1010,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
touchedPlayer=-1
setPlayerTouched(-1)
socket.emit("put correct background", socket.id)
putCorrectBackground()
await delay(1000)
socket.emit("end game", actualPlayerIndex, room)
}
@ -968,71 +1019,78 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
else{
//@ts-ignore
const person = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0]) //person sélectionnée
if (person != undefined){
const personTest = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0]) //person sélectionnée
const node = nodes.get().find((n: any) => params.nodes[0] == n.id)
if(node == undefined)return;
if (personTest != undefined && !node.label.includes(positionToEmoji(index, true)) && !node.label.includes(positionToEmoji(index, false))){ //si la personne existe et que le noeud n'a pas déjà été cliqué
let index =0
let works = true
const statsTime = elapsedTime;
for (const i of indices){
const tester = IndiceTesterFactory.Create(i)
const test = tester.Works(person)
//@ts-ignore
const node = nodes.get().find((n) => params.nodes[0] == n.id)
const test = tester.Works(personTest)
//@ts-ignore
if (node!=undefined){
if (!node.label.includes(positionToEmoji(index, test))){
networkData.nodes.update({id: params.nodes[0], label: node.label + positionToEmoji(index, test)})
await delay(500)
if(!test){
works = false
}
if (index == indices.length - 1 && works){
const nodeNode = nodes.get().find((n: any) => params.nodes[0] == n.id)
if(nodeNode == undefined)return;
networkData.nodes.update({id: params.nodes[0], label: nodeNode.label + positionToEmoji(index, test)})
await delay(500);
}
index++
}
if (person !== null && person.getId() === params.nodes[0]){
if (user!=null){
setWinnerData(user)
setNetworkDataData(networkData)
}
cptTour ++;
setNbCoupData(cptTour)
if (user!=null){
setWinnerData(user)
setNetworkDataData(networkData)
}
cptTour ++;
setNbCoupData(cptTour)
setElapsedTime(0)
endgame = true
try{
if(user && isLoggedIn){
if(solo){
if(isDaily){
// TODO: verif difficulté et add les stats
// TODO: verif pour facile et difficile, si réussi en one shot ou non
if(isEasy){
manager.userService.addEasyEnigmaStats(user.pseudo, 1, elapsedTime);
}
else{
manager.userService.addHardEnigmaStats(user.pseudo, 1, elapsedTime);
}
}
else{
// add stats mastermind
if(user && user.mastermindStats){
manager.userService.addMastermindStats(user.pseudo, cptTour, elapsedTime);
}
}
}
try{
console.log("time: " + testTemps)
if(user && isLoggedIn){
if(solo){
if(isDaily){
// TODO: verif difficulté et add les stats
// TODO: verif pour facile et difficile, si réussi en one shot ou non
if(isEasy){
manager.userService.addEasyEnigmaStats(user.pseudo, 1, testTemps - 0.5);
}
else{
manager.userService.addHardEnigmaStats(user.pseudo, 1, testTemps - 0.5);
}
}
catch(error){
console.log(error);
else{
// add stats mastermind
if(user && user.mastermindStats){
manager.userService.addMastermindStats(user.pseudo, cptTour, testTemps - 0.5);
}
}
navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`)
}
}
else{
// add stats mastermind
if(user && user.mastermindStats){
manager.userService.addMastermindStats(user.pseudo, cptTour, elapsedTime);
}
}
testFirst = true
setElapsedTime(0)
endgame = true
navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`)
}
catch(error){
console.log(error);
}
index++
navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`)
}
else{
addToHistory(personTest.getName() + " n'est pas le coupable !"); //TODO préciser le nombre d'indice qu'il a de juste
cptTour ++; // On Incrémente le nombre de tour du joueur
const tour = cptTour+1;
addToHistory("<----- [Tour " + tour +"/"+networkData.nodes.length + "] ----->");
changecptTour(cptTour); // On le transmet a la page précédente avec la fonction
}
addToHistory(person.getName() + " n'est pas le tueur !"); //TODO préciser le nombre d'indice qu'il a de juste
cptTour ++; // On Incrémente le nombre de tour du joueur
const tour = cptTour+1;
addToHistory("<----- [Tour " + tour +"/"+networkData.nodes.length + "] ----->");
changecptTour(cptTour); // On le transmet a la page précédente avec la fonction
}
}
}
@ -1054,12 +1112,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
function delay(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
function putGreyBackgroud(index: number){
/*
*/
}
}

@ -12,7 +12,6 @@ import Tooltip from 'react-bootstrap/esm/Tooltip';
import OverlayTrigger from 'react-bootstrap/esm/OverlayTrigger';
import {basePath} from "../AdressSetup"
interface LobbyContainerProps {
roomNum : string
HeadPlayer : Player
@ -27,7 +26,7 @@ const LobbyContainer: React.FC<LobbyContainerProps> = ({roomNum, HeadPlayer, nbP
const theme=useTheme();
const navigate = useNavigate();
const dest = '/lobby?room=' + roomNum;
const dest = 'lobby?room=' + roomNum;
//* Modal
const [showFull, setShowFull] = useState(false);

@ -12,6 +12,7 @@ import { BsFillPersonPlusFill } from 'react-icons/bs';
/* Images */
import logo from '../res/img/logo2_preview_rev_1.png';
import defaultImg from '../res/img/Person.png';
/* Components */
import LanguageNavItem from './LangNavItem';
@ -26,19 +27,23 @@ import { useAuth } from '../Contexts/AuthContext';
import { useNavigate } from 'react-router-dom';
import {basePath} from "../AdressSetup"
import Player from '../model/Player';
import { set } from 'lodash';
// @ts-ignore
function AppNavbar({changeLocale}) {
const theme = useTheme();
const {user, isLoggedIn, logout} = useAuth();
const navigate = useNavigate();
const {isLoggedIn, login, user, setUserData, manager } = useAuth();
function navigateToProfile(){
navigate(`${basePath}/profile`)
}
function navigateToLogin(){
navigate(`${basePath}/login`)
}
function navigateToHome(){
navigate(`${basePath}/`)
}
@ -64,40 +69,27 @@ function AppNavbar({changeLocale}) {
</Nav>
<div className='leftdiv'>
<Nav className="ml-auto navbar-title-dd">
{isLoggedIn ? (
<NavDropdown
title={<span style={{ color: theme.colors.text }}>Menu <BiDoorOpen /></span>}
id="basic-nav-dropdown"
align="end"
drop='down-centered'
>
<NavDropdown.Item onClick={navigateToProfile}>Profil</NavDropdown.Item>
<LanguageNavItem
countryCode="FR"
languageKey="languageSelector.french"
onClick={() => changeLocale('fr')}
/>
<LanguageNavItem
countryCode="GB"
languageKey="languageSelector.english"
onClick={() => changeLocale('en')}
/>
<NavDropdown.Divider />
<NavDropdown.Item onClick={logout}>Déconnexion</NavDropdown.Item>
</NavDropdown>
) : (
<>
<Nav.Link href={`${basePath}/login`} className='navbar-title-dd' style={{ backgroundColor: theme.colors.secondary }}>
<BiLogInCircle />
<FormattedMessage id="log_in" />
</Nav.Link>
<Nav.Link href={`${basePath}/signup`} className='navbar-title-dd' style={{ backgroundColor: theme.colors.secondary }}>
<BsFillPersonPlusFill />
<FormattedMessage id="sign_up" />
</Nav.Link>
<LangDropDown changeLocale={changeLocale}/>
</>
)}
{isLoggedIn ? (
<>
{/* Boutou qui lors du clique nous redirige vers le profile */}
<Nav.Link onClick={navigateToProfile} style={{ color: theme.colors.text }}>
<span>
<img src={user? user.profilePicture : defaultImg} height="50" width="50" alt="profile"/>
{user && user.pseudo}
</span>
</Nav.Link>
</>
):(
<>
{/* Bouton qui lors du clique nous redirige vers la connexion */}
<Nav.Link onClick={navigateToLogin} style={{ color: theme.colors.text }}>
<span>
<img src={user?.profilePicture} height="50" width="50" alt="profile"/>
{user && user.pseudo}
</span>
</Nav.Link>
</>
)}
</Nav>
</div>
</Navbar.Collapse>

@ -37,7 +37,7 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
img = BotImg
}
const [buffer, setBuffer] = useState("")
const [buffer, setBuffer] = useState('50%')
const [touchedPlayer, setTouchedPlayer] = useState(-2)
useEffect(() =>{
@ -48,10 +48,10 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
useEffect(() => {
if (playerIndex===index){
setBuffer('solid 3px green')
setBuffer('5px')
}
else{
setBuffer('')
setBuffer('50%')
}
}, [playerIndex])
@ -70,8 +70,8 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
onTouch();
};
const circleStyle: React.CSSProperties = {
backgroundColor: touchedPlayer == index && showCircle ? 'gold' : positionToColor(index), // Changement de la couleur en fonction de la condition
borderRadius: '50%',
backgroundColor: positionToColor(index), // Changement de la couleur en fonction de la condition
borderRadius: buffer,
width: '80px',
height: '80px',
display: 'flex',
@ -83,8 +83,8 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
const circleStyleInt: React.CSSProperties = {
backgroundColor:'white',
borderRadius: '50%',
backgroundColor: touchedPlayer == index && showCircle ? 'lightblue' : 'white',
borderRadius: buffer,
width: '70px',
height: '70px',
display: 'flex',
@ -111,8 +111,8 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
</div>
{/* </div> */}
</div>
<div className='playerNameDisplay' style={{border:buffer}}>
<h5>{actualPlayerIndex !== index ? (name.substring(0, name.length - 2).length > 7 ? name.substring(0, name.length - 2).substring(0, 7) + '...' : name) : 'vous'}</h5>
<div className='playerNameDisplay'>
<h6>{actualPlayerIndex !== index ? (name.length > 18 ? name.substring(0, 15) + '...' : name) : 'vous'}</h6>
</div>
</div>
);

@ -5,6 +5,8 @@ import Player from '../model/Player';
import { useTheme } from '../Style/ThemeContext';
import PersonStatus from './PersonStatus';
import Person from '../res/img/Person.png'
import BotImg from '../res/img/bot.png'
import { socket } from '../SocketConfig';
@ -16,13 +18,15 @@ interface PlayerListProps {
setPlayerTouched: (newPlayerTouch: number) => void;
playerIndex: number
askedWrong: boolean
greyForEveryone: () => void
}
const PlayerList: React.FC<PlayerListProps> = ({ players, playerTouched, setPlayerTouched, playerIndex, askedWrong}) => {
const PlayerList: React.FC<PlayerListProps> = ({ players, playerTouched, setPlayerTouched, playerIndex, askedWrong, greyForEveryone}) => {
const theme = useTheme();
function askEveryone(){
if (!askedWrong){
greyForEveryone()
setPlayerTouched(players.length)
}
}
@ -34,12 +38,10 @@ const PlayerList: React.FC<PlayerListProps> = ({ players, playerTouched, setPlay
//@ts-ignore
players.map((player, index) => (
//player.id!=socket.id &&
<PersonStatus img={player.profilePicture}
<PersonStatus img={player instanceof Player ? Person : BotImg}
state={Person}
key={index}
name={player.pseudo
+ " " +
positionToEmoji(index, true)}
name={player.pseudo}
playerTouched={playerTouched}
setPlayerTouched={setPlayerTouched}
index={index}
@ -65,8 +67,9 @@ const PlayerList: React.FC<PlayerListProps> = ({ players, playerTouched, setPlay
borderRadius: "10px",
border: "solid 1px",
textAlign: "center",
color: "white",
padding: "10px"}}
onClick={() => askEveryone()}>Guess !</button>
onClick={() => askEveryone()}>Ask everyone</button>
):
(
<button style={{
@ -75,6 +78,7 @@ const PlayerList: React.FC<PlayerListProps> = ({ players, playerTouched, setPlay
borderRadius: "10px",
border: "solid 1px",
textAlign: "center",
color: "white",
padding: "10px"}}
onClick={() => askEveryone()}>Ask everyone</button>
)

@ -0,0 +1,15 @@
/* Ajoutez ces styles dans votre fichier CSS ou utilisez un préprocesseur comme SCSS */
.tabsStats {
padding: 20px;
}
.stats {
background-color: #f0f0f0;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
/* Personnalisez davantage selon vos préférences */

@ -1,13 +1,13 @@
import React from 'react';
import React, {useState, useEffect} from 'react';
import Carousel from 'nuka-carousel';
/* Style */
import '../Pages/Play.css';
import '../Style/Global.css'
import './ScoreBoard.css';
import { useTheme } from '../Style/ThemeContext';
/* Ressources */
import Person from '../res/img/Person.png'
import leave from '../res/img/bot.png'
import trophy from '../res/icon/trophy.png'
import share from '../res/icon/share.png';
@ -19,155 +19,346 @@ import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
/* Component */
import ButtonImgNav from './ButtonImgNav';
import User from '../model/User';
/* Types */
/* Services */
import ScoreboardService from '../services/ScoreboardService';
import { BiLineChart, BiLineChartDown } from 'react-icons/bi';
import { CarouselCaption } from 'react-bootstrap';
import { BsLine } from 'react-icons/bs';
//@ts-ignore
const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => {
const theme=useTheme();
console.log(Player);
const [carouselKey, setCarouselKey] = useState(0);
const [activeTab, setActiveTab] = useState("perso");
// DAILY STATS
const [dailyMastermindStats, setDailyMastermindStats] = useState<any>(null);
const [dailyEasyEnigmaStats, setDailyEasyEnigmaStats] = useState<any>(null);
const [dailyMediumEnigmaStats, setDailyMediumEnigmaStats] = useState<any>(null);
const [dailyHardEnigmaStats, setDailyHardEnigmaStats] = useState<any>(null);
const [dailyOnlineStats, setDailyOnlineStats] = useState<any>(null);
// WEEKLY STATS
const [weeklyMastermindStats, setWeeklyMastermindStats] = useState<any>(null);
const [weeklyEasyEnigmaStats, setWeeklyEasyEnigmaStats] = useState<any>(null);
const [weeklyMediumEnigmaStats, setWeeklyMediumEnigmaStats] = useState<any>(null);
const [weeklyHardEnigmaStats, setWeeklyHardEnigmaStats] = useState<any>(null);
const [weeklyOnlineStats, setWeeklyOnlineStats] = useState<any>(null);
// Récupérer les records daily
useEffect(() => {
async function fetchDailyStats() {
try {
const resultMM = await ScoreboardService.getDailyMastermindStats();
const resultEF = await ScoreboardService.getDailyEasyEnigmaStats();
const resultEM = await ScoreboardService.getDailyMediumEnigmaStats();
const resultED = await ScoreboardService.getDailyHardEnigmaStats();
const resultOL = await ScoreboardService.getDailyOnlineStats();
setDailyMastermindStats(resultMM);
setDailyEasyEnigmaStats(resultEF);
setDailyMediumEnigmaStats(resultEM);
setDailyHardEnigmaStats(resultED);
setDailyOnlineStats(resultOL);
} catch (error) {
console.error(error);
}
}
async function fetchWeeklyStats() {
try{
const resultMM = await ScoreboardService.getWeeklyMastermindStats();
const resultEF = await ScoreboardService.getWeeklyEasyEnigmaStats();
const resultEM = await ScoreboardService.getWeeklyMediumEnigmaStats();
const resultED = await ScoreboardService.getWeeklyHardEnigmaStats();
const resultOL = await ScoreboardService.getWeeklyOnlineStats();
setWeeklyMastermindStats(resultMM);
setWeeklyEasyEnigmaStats(resultEF);
setWeeklyMediumEnigmaStats(resultEM);
setWeeklyHardEnigmaStats(resultED);
setWeeklyOnlineStats(resultOL);
} catch (error) {
console.error(error);
}
}
fetchDailyStats();
fetchWeeklyStats();
}, []);
return (
// <div className='LeaderBoardiv'>
<div className='LeaderBoardiv'>
<Tabs style={{width:"100%"}}
defaultActiveKey="daily"
id="ScoreBoard"
className="mb-3">
<Tab eventKey="perso" title="Vos Stats" disabled = { !Player.pseudo.startsWith("Guest_") ? false : true}>
<Container fluid>
<Row>Stats en MasterMind :</Row>
<Row>
<Col sm={10}>Partie Jouées :</Col>
<Col className='leftRow'>{Player !== null ? Player.mastermindStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Best-Score :</Col>
<Col className='leftRow'>{Player !== null ? Player.mastermindStats.bestScore : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne d'essai :</Col>
<Col className='leftRow'>{Player !== null ? Player.mastermindStats.avgNbTry : "0"}</Col>
</Row>
<hr/>
<Row>Stats en Enigme facile :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Nombre de victoire :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.nbWins : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Ratio V/D :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.ratio.toFixed(2) + "%" : "00.0%"}</Col>
</Row>
<Row>
<Col sm={10}>Meilleur temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.bestTime : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne de temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.avgTime.toFixed(2) : "0"}</Col>
</Row>
<hr/>
<Row>Stats en Enigme moyenne :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.mediumEnigmaStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Best-Score :</Col>
<Col className='leftRow'>{Player !== null ? Player.mediumEnigmaStats.bestScore : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne d'essai :</Col>
<Col className='leftRow'>{Player !== null ? Player.mediumEnigmaStats.avgNbTry.toFixed(2) : "0"}</Col>
</Row>
<hr/>
<Row>Stats en Enigme difficile :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Nombre de victoire :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.nbWins : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Ratio V/D :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.ratio.toFixed(2) + "%" : "00.0%"}</Col>
</Row>
<Row>
<Col sm={10}>Meilleur temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.bestTime : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne de temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.avgTime.toFixed(2) : "0"}</Col>
</Row>
<hr/>
<Row>Stats en ligne :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.onlineStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Nombre de victoire :</Col>
<Col className='leftRow'>{Player !== null ? Player.onlineStats.nbWins : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Ratio V/D :</Col>
<Col className='leftRow'>{Player !== null ? Player.onlineStats.ratio.toFixed(2) + "%" : "0"}</Col>
</Row>
</Container>
</Tab>
<Tab eventKey="daily" title="Daily"
style={{display:"flex", flexDirection:'column', alignItems:'center'}}>
<img src={trophy}
height='100'
width='100'
alt="Person2"/>
<Container fluid>
<Row>
<Col sm={8}>Partie Jouées :</Col>
<Col className='leftRow'>10</Col>
</Row>
<Row>
<Col sm={8}>Partie gagnées :</Col>
<Col className='leftRow'>2</Col>
</Row>
<Row>
<Col sm={8}>Pions posés :</Col>
<Col className='leftRow'>2</Col>
</Row>
<hr/>
<Row>
<Col sm={8}>Partie solo :</Col>
<Col className='leftRow'>21</Col>
</Row>
<Row>
<Col sm={8}>Nombre de coups moyen :</Col>
<Col className='leftRow'>19</Col>
</Row>
</Container>
</Tab>
<Tab eventKey="weekly" title="Weekly">
<img src={trophy}
height='100'
width='100'
alt="Person2"/>
</Tab>
</Tabs>
<ButtonImgNav dest='/' img={share}/>
</div>
//</div>
<Tabs
activeKey={activeTab}
onSelect={(key:any) => {
setActiveTab(key);
// Forcer une mise à jour du carousel
setCarouselKey((prevKey) => prevKey + 1);
}}
id="ScoreBoard"
className="tabsStats justify-content-around">
<Tab eventKey="perso" title="Vos Stats" disabled={!Player.pseudo.startsWith("Guest_") ? false : true}>
<Tab.Content className={`tabsStats ${activeTab !== 'perso' ? 'hidden' : ''}`}>
<Carousel adaptiveHeight wrapAround slidesToShow={1} cellSpacing={10} key={carouselKey}>
<div className="stats">
<h5>Mastermind</h5>
<hr />
<p>Parties Jouées: {Player.mastermindStats.nbGames}</p>
<p>Best-Score: {Player.mastermindStats.bestScore}</p>
<p>Moyenne d'essai: {Player.mastermindStats.avgNbTry.toFixed(2)}</p>
</div>
<div className="stats">
<h5>Enigme facile</h5>
<hr />
<p>Parties Jouées: {Player.easyEnigmaStats.nbGames}</p>
<p>Nombre de victoires: {Player.easyEnigmaStats.nbWins}</p>
<p>Ratio V/D: {Player.easyEnigmaStats.ratio.toFixed(2) + "%"}</p>
<p>Meilleur temps: {Player.easyEnigmaStats.bestTime + "s"}</p>
<p>Moyenne de temps: {Player.easyEnigmaStats.avgTime.toFixed(2) + "s"}</p>
</div>
<div className="stats">
<h5>Enigme moyenne</h5>
<hr />
<p>Parties Jouées: {Player.mediumEnigmaStats.nbGames}</p>
<p>Best-Score: {Player.mediumEnigmaStats.bestScore}</p>
<p>Moyenne d'essai: {Player.mediumEnigmaStats.avgNbTry.toFixed(2)}</p>
</div>
<div className="stats">
<h5>Enigme difficile</h5>
<hr />
<p>Parties Jouées: {Player.hardEnigmaStats.nbGames}</p>
<p>Nombre de victoires: {Player.hardEnigmaStats.nbWins}</p>
<p>Ratio V/D: {Player.hardEnigmaStats.ratio.toFixed(2) + "%"}</p>
<p>Meilleur temps: {Player.hardEnigmaStats.bestTime + "s"}</p>
<p>Moyenne de temps: {Player.hardEnigmaStats.avgTime.toFixed(2) + "s"}</p>
</div>
<div className="stats">
<h5>En ligne</h5>
<hr />
<p>Parties Jouées: {Player.onlineStats.nbGames}</p>
<p>Nombre de victoires: {Player.onlineStats.nbWins}</p>
<p>Ratio V/D: {Player.onlineStats.ratio.toFixed(2) + "s"}</p>
</div>
</Carousel>
</Tab.Content>
</Tab>
<Tab eventKey="daily" title="Daily">
<Tab.Content className={`tabsStats ${activeTab !== 'daily' ? 'hidden' : ''}`}>
<Carousel adaptiveHeight wrapAround slidesToShow={1} cellSpacing={10} key={carouselKey}>
<div className="stats">
<h5>Mastermind</h5>
<hr />
{dailyMastermindStats !== null ? (dailyMastermindStats.tab.length !== 0 ? dailyMastermindStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.score + " essai(s)"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme facile</h5>
<hr />
{dailyEasyEnigmaStats !== null ? (dailyEasyEnigmaStats.tab.length !== 0 ? dailyEasyEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme moyenne</h5>
<hr />
{dailyMediumEnigmaStats !== null ? (dailyMediumEnigmaStats.tab.length !== 0 ? dailyMediumEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme difficile</h5>
<hr />
{dailyHardEnigmaStats !== null ? (dailyHardEnigmaStats.tab.length !== 0 ? dailyHardEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>En ligne</h5>
<hr />
{dailyOnlineStats !== null ? (dailyOnlineStats.tab.length !== 0 ? dailyOnlineStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.wins + " victoires"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
</Carousel>
</Tab.Content>
</Tab>
<Tab eventKey="weekly" title="Weekly">
<Tab.Content className={`tabsStats ${activeTab !== 'weekly' ? 'hidden' : ''}`}>
<Carousel adaptiveHeight wrapAround slidesToShow={1} cellSpacing={10} key={carouselKey}>
<div className="stats">
<h5>Mastermind</h5>
<hr />
{weeklyMastermindStats !== null ? (weeklyMastermindStats.tab.length !== 0 ? weeklyMastermindStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.score + " essai(s)"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme facile</h5>
<hr />
{weeklyEasyEnigmaStats !== null ? (weeklyEasyEnigmaStats.tab.length !== 0 ? weeklyEasyEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme moyenne</h5>
<hr />
{weeklyMediumEnigmaStats !== null ? (weeklyMediumEnigmaStats.tab.length !== 0 ? weeklyMediumEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme difficile</h5>
<hr />
{weeklyHardEnigmaStats !== null ? (weeklyHardEnigmaStats.tab.length !== 0 ? weeklyHardEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>En ligne</h5>
<hr />
{weeklyOnlineStats !== null ? (weeklyOnlineStats.tab.length !== 0 ? weeklyOnlineStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.wins + " victoires"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
</Carousel>
</Tab.Content>
</Tab>
</Tabs>
);
}
export default ScoreBoard;
export default ScoreBoard;

@ -0,0 +1,331 @@
import React, { useEffect, useState } from "react";
import { DataSet, Network} from "vis-network/standalone/esm/vis-network";
import GraphCreator from "../model/Graph/GraphCreator";
import "./GraphContainer.css";
import IndiceTesterFactory from "../model/Factory/IndiceTesterFactory";
import Person from "../model/Person";
import { useNavigate } from "react-router-dom";
import { useGame } from "../Contexts/GameContext";
import { socket } from "../SocketConfig"
import { colorToEmoji, positionToColor, positionToEmoji } from "../ColorHelper";
import { ColorToHexa } from "../model/EnumExtender";
import Bot from "../model/Bot";
import NodePerson from "../model/Graph/NodePerson";
import { useAuth } from "../Contexts/AuthContext";
import Indice from "../model/Indices/Indice";
import Pair from "../model/Pair";
import Player from "../model/Player";
import JSONParser from "../JSONParser";
import User from "../model/User";
import { json } from "body-parser";
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
import {basePath} from "../AdressSetup"
import PersonNetwork from "../model/PersonsNetwork";
interface TutorialGraphProps {
setNetwork: (network: Network) => void
showLast: boolean
setPlayerIndex: (playerIndex: number) => void
handleShowTurnBar: (bool: boolean) => void
handleTurnBarTextChange: (text: string) => void
addToHistory: (text: string) => void
setPlayerTouched: (playerIndex: number) => void
playerTouched: number
tutoStep: number
setTutoStep: (step: number) => void
setGreyForEveryone: (func: () => void) => void
displayModalstep: (step: number) => void;
}
let lastNodes: NodePerson[] = []
let firstIndex = true
let first = true
let touchedPlayer = -1
let stepTuto = -1
const TutorialGraph: React.FC<TutorialGraphProps> = ({showLast, setNetwork, setPlayerIndex, handleShowTurnBar, handleTurnBarTextChange, addToHistory, setPlayerTouched, playerTouched, tutoStep, setTutoStep, setGreyForEveryone, displayModalstep}) => {
let cptTour: number = 0
//* Gestion du temps :
let initMtn = 0
const {isLoggedIn, user, manager} = useAuth();
const {setIndiceData, setIndicesData, setActualPlayerIndexData, setWinnerData, setPlayersData, setNetworkDataData, setPersonData} = useGame();
const params = new URLSearchParams(window.location.search);
const navigate = useNavigate();
const [lastIndex, setLastIndex] = useState(-1)
if (first){
first = false
setActualPlayerIndexData(0)
handleTurnBarTextChange("C'est à vous de jouer !")
handleShowTurnBar(true)
}
useEffect(() =>{
touchedPlayer=playerTouched
}, [playerTouched])
useEffect(() => {
stepTuto = tutoStep
if(stepTuto===1){
handleShowTurnBar(true)
}
}, [tutoStep])
useEffect(() => {
const tab: NodePerson[] = []
for(const n of lastNodes.reverse()){
}
lastNodes = tab
if (showLast){
socket.emit("opacity activated", socket.id)
}
else{
socket.emit("opacity deactivated", socket.id)
}
}, [showLast])
let playerIndex: number = 0
if (firstIndex){
firstIndex=false
setPlayerIndex(playerIndex)
}
let index = 0
useEffect(() => {
let jsonGraph = require("../tuto/graph.json")
let jsonIndice = require("../tuto/indices.json")
const personNetwork = JSONParser.JSONToNetwork(JSON.stringify(jsonGraph))
const indices = JSONParser.JSONToIndices(jsonIndice)
setIndiceData(indices[0])
if (personNetwork == null){
return
}
const graph = GraphCreator.CreateGraph(personNetwork)
const nodes = new DataSet(graph.nodesPerson);
setIndicesData(indices)
setPersonData(personNetwork.getPersons()[4])
let n = graph.nodesPerson;
let e = graph.edges;
const graphState = { n, e };
// Sauvegarder l'état dans localStorage
localStorage.setItem('graphState', JSON.stringify(graphState));
const container = document.getElementById('graph-container');
if (!container) {
console.error("Container not found");
return;
}
// Charger les données dans le graph
// Configuration des options du Graphe
const initialOptions = {
layout: {
improvedLayout: true,
hierarchical: {
enabled: false,
direction: 'LR', // LR (Left to Right) ou autre selon votre préférence
sortMethod: 'hubsize'
},
randomSeed: 3
},
physics: {
enabled: true,
barnesHut: {
gravitationalConstant: -1000,
springConstant: 0.001,
springLength: 100
},
solver: "repulsion",
repulsion: {
nodeDistance: 100 // Put more distance between the nodes.
}
}
};
const networkData = { nodes: nodes, edges: graph.edges };
const network = new Network(container, networkData, initialOptions);
network.stabilize();
setNetwork(network)
const myFunctionInsideEffect = () => {
if (stepTuto === 3){
const tabGrey = [0, 1, 2, 3, 5, 6, 7, 8, 9]
for (const i of tabGrey){
nodes.update({id: i, color: "#808080"})
}
}
};
setGreyForEveryone(() => myFunctionInsideEffect);
network.on("click", async (params) => {
if(params.nodes.length > 0){
}
});
network.on("dragging", (params) => {
if (params.nodes.length > 0) {
// Un nœud a été cliqué
initialOptions.physics.enabled = false;
network.setOptions(initialOptions);
setNetwork(network)
}
});
network.on("click", async (params) => {
if(params.nodes.length > 0){
if (stepTuto === 0 && touchedPlayer === 1){
const node = nodes.get().find((n: NodePerson) => n.id === params.nodes[0])
if (node === undefined)return;
if (node.id === 7){
nodes.update({id: node.id, label: node.label + positionToEmoji(1, true)})
handleShowTurnBar(false)
setPlayerIndex(1)
setPlayerTouched(-1)
await delay(500)
const node2 = nodes.get().find((n: NodePerson) => n.id === params.nodes[0])
if (node2 === undefined)return;
nodes.update({id: node.id, label: node2.label + positionToEmoji(2, false)})
await delay(500)
const node3 = nodes.get().find((n: NodePerson) => n.id === 8)
if (node3 === undefined)return;
nodes.update({id: node3.id, label: node3.label + positionToEmoji(1, false)})
setPlayerIndex(2)
await delay(500)
const node4 = nodes.get().find((n: NodePerson) => n.id === 0)
if (node4 === undefined)return;
nodes.update({id: node4.id, label: node4.label + positionToEmoji(1, true)})
setPlayerIndex(0)
setTutoStep(1)
displayModalstep(1);
}
}
else if(stepTuto === 1 && touchedPlayer === 2){
const node = nodes.get().find((n: NodePerson) => n.id === params.nodes[0])
if (node === undefined){
return;
}
if (node.id === 0){
nodes.update({id: node.id, label: node.label + positionToEmoji(2, false)})
setPlayerTouched(-1)
displayModalstep(2);
handleTurnBarTextChange("Mauvais choix, posez un carré !")
const tabGrey = [7, 0, 4, 1, 8]
for (const id of tabGrey){
const node = nodes.get().find((n: NodePerson) => n.id === id)
if (node === undefined)return;
nodes.update({id: node.id, color: "#808080"})
}
setTutoStep(2)
}
}
else if(stepTuto === 2){
const node = nodes.get().find((n: NodePerson) => n.id === params.nodes[0])
if (node === undefined)return;
if (node.id === 9){
const tabColor = [7, 0, 4, 1, 8]
nodes.update({id: node.id, label: node.label + positionToEmoji(0, false)})
for(const id of tabColor){
const pers = personNetwork.getPersons().find((p: Person) => p.getId() === id)
if (pers !== undefined){
nodes.update({id: id, color: ColorToHexa(pers.getColor())})
}
}
handleShowTurnBar(false)
setPlayerIndex(1)
await delay(500)
const node2 = nodes.get().find((n: NodePerson) => n.id === 4)
if (node2 === undefined)return;
nodes.update({id: node2.id, label: node2.label + positionToEmoji(2, true)})
setPlayerIndex(2)
await delay(500)
const node3 = nodes.get().find((n: NodePerson) => n.id === 3)
if (node3 === undefined)return;
nodes.update({id: node3.id, label: node3.label + positionToEmoji(0, false)})
await delay(500)
const node4 = nodes.get().find((n: NodePerson) => n.id === 1)
if (node4 === undefined)return;
nodes.update({id: node4.id, label: node4.label + positionToEmoji(2, false)})
setPlayerIndex(0)
handleTurnBarTextChange("A vous de jouer !")
handleShowTurnBar(true)
setTutoStep(3)
displayModalstep(3);
}
}
else if(stepTuto === 3 && touchedPlayer === 3){
const node = nodes.get().find((n: NodePerson) => n.id === params.nodes[0])
if (node === undefined)return;
if (node.id === 4){
nodes.update({id: node.id, label: node.label + positionToEmoji(0, true)})
setPlayerTouched(-1)
await delay(500)
const node2 = nodes.get().find((n: NodePerson) => n.id === 4)
if (node2 === undefined)return;
nodes.update({id: node2.id, label: node2.label + positionToEmoji(1, true)})
await delay(500)
for(const person of personNetwork.getPersons()){
nodes.update({id: person.getId(), color: ColorToHexa(person.getColor())})
}
if (user != null){
const winner = user;
setNetworkDataData(networkData)
setActualPlayerIndexData(-1)
setLastIndex(-1)
setPlayerTouched(-1)
setWinnerData(winner)
first = true
navigate(`${basePath}/endgame`)
}
}
}
}
else{
setPlayerTouched(-1)
}
});
}, []); // Le tableau vide signifie que cela ne s'exécutera qu'une fois après le premier rendu
return (
<>
<div id="graph-container"/>
</>
);
function delay(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
export default TutorialGraph;

@ -24,8 +24,6 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const login = async () => {
setIsLoggedIn(true);
const [u, bool] = await manager.userService.fetchUserInformation()
setUser(u)
};
const setUserData = (newPlayer: User) => {

@ -1,4 +1,4 @@
import React, {useEffect} from 'react';
import React, {useEffect, useState} from 'react';
/* Style */
@ -11,6 +11,9 @@ import Person from '../res/img/Person.png';
import Leave from '../res/icon/leave.png';
import Replay from '../res/icon/replay.png';
/* sound */
import WinSound from '../res/Audio/win.wav';
/* Component */
import PersonStatus from '../Components/PersonStatus';
import ButtonImgNav from '../Components/ButtonImgNav';
@ -64,6 +67,11 @@ function EndGame() {
}
};
useEffect(() => {
handleWinSound();
}, []);
useEffect(() => {
const container = document.getElementById("vis-graph");
if (!container) {
@ -126,14 +134,27 @@ function EndGame() {
indicenull = true;
}
//* Sound
const [playTurnSound, setPlayTurnSound] = useState(false);
const handleWinSound = () => {
setTimeout(() => { // on attend 1s avant de jouer le son
setPlayTurnSound(true);
}, 300);
setTimeout(() => { // on attend 2s avant de remettre le son à false
setPlayTurnSound(false);
}, 2000);
};
return (
<div>
{playTurnSound && <audio src={WinSound} autoPlay />}
{!IsSolo ? (
<div>
<div className="head">
<header className='leaderboard-header' style={{ borderColor: theme.colors.primary }}>
<h1>{winner?.pseudo} a gagné !</h1>
<h3>Le tueur était <u>{person?.getName()}</u></h3>
<h3>Le coupable était <u>{person?.getName()}</u></h3>
</header>
</div>
<div className='winner'>
@ -146,15 +167,13 @@ function EndGame() {
<BigButtonNav dest="/play" img={Leave}/>
</div> */}
<div className="losingPlayersContainer">
{losingPlayers.map((player, index) => (
<div className="playerContainer" key={index}>
{player.id !== winner?.id && (
<div>
<PersonStatus img={Person} state={Person} key={index} name={player.pseudo} playerTouched={1} setPlayerTouched={() => {}} index={index} playerIndex={-2} showCircle={false} askedWrong={false}/>
{!indicenull && (<h6 className='indiceDisplay'>{indices[players.findIndex((p) => p.id == player?.id)].ToString("fr")}</h6>)}
</div>
)}
</div>
{players.map((player, index) => (
player.id !== winner?.id && (
<div className="playerContainer" key={index}>
<PersonStatus img={Person} state={Person} key={index} name={player.pseudo} playerTouched={1} setPlayerTouched={() => {}} index={index} playerIndex={-2} showCircle={false} askedWrong={false}/>
{!indicenull && (<h6 className='indiceDisplay'>{indices[players.findIndex((p) => p.id == player?.id)].ToString("fr")}</h6>)}
</div>
)
))}
</div>
</div>
@ -164,7 +183,7 @@ function EndGame() {
<div className="head">
<header className='leaderboard-header' style={{ borderColor: theme.colors.primary }}>
<h1>Vous avez gagné !</h1>
<h3>Le tueur était <u>{person?.getName()}</u></h3>
<h3>Le coupable était <u>{person?.getName()}</u></h3>
</header>
</div>
<div className='winner'>

@ -51,7 +51,7 @@ function Home() {
<h2>Introduction</h2>
<p>
{/* <FormattedMessage id="home.histoire" /> */}
Bienvenue dans notre jeu de déduction captivant, où l'intrigue et la malice se rejoignent dans une aventure palpitante ! Plongez-vous dans un monde de mystère et d'intrigue, où chaque interaction compte, et chaque indice vous rapproche de la vérité.Imaginez un graphique complexe où chaque sommet représente une personne, chaque axe une relation, et chaque détail compte. Vous êtes plongé dans un défi stimulant pour découvrir qui parmi ces individus est le mystérieux tueur. Chaque joueur détient un indice crucial, et seul le partage stratégique de ces indices vous mènera à la résolution du mystère. Explorez notre page de règles pour comprendre les subtilités du jeu, découvrez les indices qui peuvent vous guider, et élaborez des stratégies intelligentes pour identifier le coupable. Manipuler vos amis, afin d'être le premier à découvrir qui est le meurtrier ! Êtes-vous prêt à relever le défi et à démasquer le tueur caché dans le graphe ? Que l'enquête commence !
Bienvenue dans notre jeu de déduction captivant, où l'intrigue et la malice se rejoignent dans une aventure palpitante ! Plongez-vous dans un monde de mystère et d'intrigue, où chaque interaction compte, et chaque indice vous rapproche de la vérité.Imaginez un graphique complexe où chaque sommet représente une personne, chaque axe une relation, et chaque détail compte. Vous êtes plongé dans un défi stimulant pour découvrir qui parmi ces individus est le mystérieux coupable. Chaque joueur détient un indice crucial, et seul le partage stratégique de ces indices vous mènera à la résolution du mystère. Explorez notre page de règles pour comprendre les subtilités du jeu, découvrez les indices qui peuvent vous guider, et élaborez des stratégies intelligentes pour identifier le coupable. Manipuler vos amis, afin d'être le premier à découvrir qui est le meurtrier ! Êtes-vous prêt à relever le défi et à démasquer le coupable caché dans le graphe ? Que l'enquête commence !
</p>
</div>
<div>

@ -27,6 +27,11 @@ import Oeye from "../res/icon/eye.png";
import Ceye from "../res/icon/hidden.png";
import JSZip from 'jszip';
/* Sound */
import turnSound from "../res/Audio/turn.mp3";
import winSound from "../res/Audio/win.wav";
/* nav */
import { Link, Navigate, useNavigate, useNavigationType } from 'react-router-dom';
@ -97,6 +102,28 @@ const InGame = ({locale, changeLocale}) => {
const [showLast, setShowLast] = useState(false)
const [askedWrong, setAskedWrong] = useState(false)
const [importToPdf, setImportToPdf] = useState(false)
const [importToJSON, setImportToJSON] = useState(false)
const [putCorrectBackground, setPutCorrectBackground] = useState<() => void>(() => {});
const [putGreyBackgroud, setPutGreyBackground] = useState<() => void>(() => {});
const [putImposssibleGrey, setPutImposssibleGrey] = useState<() => void>(() => {});
const setPutCorrectBackgroundData = (func: () => void) => {
setPutCorrectBackground(func)
}
const setPutGreyBackgroundData = (func: () => void) => {
setPutGreyBackground(func)
}
const setPutImposssibleGreyData = (func: () => void) => {
setPutImposssibleGrey(func)
}
const setImportToJSONData = (imp: boolean) => {
setImportToJSON(imp)
}
const setImportToPdfData = (imp: boolean) => {
setImportToPdf(imp)
@ -278,13 +305,36 @@ const InGame = ({locale, changeLocale}) => {
window.open(url);
};
const [SwitchEnabled, setSwitchEnabled] = useState(false)
// const [SwitchEnabled, setSwitchEnabled] = useState(false)
const allIndices = Stub.GenerateIndice()
const { indice, players, actualPlayerIndex} = useGame();
const nbPlayer = players.length;
const navdeduc = 'deduc?actualId=' + actualPlayerIndex + '&nbPlayer=' + nbPlayer;
//* Sound
const [playTurnSound, setPlayTurnSound] = useState(false);
const [soundPreference, setSoundPreference] = useState(true); // utilisateur
const handleSoundPreferenceChange = () => {
setSoundPreference(!soundPreference);
console.log("changement des options du son : "+ soundPreference)
};
const handleTurn = () => {
console.log("etat normal du sound : " + soundPreference)
if (soundPreference) {
setPlayTurnSound(true);
setTimeout(() => {
setPlayTurnSound(false);
}, 2000);
}
};
return (
<div id="mainDiv">
{showTurnBar && <TurnBar text={turnBarText}/>}
@ -306,8 +356,18 @@ const InGame = ({locale, changeLocale}) => {
askedWrong={askedWrong}
setAskedWrong={setAskedWrongData}
importToPdf={importToPdf}
setImportToPdf={setImportToPdfData}/>
setImportToPdf={setImportToPdfData}
importToJSON={importToJSON}
setImportToJSON={setImportToJSONData}
setPutCorrectBackground={setPutCorrectBackgroundData}
setPutGreyBackground={setPutGreyBackgroundData}
setPutImposssibleGrey={setPutImposssibleGreyData}
putCorrectBackground={putCorrectBackground}
putGreyBackground={putGreyBackgroud}
putImposssibleGrey={putImposssibleGrey}
handleTurn={handleTurn}/>
</div>
{playTurnSound && <audio src={turnSound} autoPlay />}
{IsSolo && !isDaily &&
@ -427,22 +487,9 @@ const InGame = ({locale, changeLocale}) => {
}
</div>
{/*
<Offcanvas show={showP}
onHide={handleCloseP}>
<Offcanvas.Header closeButton>
<Offcanvas.Title>Joueurs</Offcanvas.Title>
<h3>Il y a {players.length} joueurs</h3>
</Offcanvas.Header>
<Offcanvas.Body>
</Offcanvas.Body>
</Offcanvas>
*/}
{ !IsSolo &&
<div className='playerlistDiv'>
<PlayerList players={players} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} playerIndex={playerIndex} askedWrong={askedWrong}/>
<PlayerList players={players} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} playerIndex={playerIndex} askedWrong={askedWrong} greyForEveryone={() => {}}/>
</div>
}
@ -456,7 +503,6 @@ const InGame = ({locale, changeLocale}) => {
<Offcanvas.Title>Indice</Offcanvas.Title>
</Offcanvas.Header>
<Offcanvas.Body>
{/* Possède les cheveux noir <u>ou</u> joue au basket */}
{indice?.ToString(locale)}
</Offcanvas.Body>
</Offcanvas>
@ -472,31 +518,12 @@ const InGame = ({locale, changeLocale}) => {
<Offcanvas.Title><img src={Param} alt='param'/> Paramètres</Offcanvas.Title>
</Offcanvas.Header>
<Offcanvas.Body>
<Nav className="me-auto">
<NavDropdown
title={<span><HiLanguage/> Language </span>}
className="navbar-title" id="basic-nav-dropdown">
<NavDropdown.Item onClick={() => changeLocale('fr')}>
<FormattedMessage id="languageSelector.french"/>
</NavDropdown.Item>
<NavDropdown.Item onClick={() => changeLocale('en')}>
<FormattedMessage id="languageSelector.english"/>
</NavDropdown.Item>
</NavDropdown>
</Nav>
<label>
<Switch checked={SwitchEnabled} onChange={setSwitchEnabled}/>
<p>Afficher les noeuds possibles</p>
<label style={{ display:'flex'}}>
<Switch checked={soundPreference} onChange={handleSoundPreferenceChange}/>
<p style={{ marginLeft:'20px'}}>Activer les SFX</p>
</label>
</Offcanvas.Body>
</Offcanvas>
{/*
<div id="endgamebutton" > {/* tmp
<ButtonImgNav dest="/endgame" img={Leave} text='endgame'/>
</div>
*/}
</div>
);
};

@ -1,4 +1,4 @@
import React from 'react';
import React, {useEffect} from 'react';
/* Style */
import '../Style/Global.css';
@ -24,11 +24,31 @@ import Alert from 'react-bootstrap/Alert';
import MGlass from "../res/icon/magnifying-glass.png";
import Param from "../res/icon/param.png";
import Info from "../res/icon/infoGreen.png"; //todo changer la couleur de l'icon
import { useAuth } from '../Contexts/AuthContext';
//@ts-ignore
function InfoPage({locale, changeLocale}) {
const theme = useTheme();
const {isLoggedIn, login, user, setUserData, manager } = useAuth();
useEffect(() => {
if (user == null){
console.log(user)
manager.userService.fetchUserInformation().then(([user, loggedIn]) =>{
console.log(user);
if (user!=null){
if (loggedIn){
login()
setUserData(user)
}
else{
setUserData(user)
}
}
})
}
}, [isLoggedIn]);
const styles = {
roux: { backgroundColor: ColorToHexa(Color.REDHEAD), width: '15px', height: '15px', display: 'inline-block', marginRight: '5px' },
@ -61,10 +81,8 @@ function InfoPage({locale, changeLocale}) {
<section id="composants-du-jeu">
<h2><FormattedMessage id="info.pions"/> :</h2>
<h4>
<FormattedMessage id="info.sommaire"/>
</h4>
<h6><FormattedMessage id="info.composant.text"/></h6>
<h4><FormattedMessage id="info.sommaire"/></h4>
<h6><FormattedMessage id="info.composant.text"/></h6>
<ul>
<p>
<li><h5 className='h5title'><FormattedMessage id="info.composant.carre.title"/> : 🟪🟦🟩🟨🟥🟫</h5></li>
@ -73,7 +91,6 @@ function InfoPage({locale, changeLocale}) {
<li><h5 className='h5title'><FormattedMessage id="info.composant.rond.title"/> : 🟣🔵🟢🟡🔴🟤</h5></li>
<FormattedMessage id="info.composant.rond"/>
</p>
</ul>
<hr/>
<h4>
<FormattedMessage id="info.car_perso"/>
@ -122,6 +139,7 @@ function InfoPage({locale, changeLocale}) {
</ul>
<FormattedMessage id="info.composant.sport.bis"/>
</p>
</ul>
</section>
<hr/>
<section id="objectif-du-jeu">
@ -270,7 +288,6 @@ function InfoPage({locale, changeLocale}) {
<FormattedMessage id="info.indice-possible.voisin"/>
</h4>
<IndiceList instance={EdgesIndice} lang={locale}/>
<IndiceList instance={NbEdgesIndice} lang={locale}/>
<hr/>
</section>
</div>

@ -66,11 +66,17 @@ function Lobby() {
const room = params.get('room');
function addBot(){
socket.emit("lobby joined", room, new EasyBot("botId" + Math.floor(Math.random() * 1000), "Bot" + Math.floor(Math.random() * 100), "").toJson())
let json = require("../res/botNames.json")
const tabNames = [...json.names]
let name = tabNames[Math.floor(Math.random() * tabNames.length)]
while (players.find((p) => p.pseudo === name) != undefined){
name = tabNames[Math.floor(Math.random() * tabNames.length)]
}
socket.emit("lobby joined", room, new EasyBot(name, name, "").toJson())
}
//* nb Node
const [enteredNumber, setEnteredNumber] = useState(20);
const [enteredNumber, setEnteredNumber] = useState(25);
//@ts-ignore
const handleNumberChange = (event) => {
@ -213,23 +219,25 @@ function Lobby() {
function StartGame(){
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(players.length, enteredNumber)
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
let users = players.filter((p) => p instanceof User)
let u = users[Math.floor(Math.random() * users.length)]
let start = players.findIndex((p) => p.id == u.id)
if (start == -1){
start = 0
if (players.length > 2){
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(players.length, enteredNumber)
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
let users = players.filter((p) => p instanceof User)
let u = users[Math.floor(Math.random() * users.length)]
let start = players.findIndex((p) => p.id == u.id)
if (start == -1){
start = 0
}
socket.emit('network created', JSON.stringify(networkPerson, null, 2), JSON.stringify(choosenPerson), JSON.stringify(choosenIndices), room, start);
}
socket.emit('network created', JSON.stringify(networkPerson, null, 2), JSON.stringify(choosenPerson), JSON.stringify(choosenIndices), room, start);
}
const copyGameLink = () => {
setShow(!show)
const gameLink = "http://172.20.10.4:3000/lobby?room="+ room;
const gameLink = basePath + "/lobby?room="+ room;
navigator.clipboard.writeText(gameLink)
.then(() => {
console.log('Lien copié avec succès !');
@ -240,7 +248,7 @@ function Lobby() {
};
const textAreaRef = useRef<HTMLTextAreaElement>(null);
const linkToCopy = "http://172.20.10.4:3000/lobby?room="+ room
const linkToCopy = basePath + "/lobby?room="+ room
const handleCopyClick = () => {
setShow(!show)
if(textAreaRef.current != null){
@ -338,13 +346,14 @@ function Lobby() {
style={{borderColor:theme.colors.secondary}}> - </button>
<input
// type="number"
style={{textAlign:'center'}}
id="numberInput"
disabled
value={ "Nombre de noeuds : " + enteredNumber}
value={enteredNumber}
onChange={handleNumberChange}
min={20}
max={60}/>
<button className='valuebutton' onClick={() => { if (enteredNumber<60) setEnteredNumber(enteredNumber+1)}}
<button className='valuebutton' onClick={() => { if (enteredNumber<50) setEnteredNumber(enteredNumber+1)}}
style={{borderColor:theme.colors.secondary}}> + </button>
</div>
</div>

@ -4,16 +4,16 @@ import { useNavigate } from 'react-router-dom';
import { useAuth } from '../Contexts/AuthContext';
import AuthService from '../services/AuthService';
import '../Style/Global.css';
import { Link } from 'react-router-dom';
import {basePath} from "../AdressSetup"
const SignIn = () => {
const navigate = useNavigate();
const { login } = useAuth();
const [error, setError] = useState<string | null>(null);
const {login} = useAuth();
const [showConfirmation, setShowConfirmation] = useState(false);
const handleSubmit = async (event: React.FormEvent) => {
event.preventDefault();
@ -80,7 +80,7 @@ const SignIn = () => {
</button>
</div>
<p className="forgot-password text-right">
<a href="#">Mot de passe</a> oublié ?
<Link to={`${basePath}/signup`}>Pas encore inscrit ?</Link>
</p>
</form>

@ -110,6 +110,10 @@ function NewPlay() {
else setShowOverlay(true)
}
function launchTuto(){
navigate(`${basePath}/tutorial`);
}
useEffect(() => {
@ -191,20 +195,15 @@ function NewPlay() {
// const returnVisibility: Visibility = goBackRoom !== -1 ? "visible" : "hidden";
const returnVisibility: any= goBackRoom !== -1 ? "visible" : "hidden" ;
const returnVisibility = goBackRoom !== -1 ? "block" : "none" ;
return (
<div className="MainContainer">
<div className="NewleftContainer">
{/* Menu de boutons */}
<div className="leftContainer">
{/* Boutons pour jouer */}
<div className='NewbuttonGroupVertical'>
<button onClick={launchMastermind} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Jouer seul </button>
<button ref={target} onClick={launchEngimeJour} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Résoudre une énigme</button>
<Overlay show={showOverlay} target={target.current} placement="bottom" rootClose={true} rootCloseEvent='click'>
{({ placement, arrowProps, show: _show, popper, ...props }) => (
@ -226,9 +225,10 @@ function NewPlay() {
</Overlay>
<button onClick={createLobby} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Créer une partie </button>
<button onClick= {() => navigate("/join")} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button>
<button onClick={launchTuto} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Tutoriel </button>
{/* <button onClick= {() => navigate("/join")} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button> */}
{/* {goBackRoom != -1 && <button onClick={goBack} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}>Retourner à la partie</button>} */}
<button onClick={goBack} className="ButtonNavRejoin" style={{ visibility:returnVisibility}}>Retourner à la partie</button>
<button onClick={goBack} className="ButtonNavRejoin" style={{ display:returnVisibility}}>Retourner à la partie</button>
</div>
@ -236,21 +236,11 @@ function NewPlay() {
<div style={{border:'solid 1px lightgray', borderRadius:'15px', marginTop:'20px'}}>
<Lobbies/>
</div>
</div>
<div className='NewrightContainer'>
<div style={{ border:'solid 2px lightgray', borderRadius:'15px', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column', padding:'20px', margin:'20px 0px'}}>
<h2>
{user && user.pseudo}
</h2>
<img src={user?.profilePicture}
height='150'
width='150'
alt="Person"
/>
</div>
{user && (<ScoreBoard Player={user}/>)}
</div>
<div className='rightContainer'>
{user && <ScoreBoard Player={user}/>}
</div>
</div>
);
}

@ -1,17 +1,16 @@
.MainContainer{
flex: 1 1 0;
.MainContainer {
display: flex;
flex-direction: row;
justify-content:space-around
justify-content: center;
align-items: center;
height: 100%;
}
.MidContainer{
.MidContainer {
display: flex;
/* justify-content:center; */
align-items:center;
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 15px;
width: 30%;
}
@ -21,20 +20,24 @@
justify-content: center;
}
.leftContainer{
width: 30%;
.leftContainer {
height: 100%;
margin: 20px 30px;
width: 70%;
}
.rightContainer{
.rightContainer {
height: 100%;
margin: 20px 30px;
width: 30%;
}
.NewleftContainer{
.NewleftContainer {
margin: 20px 30px;
width: 70%;
}
.NewrightContainer{
.NewrightContainer {
display: flex;
flex-direction: column;
justify-content: center;
@ -42,81 +45,55 @@
width: 30%;
}
/* .textBoard div{
display: flex;
flex-direction:column-reverse;
justify-content:space-between
} */
/* .textBoard div:nth-child(2){
.buttonGroupVertical {
display: flex;
justify-content: end;
} */
/**Button**/
.buttonGroupVertical{
display: flex;
justify-content:center;
align-items:center;
justify-content: center;
align-items: center;
flex-direction: column;
}
.NewbuttonGroupVertical{
.NewbuttonGroupVertical {
display: flex;
justify-content:space-around;
align-items:start;
flex-direction: row;
justify-content: space-evenly;
}
.ButtonNav{
.ButtonNav {
margin: 15px 10px;
width:200px;
width: 200px;
height: 8vh;
/* background-color: #85C9C2;
color: #2A4541; */
color: white;
border: solid;
border: 2px solid #0056b3;
border-radius: 15px;
border-width: 2px;
font-size:larger;
font-size: larger;
}
.ButtonNavRejoin{
.ButtonNavRejoin {
margin: 15px 10px;
width:200px;
width: 200px;
height: 8vh;
color: white;
background-color: aquamarine;
border: solid 2px rgb(40, 225, 163);
border: 2px solid #0056b3;
border-radius: 15px;
font-size:larger;
font-size: larger;
}
.returnDiv{
.returnDiv {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin:40px 15px;
border: solid 2px whitesmoke;
margin: 40px 15px;
border: 2px solid whitesmoke;
border-radius: 15px;
background-color: white;
}
.returnDiv p {
margin: 15px;
padding: 10px;
border: solid 1px whitesmoke;
border: 1px solid whitesmoke;
border-radius: 10px;
font-weight:500;
}
font-weight: 500;
}

@ -1,6 +1,5 @@
.mainContainer{
display: flex;
/* flex-direction: column; */
justify-content: center;
align-items: center;
margin: 50px;

@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import ProfilePDP from '../Components/ProfilePDP';
import SessionService from '../services/SessionService';
@ -24,20 +24,34 @@ import Modal from 'react-bootstrap/Modal';
import Form from 'react-bootstrap/Form';
import ProgressBar from 'react-bootstrap/ProgressBar';
import {basePath} from "../AdressSetup"
//@ts-ignore
const Profile = () => {
const navigate = useNavigate();
//let player;
const {user, logout} = useAuth()
const [editingUsername, setEditingUsername] = useState(false);
const {isLoggedIn, login, logout, user, setUserData, manager } = useAuth();
const [newUsername, setNewUsername] = useState(user?.pseudo);
//@ts-ignore
useEffect(() => {
if (user == null){
manager.userService.fetchUserInformation().then(([user, loggedIn]) =>{
if (user!=null){
if (loggedIn){
login()
setUserData(user)
}
}
})
}
}, [isLoggedIn]);
const handleLogout = () => {
logout();
navigate(`${basePath}/`);
};
// @ts-ignore
const onUsernameChange = (newUsername) => {
if(user?.pseudo != null){
SessionService.UpdatePseudo(user.pseudo, newUsername)
@ -351,7 +365,10 @@ const Profile = () => {
</Modal>
</>
</div>
</div>
{/* Bouton de déconnexion */}
<div className='logout'>
<Button variant="warning" onClick={handleLogout}>Déconnexion</Button>
</div>
</div>
</>

@ -9,7 +9,6 @@ import {basePath} from "../AdressSetup"
const SignUp = () => {
const navigate = useNavigate();
const [error, setError] = useState<string | null>(null);
const [showConfirmation, setShowConfirmation] = useState(false);

@ -0,0 +1,755 @@
import React, { useState, useEffect } from 'react';
import Switch from "react-switch";
import {saveAs} from "file-saver"
/* Style */
import "./InGame.css"
import {useTheme} from '../Style/ThemeContext'
/* Component */
import GraphContainer from '../Components/GraphContainer';
import PlayerList from '../Components/PlayerList';
import TurnBar from '../Components/TurnBar';
/* Icon */
import Param from "../res/icon/param.png";
import Info from "../res/icon/infoGreen.png";
import Check from "../res/icon/checkboxGreen.png";
import MGlass from "../res/icon/magnifying-glass.png";
import Reset from "../res/icon/reset.png";
import Oeye from "../res/icon/eye.png";
import Ceye from "../res/icon/hidden.png";
import ImgBot from "../res/img/bot.png";
import detective from "../res/img/tuto/tuto-detective.jpg";
import ava from "../res/img/tuto/tuto-ava2.png";
import indicetxt from "../res/img/tuto/tuto-indiceTxt.png"
import rep from "../res/img/tuto/tuto-rep.png";
import joueurs from "../res/img/tuto/tuto-joueurs.png";
import graph from "../res/img/tuto/tuto-graph.png";
import step1 from "../res/img/tuto/tuto2-1.png";
import step2 from "../res/img/tuto/tuto2-2.png";
import step3 from "../res/img/tuto/tuto2-3.png";
import step4 from "../res/img/tuto/tuto2-4.png";
import step5 from "../res/img/tuto/tuto2-5.png";
import step6 from "../res/img/tuto/tuto2-6.png";
/* nav */
import { Link, Navigate, useNavigate, useNavigationType } from 'react-router-dom';
/* Boostrap */
import Offcanvas from 'react-bootstrap/Offcanvas';
import Modal from 'react-bootstrap/Modal';
import Card from 'react-bootstrap/Card';
import Button from 'react-bootstrap/Button';
/* Model */
import Stub from '../model/Stub';
import { useGame } from '../Contexts/GameContext';
import { socket } from '../SocketConfig';
import { Network } from 'vis-network';
import {generateLatexCode, generateLatexCodeEnigme} from '../Script/LatexScript';
import Pair from '../model/Pair';
import Indice from '../model/Indices/Indice';
import {basePath} from "../AdressSetup"
import TutorialGraph from '../Components/TutorialGraph';
import { useAuth } from '../Contexts/AuthContext';
import EasyBot from '../model/EasyBot';
import { set } from 'lodash';
let cptNavigation = 0
//@ts-ignore
const Tutorial = ({locale, changeLocale}) => {
const {personNetwork, person, indices, players, setPlayersData, indice, actualPlayerIndex} = useGame()
const {user} = useAuth()
const theme = useTheme();
const navigate = useNavigate()
const [greyForEveryone, setGreyForEveryone] = useState<() => void>(() => {});
const setGreyForEveryoneData = (func: () => void) => {
setGreyForEveryone(func)
}
const navigationType = useNavigationType()
cptNavigation++
if (cptNavigation % 2 == 0){
if (navigationType.toString() == "POP"){
socket.emit("player quit")
navigate(`${basePath}/`)
}
}
//* Historique
const [history, setHistory] = useState<string[]>([]);
const [showLast, setShowLast] = useState(false)
const [askedWrong, setAskedWrong] = useState(false)
const [importToPdf, setImportToPdf] = useState(false)
const [importToJSON, setImportToJSON] = useState(false)
const [tutoStep, setTutoStep] = useState(0)
const setTutoStepData = (step: number) => {
setTutoStep(step)
}
const setImportToJSONData = (imp: boolean) => {
setImportToJSON(imp)
}
const setImportToPdfData = (imp: boolean) => {
setImportToPdf(imp)
}
// Fonction pour ajouter un élément à l'historique
const addToHistory = (message: string) => {
setHistory(prevHistory => [...prevHistory, message]);
};
const setShowLastData = () =>{
setLastVisible(!showLast);
setShowLast(!showLast);
}
const setAskedWrongData = (askedWrong: boolean) => {
setAskedWrong(askedWrong)
}
useEffect(() => {
const historyContainer = document.getElementById('history-container');
if (historyContainer) {
historyContainer.scrollTop = historyContainer.scrollHeight;
}
}, [history]);
useEffect(() => {
if (user == null){
return
}
setPlayersData([user, new EasyBot("Scooby-Doo", "Scooby-Doo", ImgBot), new EasyBot("Batman", "Batman", ImgBot)])
}, [])
const [showChoiceBar, setShowChoiceBar] = useState(false);
const [showTurnBar, setShowTurnBar] = useState(false);
const [turnBarText, setTurnBarText] = useState("");
const [playerTouched, setPlayerTouched] = useState(-2)
const [playerIndex, setPlayerIndex] = useState(-2)
const [network, setNetwork] = useState<Network | null>(null)
const [networkEnigme, setNetworkEnigme] = useState<Map<number, Pair<Indice, boolean>[]> | null>(null)
const setNetworkData = (network: Network) => {
setNetwork(network)
}
const setNetworkEnigmeData = (networkEnigme: Map<number, Pair<Indice, boolean>[]>) => {
setNetworkEnigme(networkEnigme)
}
const handleNodeClick = (shouldShowChoiceBar: boolean) => {
setShowChoiceBar(shouldShowChoiceBar);
};
const handleSetPlayerTouched = (newPlayerTouched: number) => {
setPlayerTouched(newPlayerTouched);
};
const handleShowTurnBar = (shouldShowTurnBar: boolean) => {
setShowTurnBar(shouldShowTurnBar);
};
const handleTurnBarTextChange = (newTurnBarText: string) =>{
setTurnBarText(newTurnBarText)
}
const setPlayerIndexData = (playerIndex: number) => {
setPlayerIndex(playerIndex)
}
const resetGraph = () => {
setisLoading(true);
socket.emit("reset graph", socket.id)
setTimeout(() => {
setisLoading(false);
}, 2000);
}
/* offcanvas */
//? faire une fonction pour close et show en fonction de l'etat du canva ?
//? comment faire pour eviter la recopie de tout le code a chaque canvas boostrap ?
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
const [showP, setShowP] = useState(false);
const handleCloseP = () => setShowP(false);
const handleShowP = () => setShowP(true);
const [showS, setShowS] = useState(false);
const handleCloseS = () => setShowS(false);
const handleShowS = () => setShowS(true);
const [cptTour, setcptTour] = useState(0);
const [LastVisible, setLastVisible] = useState(false);
const [isLoading, setisLoading] = useState(false);
//@ts-ignore
const changecptTour = (newcptTour) => {
setcptTour(newcptTour);
};
const handleChange = () => {
if (show){
handleClose()
}
else {
handleShow()
}
};
const handleChangeS = () => {
if (showS){
handleCloseS()
}
else {
handleShowS()
}
};
const eye = LastVisible ? Oeye : Ceye; //icon que l'on affiche pour l'oeil : fermé ou ouvert.
/* Windows open */
//@ts-ignore
const openInNewTab = (url) => { //! avec url ==> dangereux
window.open(url);
};
const [SwitchEnabled, setSwitchEnabled] = useState(false)
const allIndices = Stub.GenerateIndice()
const nbPlayer = players.length;
const navdeduc = 'deduc?actualId=' + actualPlayerIndex + '&nbPlayer=' + nbPlayer;
//* gestion demo */
const [showM, setShowM] = useState(false);
const [showTuto2, setShowTuto2] = useState(false);
const [showTuto21, setShowTuto21] = useState(false);
const [showTuto22, setShowTuto22] = useState(false);
const [showTuto3, setShowTuto3] = useState(false);
const handleCloseM = () => {
setShowM(false);
handleShowHelp()
}
const handleShowM = () => setShowM(true);
const handleCloseHelp = () => {
switch(tutoStep){
case 0:
setShowTuto2(false);
break;
case 1:
setShowTuto21(false);
break;
case 2:
setShowTuto22(false);
break;
case 3:
setShowTuto3(false);
break;
}
}
const handleShowHelp = () => {
switch(tutoStep){
case 0:
setShowTuto2(true);
break;
case 1:
setShowTuto21(true);
break;
case 2:
setShowTuto22(true);
break;
case 3:
setShowTuto3(true);
break;
}
}
const handleCloseTuto2 = () => setShowTuto2(false);
const handleShowTuto2 = () => setShowTuto2(true);
const handleCloseTuto21 = () => setShowTuto21(false);
const handleShowTuto21 = () => setShowTuto21(true);
const handleCloseTuto22 = () => setShowTuto22(false);
const handleShowTuto22 = () => setShowTuto22(true);
const handleCloseTuto3 = () => setShowTuto3(false);
const handleShowTuto3 = () => setShowTuto3(true);
const [step, setStep] = useState(-1);
//@ts-ignore
const displayModalstep = (step: number) => {
//* for step 2
setStep(0); // remise a 0 de step
switch(step) {
case 1:
setShowTuto21(true);
break;
case 2:
setShowTuto22(true);
break;
case 3:
setShowTuto3(true);
break;
}
}
useEffect(() => {
handleShowM();
}, [])
return (
<div id="mainDiv">
{showTurnBar && <TurnBar text={turnBarText}/>}
<div id='graphDiv'>
<TutorialGraph tutoStep={tutoStep}
setTutoStep={setTutoStepData}
handleShowTurnBar={handleShowTurnBar}
handleTurnBarTextChange={handleTurnBarTextChange}
addToHistory={addToHistory}
setPlayerTouched={handleSetPlayerTouched}
playerTouched={playerTouched}
setNetwork={setNetworkData}
showLast={showLast}
setPlayerIndex={setPlayerIndexData}
setGreyForEveryone={setGreyForEveryoneData}
displayModalstep={displayModalstep}/>
</div>
<div className='historique' id="history-container">
{history.map((item, index) => (
<div key={index}>{item}</div>
))}
</div>
<div className='menuGame'>
{/* <Button variant="primary" onClick={handleShowM}>
tuto 1
</Button>
<Button variant="primary" onClick={handleShowTuto2} disabled={tuto1disable}>
tuto 2
</Button> */}
<Button variant="primary" onClick={handleShowHelp}>
Aide
</Button>
<Link to={`${basePath}/info`} target='_blank'>
<button className='button'
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}>
<img src={Info} alt="info" height="40"/>
</button>
</Link>
<button className='button' onClick={handleChange}
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}>
<img src={MGlass} alt="indice" height="40"/>
</button>
<button className='button' onClick={setShowLastData}
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}>
<img src={ eye } alt="indice" height="40"/>
</button>
</div>
<div className='playerlistDiv'>
<PlayerList players={players} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} playerIndex={playerIndex} askedWrong={askedWrong} greyForEveryone={greyForEveryone}/>
</div>
<Offcanvas show={show}
onHide={handleClose}
placement='end'
scroll={true}
backdrop={false}
style={{ height: '20%', width: '25%', top: '60vh' }}>
<Offcanvas.Header closeButton>
<Offcanvas.Title>Indice</Offcanvas.Title>
</Offcanvas.Header>
<Offcanvas.Body>
{indice?.ToString(locale)}
</Offcanvas.Body>
</Offcanvas>
<Modal
show={showM}
onHide={handleCloseM}
backdrop="static"
keyboard={false}
size="lg"
style={{ maxHeight: '100vh'}}>
<Modal.Header>
<Modal.Title>Tutoriel</Modal.Title>
</Modal.Header>
<Modal.Body style={{ display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
{step === -1 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={detective} style={{width:'300px', height:'300px'}}/>
<Card.Body>
<Card.Title> Bienvenue dans SocialGraph</Card.Title>
<Card.Text>
Vous incarnez un détective assoiffé de gloire, confronté à un crime. <br/>
Cependant, d'autres enquêteurs sont également sur le coup, tous cherchant à décrocher le titre de meilleur détective du monde. <br/>
Chacun possède un indice crucial pour identifier le coupable, il va falloir déduire l'indice de vos concurrents si vous souhaitez l'emporter ! <br/>
Interrogez vos concurrents pour obtenir des réponses par oui ou non, mais méfiez-vous, un refus a des conséquences. <br/>
Soyez le premier à déduire les indices des autres et à trouver le coupable pour remporter la reconnaissance tant convoitée. <br />
<i>Si vous avez le moindre doute, cliquer sur le bouton "aide" pour afficher l'étape actuel du tuto</i>
</Card.Text>
</Card.Body>
</Card>
)}
{step === 0 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={ava} style={{width:'300px', height:'300px'}}/>
<Card.Body>
<Card.Title>Les Suspects</Card.Title>
<Card.Text>
Voici comment est représenté un suspect, chaque suspect possède différentes caractéristiques, que ce soit leur nom, âge, sport et leur couleur de cheveux.
<br />
Par exemple, ici, nous avons <b>Ava</b>, qui a <b>40 ans</b>, qui pratique du <b>Basket</b> et du <b>Tennis</b>, qui a les cheveux <b>Roux</b> et qui possède <b>2 amis</b> : Carter et Liam.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 1 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={indicetxt} style={{width:'300px', height:'auto'}}/>
<Card.Body>
<Card.Title>Les indices</Card.Title>
<Card.Text>
Dans ce jeu, chaque détective possède un indice, qui permet d'identifier une caractéristique du coupable, votre indice est le suivant :
<br />
"<u>Le suspect a entre 20 et 29 ans</u>".
</Card.Text>
</Card.Body>
</Card>
)}
{step === 3 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={joueurs} style={{width:'auto', height:'300px'}}/>
<Card.Body>
<Card.Title>Les Détectives</Card.Title>
<Card.Text>
Il est possible de voir les détectives sur le côté gauche de l'écran, ils sont représentés par des cercles de couleurs différentes. Le contour carré signifie que ce détective est en pleine réflexion.
<br />
Pour interroger un détective à propos d'un suspect, il suffit de le sélectionner, puis de cliquer sur le suspect que vous souhaitez. Il vous répondra donc ce qu'il pense de ce suspect selon son indice.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 4 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={rep} style={{width:'300px', height:'300px'}}/>
<Card.Body>
<Card.Title>Les réponses</Card.Title>
<Card.Text>
Les détéctives vous répondrons que par des ronds ou des carrés de leur couleur.
<br />
<ul>
<li>
Un <u>carré</u> signifie que son indice innocente le suspect.
</li>
<li>
Un <u>rond</u> signifie que son indice peut incréminer le suspect.
</li>
</ul>
Par exemple, ici :<br />
l'indice du détéctive Scooby-Doo (<u>Vert</u>) permet d'innocenter Logan.
<br/>Eleanor peut être suspectée par l'indice du détective Batman (<u>Jaune</u>).
<br/>Evelyn est innocentée par l'indice de <u>3 détéctive différents</u>.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 5 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Header>
<button className='button'
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}>
<img src={Info} alt="info" height="40"/>
</button>
</Card.Header>
<Card.Body>
<Card.Title>Les règles du jeu</Card.Title>
<Card.Text>
Ce bouton vous mène à la page d'<b>information du jeu</b>, avec toutes les règles du jeu, que ce soit les objectifs, les indices, le déroulement, etc.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 2 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Header>
<button className='button'
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}>
<img src={MGlass} alt="info" height="40"/>
</button>
</Card.Header>
<Card.Body>
<Card.Title>L'indice</Card.Title>
<Card.Text>
Ce bouton vous permet d'afficher votre indice personnel, gardez le secret ! Il s'agit de votre meilleur atout pour gagner.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 6 && (
<Card style={{ width: '90%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={graph} style={{width:'auto', height:'300px'}}/>
<Card.Body>
<Card.Title>Place à la pratique !</Card.Title>
<Card.Text>
Bien joué ! Vous avez maintenanttoutes les bases d'un veritable détéctive.
<br/>
Vous allez à présent avoir un exercice pratique pour la résolution d'une enquête, au côté de ces très chère Batman et Scooby-Doo.
<br/>
Cliquer sur "Poursuivre" pour commencer votre première partie.
</Card.Text>
</Card.Body>
</Card>
)}
</Modal.Body>
<Modal.Footer style={{display:'flex'}}>
<div style={{ width:'100%', display:'flex', justifyContent:'start'}}>
<label style={{ color:'gray'}}>Étape {step+1}/7</label>
</div>
{ step != -1 && (<Button variant="primary" onClick={() => setStep(step - 1)}>Précédent</Button>)}
{ step === 6 ? (<Button variant="primary" onClick={handleCloseM}>Poursuivre</Button>) :
<Button variant="primary" onClick={() => setStep(step + 1)}>Suivant</Button>}
</Modal.Footer>
</Modal>
<Modal
show={showTuto2}
onHide={handleCloseTuto2}
backdrop="static"
keyboard={false}
size="lg"
style={{ maxHeight: '100vh'}}>
<Modal.Header>
<Modal.Title>Tutoriel</Modal.Title>
</Modal.Header>
<Modal.Body style={{ display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card style={{ width: '100%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={step1} style={{width:'auto', height:'300px'}}/>
<Card.Body>
<Card.Title>Premier pas</Card.Title>
<Card.Text>
Bienvenue dans cette seconde partie, où nous allons apprendre le déroulé d'une veritable enquête.
<br/>
Dans un premier temps, sélectionnez le joueur <b>Scooby-Doo</b> et questionnez le à propos du suspect nommé <b>Violet</b> en cliquant sur cette dernière.
</Card.Text>
</Card.Body>
</Card>
</Modal.Body>
<Modal.Footer style={{display:'flex'}}>
<Button variant="primary" onClick={handleCloseTuto2}>Compris !</Button>
</Modal.Footer>
</Modal>
<Modal
show={showTuto21}
onHide={handleCloseTuto21}
backdrop="static"
keyboard={false}
size="lg"
style={{ maxHeight: '100vh'}}>
<Modal.Header>
<Modal.Title>Tutoriel</Modal.Title>
</Modal.Header>
<Modal.Body style={{ display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
{step === 0 && (
<Card style={{ width: '100%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={step2} style={{width:'300px', height:'auto'}}/>
<Card.Body>
<Card.Title>Votre premier tour</Card.Title>
<Card.Text>
Super, <u>Violet a été identifié par l'indice de Scooby-Doo</u>, c'est une information essentielle ! Cependant, cela ne signifie <i>pas forcément</i> qu'elle est coupable.
<br/>
C'est à présent le tour aux autres joueurs de jouer, regardons ce qu'ils ont fait.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 1 && (
<Card style={{ width: '100%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={step3} style={{width:'200px', height:'auto'}}/>
<Card.Body>
<Card.Title>Premier tour des autres joueurs</Card.Title>
<Card.Text>
Il semblerait que Scooby-Doo ait lui aussi interrogé Batman à propos de Violet, et que ce dernier ait répondu <b>non</b> par un carré.
Cela signifie que Violet n'est pas coupable, et qu'elle est donc innocente !
<br/>
Scooby-Doo a donc fait une erreur, en questionnant quelqu'un pouvant innocenter Violet. En guise de <b>punition</b>, il doit, lui aussi, poser un carré sur un autre joueur, révélant aussi plus d'information sur son indice.
Nous savons donc maintenant que l'indice de Scooby-Doo ne permet pas d'identifier Sebastian.
<br/>
Ensuite, Batman a questionné Scooby-Doo à propos de Charlotte, qui est identifié par l'indice de Scooby-Doo.
</Card.Text>
</Card.Body>
</Card>
)}
{step === 2 && (
<Card style={{ width: '100%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={step4} style={{width:'300px', height:'auto'}}/>
<Card.Body>
<Card.Title>Second tour</Card.Title>
<Card.Text>
Vous remarquez que <u>votre indice identifie lui aussi Charlotte</u>, et si nous demandions à Batman, si ce dernier pense que Charlotte est la coupable ?
<br/>
Cela nous permettrait donc de mettre fin à la partie !
</Card.Text>
</Card.Body>
</Card>
)}
</Modal.Body>
<Modal.Footer style={{display:'flex'}}>
<div style={{ width:'100%', display:'flex', justifyContent:'start'}}>
<label style={{ color:'gray'}}>Étape {step+1}/3</label>
</div>
{ step != 0 && (<Button variant="primary" onClick={() => setStep(step - 1)}>Précédent</Button>)}
{ step === 2 ? (<Button variant="primary" onClick={handleCloseTuto21}>Fermer</Button>) :
<Button variant="primary" onClick={() => setStep(step + 1)}>Suivant</Button>}
</Modal.Footer>
</Modal>
<Modal
show={showTuto22}
onHide={handleCloseTuto22}
backdrop="static"
keyboard={false}
size="lg"
style={{ maxHeight: '100vh'}}>
<Modal.Header>
<Modal.Title>Tutoriel</Modal.Title>
</Modal.Header>
<Modal.Body style={{ display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card style={{ width: '100%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={step5} style={{width:'300px', height:'auto'}}/>
<Card.Body>
<Card.Title>La punition</Card.Title>
<Card.Text>
Mince, il semblerait que l'indice de Batman innocente Charlotte, et que vous avez donc commit une erreur, la <b>punition</b> s'applique !
<br/>
Vous devez donc poser un <u>carré sur un autre joueur</u>, révélant ainsi plus d'information sur votre indice.
<br/>
Mais rien n'est joué ! Posons notre carré sur <b>Liam</b> pour cela, sélectionnez directement le suspect désiré.
</Card.Text>
</Card.Body>
</Card>
</Modal.Body>
<Modal.Footer style={{display:'flex'}}>
<Button variant="primary" onClick={handleCloseTuto22}>Compris !</Button>
</Modal.Footer>
</Modal>
<Modal
show={showTuto3}
onHide={handleCloseTuto3}
backdrop="static"
keyboard={false}
size="lg"
style={{ maxHeight: '100vh'}}>
<Modal.Header>
<Modal.Title>End Game</Modal.Title>
</Modal.Header>
<Modal.Body style={{ display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card style={{ width: '100%', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column'}}>
<Card.Img variant="top" src={step6} style={{width:'250px', height:'auto'}}/>
<Card.Body>
<Card.Title>La fin du jeu</Card.Title>
<Card.Text>
Ce tour est lui aussi riche en informations !
<br/>
Vous avez à présent assez d'information pour deviner les indices des autres :
<ul>
<li>
Scooby-Doo semble avoir : <i>{indices[1]?.ToString(locale)}</i>.
</li>
<li>
Batman semble avoir : <i>{indices[2]?.ToString(locale)}</i>.
</li>
<li>
Et votre indice est : <i>{indices[0]?.ToString(locale)}</i>.
</li>
</ul>
Vous avez à présent toutes les cartes en main pour deviner qui est le coupable, cliquer sur le bouton <b>Ask Everyone</b>, puis séléctionné un suspect pour émettre une <b>accusation</b> pour deviner, bonne chance !
</Card.Text>
</Card.Body>
</Card>
</Modal.Body>
<Modal.Footer style={{display:'flex'}}>
<Button variant="primary" onClick={handleCloseTuto3}>Compris !</Button>
</Modal.Footer>
</Modal>
</div>
);
};
export default Tutorial;

@ -76,7 +76,7 @@
"informations" : "Informations",
"info.intro.title":"Introduction au jeu :",
"info.intro.text":"Bienvenue dans notre jeu de déduction captivant, où l'intrigue et la malice se rejoignent dans une aventure palpitante ! Plongez-vous dans un monde de mystère et d'intrigue, où chaque interaction compte, et chaque indice vous rapproche de la vérité.Imaginez un graphique complexe où chaque sommet représente une personne, chaque axe une relation, et chaque détail compte. Vous êtes plongé dans un défi stimulant pour découvrir qui parmi ces individus est le mystérieux tueur. Chaque joueur détient un indice crucial, et seul le partage stratégique de ces indices vous mènera à la résolution du mystère. Explorez notre page de règles pour comprendre les subtilités du jeu, découvrez les indices qui peuvent vous guider, et élaborez des stratégies intelligentes pour identifier le coupable. Manipuler vos amis, afin d'être le premier à découvrir qui est le meurtrier ! Êtes-vous prêt à relever le défi et à démasquer le tueur caché dans le graphe ? Que l'enquête commence !",
"info.intro.text":"Bienvenue dans notre jeu de déduction captivant, où l'intrigue et la malice se rejoignent dans une aventure palpitante ! Plongez-vous dans un monde de mystère et d'intrigue, où chaque interaction compte, et chaque indice vous rapproche de la vérité.Imaginez un graphique complexe où chaque sommet représente une personne, chaque axe une relation, et chaque détail compte. Vous êtes plongé dans un défi stimulant pour découvrir qui parmi ces individus est le mystérieux coupable. Chaque joueur détient un indice crucial, et seul le partage stratégique de ces indices vous mènera à la résolution du mystère. Explorez notre page de règles pour comprendre les subtilités du jeu, découvrez les indices qui peuvent vous guider, et élaborez des stratégies intelligentes pour identifier le coupable. Manipuler vos amis, afin d'être le premier à découvrir qui est le meurtrier ! Êtes-vous prêt à relever le défi et à démasquer le coupable caché dans le graphe ? Que l'enquête commence !",
"info.sommaire":"Sommaire",
@ -122,7 +122,7 @@
"info.objectif.intro":"Bienvenue dans l'univers astucieux de notre jeu de déduction, où la tromperie et la ruse sont les clés du succès. Votre mission est de démêler le mystère qui se cache derrière chaque interaction du graphique complexe représentant les relations entre les individus.",
"info.objectif.t1":"Manipulation Subtile",
"info.objectif.t1.text":"Le but ultime est de découvrir qui parmi les individus est le tueur, mais pas par une collaboration ouverte. Au contraire, vous utiliserez la manipulation subtile pour brouiller les pistes et détourner l'attention de vos adversaires. Posez des questions stratégiques, répondez avec malice, et plantez des indices trompeurs pour vous rapprocher du dénouement.",
"info.objectif.t1.text":"Le but ultime est de découvrir qui parmi les individus est le coupable, mais pas par une collaboration ouverte. Au contraire, vous utiliserez la manipulation subtile pour brouiller les pistes et détourner l'attention de vos adversaires. Posez des questions stratégiques, répondez avec malice, et plantez des indices trompeurs pour vous rapprocher du dénouement.",
"info.objectif.t2":"Jeu de Duperie",
"info.objectif.t2.text":"Chaque tour offre l'opportunité de semer le doute parmi vos adversaires. Lorsqu'un joueur vous interroge, répondez en plaçant habilement un jeton carré pour indiquer que 'selon votre indice, cette personne ne peut être le coupable' ou un jeton rond pour suggérer qu'elle reste dans la liste des suspects. Soyez prudent, car chaque geste peut être interprété, et la vérité est souvent cachée derrière une façade d'indices trompeurs.",
"info.objectif.t3":"Contre-manipulation",
@ -135,7 +135,7 @@
"info.deroulement.e2":"Contre-manipulation et Contre-questions",
"info.deroulement.e2.text":"Si un joueur place un jeton carré, le questionneur doit également poser un jeton carré sur un nœud du graphique. Les contre-questions sont un moyen de semer la confusion parmi les joueurs et de détourner l'accusation.",
"info.deroulement.e3":"Le 'Guess' Final",
"info.deroulement.e3.text":"La partie atteint son apogée lorsqu'un joueur tente le 'Guess' final, affirmant que telle personne est le tueur. Les autres joueurs peuvent alors contredire cette affirmation en plaçant leurs propres jetons carrés. Si aucune réfutation n'est faite, le joueur ayant fait le 'Guess' remporte la partie, démontrant ainsi sa maîtrise dans l'art de la manipulation.",
"info.deroulement.e3.text":"La partie atteint son apogée lorsqu'un joueur tente le 'Guess' final, affirmant que telle personne est le coupable. Les autres joueurs peuvent alors contredire cette affirmation en plaçant leurs propres jetons carrés. Si aucune réfutation n'est faite, le joueur ayant fait le 'Guess' remporte la partie, démontrant ainsi sa maîtrise dans l'art de la manipulation.",
"info.indice-possible.age":"Âge d'une personne",
"info.indice-possible.hair":"Couleur de cheveux d'une personne",

@ -2,6 +2,7 @@ class Edge{
public from: number
public to: number
public color: string = "black"
constructor(from: number, to: number){
this.from = from

@ -2,3 +2,5 @@ declare module "*.png";
declare module "*.svg";
declare module "*.jpeg";
declare module "*.jpg";
declare module '*.mp3';
declare module '*.wav';

@ -0,0 +1,22 @@
{
"names": [
"Sherlock Holmes",
"Inspecteur Gadget",
"Scooby-Doo",
"Marple",
"Spocky",
"Phoenix",
"Batman",
"James Bond",
"Sherlockio",
"Verra",
"Hercule Poirot",
"Colombo",
"MacGyver",
"Lupin",
"D. Conan",
"Pr. Layton",
"Dr. Watson"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -0,0 +1,244 @@
import {ADRESSE_DBSERVER} from '../AdressSetup';
class ScoreboardService {
// ------------------------------ GET ------------------------------
// ----------------------------- DAILY -----------------------------
// ----------------------------- STATS -----------------------------
static async getDailyMastermindStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMastermind', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getDailyEasyEnigmaStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyEasyEnigma', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getDailyMediumEnigmaStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMediumEnigma', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getDailyHardEnigmaStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyHardEnigma', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getDailyOnlineStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyOnline', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
// ------------------------------ GET ------------------------------
// ----------------------------- WEEKLY ----------------------------
// ----------------------------- STATS -----------------------------
static async getWeeklyMastermindStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMastermind', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getWeeklyEasyEnigmaStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyEasyEnigma', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getWeeklyMediumEnigmaStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMediumEnigma', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getWeeklyHardEnigmaStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyHardEnigma', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getWeeklyOnlineStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyOnline', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
}
export default ScoreboardService;

@ -165,7 +165,6 @@ class SessionService {
throw error;
}
}
}
export default SessionService;

@ -0,0 +1 @@
{"persons":[{"id":0,"name":"Charlotte","age":25,"color":2,"sports":[4],"friends":[{"id":4,"name":"Sophia","age":20,"color":4,"sports":[1,3]},{"id":3,"name":"Aurora","age":19,"color":0,"sports":[4,2]},{"id":7,"name":"Violet","age":24,"color":2,"sports":[3]},{"id":5,"name":"Alice","age":68,"color":3,"sports":[0]}]},{"id":1,"name":"Carter","age":20,"color":1,"sports":[1,0],"friends":[{"id":4,"name":"Sophia","age":20,"color":4,"sports":[1,3]},{"id":2,"name":"Ava","age":40,"color":3,"sports":[2,3]}]},{"id":2,"name":"Ava","age":40,"color":3,"sports":[2,3],"friends":[{"id":1,"name":"Carter","age":20,"color":1,"sports":[1,0]},{"id":9,"name":"Liam","age":19,"color":4,"sports":[0]}]},{"id":3,"name":"Aurora","age":19,"color":0,"sports":[4,2],"friends":[{"id":4,"name":"Sophia","age":20,"color":4,"sports":[1,3]},{"id":0,"name":"Charlotte","age":25,"color":2,"sports":[4]},{"id":8,"name":"Sebastian","age":13,"color":0,"sports":[1]},{"id":9,"name":"Liam","age":19,"color":4,"sports":[0]},{"id":6,"name":"Benjamin","age":52,"color":1,"sports":[0,2,4]}]},{"id":4,"name":"Sophia","age":20,"color":4,"sports":[1,3],"friends":[{"id":3,"name":"Aurora","age":19,"color":0,"sports":[4,2]},{"id":0,"name":"Charlotte","age":25,"color":2,"sports":[4]},{"id":1,"name":"Carter","age":20,"color":1,"sports":[1,0]}]},{"id":5,"name":"Alice","age":68,"color":3,"sports":[0],"friends":[{"id":0,"name":"Charlotte","age":25,"color":2,"sports":[4]},{"id":6,"name":"Benjamin","age":52,"color":1,"sports":[0,2,4]}]},{"id":6,"name":"Benjamin","age":52,"color":1,"sports":[0,2,4],"friends":[{"id":3,"name":"Aurora","age":19,"color":0,"sports":[4,2]},{"id":5,"name":"Alice","age":68,"color":3,"sports":[0]}]},{"id":7,"name":"Violet","age":24,"color":2,"sports":[3],"friends":[{"id":0,"name":"Charlotte","age":25,"color":2,"sports":[4]}]},{"id":8,"name":"Sebastian","age":13,"color":0,"sports":[1],"friends":[{"id":3,"name":"Aurora","age":19,"color":0,"sports":[4,2]}]},{"id":9,"name":"Liam","age":19,"color":4,"sports":[0],"friends":[{"id":2,"name":"Ava","age":40,"color":3,"sports":[2,3]},{"id":3,"name":"Aurora","age":19,"color":0,"sports":[4,2]}]}]}

@ -0,0 +1 @@
"[{\"type\":\"AgeIndice\",\"id\":5,\"minimum\":20,\"maximum\":29},{\"type\":\"SportIndice\",\"id\":24,\"sports\":[2,3]},{\"type\":\"ColorEdgesIndice\",\"id\":27,\"neighborsColors\":[0]}]"

@ -8011,6 +8011,11 @@ nth-check@^2.0.1:
dependencies:
boolbase "^1.0.0"
nuka-carousel@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/nuka-carousel/-/nuka-carousel-7.0.0.tgz"
integrity sha512-KE0WV1MuE4Gq6ynL8P3qJH2rGq/DkJ0ej+ezo0IuZp4oklV8WNqu6P6O1utJqihHLGoEuFppq5wlHSHfhdCHXA==
nwsapi@^2.2.0:
version "2.2.7"
resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz"
@ -9186,7 +9191,7 @@ react-dev-utils@^12.0.1:
strip-ansi "^6.0.1"
text-table "^0.2.0"
"react-dom@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", react-dom@^18.0.0, react-dom@^18.2.0, react-dom@>=16.14.0, react-dom@>=16.6.0, react-dom@>=16.8:
"react-dom@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", react-dom@^18.0.0, react-dom@^18.2.0, react-dom@>=16.14.0, react-dom@>=16.6.0, react-dom@>=16.8, react-dom@>=18.0.0:
version "18.2.0"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz"
integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==
@ -9349,7 +9354,7 @@ react-transition-group@^4.4.5:
loose-envify "^1.4.0"
prop-types "^15.6.2"
react@*, "react@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.6.0 || 17 || 18", "react@^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", react@^18.0.0, react@^18.2.0, "react@>= 16", react@>=0.14.0, react@>=15, react@>=15.0.0, react@>=16, react@>=16.14.0, react@>=16.3, react@>=16.6.0, react@>=16.8, react@>=16.8.0:
react@*, "react@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.6.0 || 17 || 18", "react@^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", react@^18.0.0, react@^18.2.0, "react@>= 16", react@>=0.14.0, react@>=15, react@>=15.0.0, react@>=16, react@>=16.14.0, react@>=16.3, react@>=16.6.0, react@>=16.8, react@>=16.8.0, react@>=18.0.0:
version "18.2.0"
resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==

Loading…
Cancel
Save