Merge branch 'master' of https://codefirst.iut.uca.fr/git/Crypteam/Cryptid into Scoreboard 📝

pull/74/head
Pierre Ferreira 1 year ago
commit 8623adf96c

@ -7,7 +7,7 @@ const app = express();
const server = http.createServer(app);
const io = socketIO(server, {
cors: {
origin: ["http://localhost:3000", "http://localhost:3001"], // Remplacez par l'URL de votre application React
origin: ["http://172.20.10.4:3000", "http://localhost:3000"], // Remplacez par l'URL de votre application React
methods: ["GET", "POST"],
credentials: true
}
@ -24,24 +24,31 @@ server.listen(3002, () => {
io.on('connection', (socket) => {
console.log(socket.id);
socket.on('network created', (network, person, indices, room) =>{
io.to(room).emit("game created", network, person, indices, Math.floor(Math.random() * map.get(room).length))
socket.on('network created', (network, person, indices, room, start) =>{
io.to(room).emit("game created", network, person, indices, start)
});
socket.on("lobby joined", (room, name) =>{
socket.on("lobby joined", (room, player) =>{
if (player.type=="Human"){
socket.join(room)
}
if (map.get(room) == undefined){
map.set(room, [{id: socket.id, name: name}])
map.set(room, [{type: player.type, id: socket.id, name: player.name}])
}
else{
const tab = map.get(room)
for(let i = 0; i<tab.length; i++){
if (tab[i].id === socket.id){
if (tab[i].id === socket.id && player.type==="Human"){
tab.splice(i, 1)
}
}
map.get(room).push({id: socket.id, name: name})
if (player.type!=="Human"){
map.get(room).push({type: player.type, id: player.id, name: player.name})
}
else{
map.get(room).push({type: player.type, id: socket.id, name: player.name})
}
}
io.to(room).emit("new player", map.get(room))
@ -55,8 +62,8 @@ io.on('connection', (socket) => {
io.to(askingPlayer.id).emit("already asked", nodeId, askedPlayer)
})
socket.on("ask player", (nodeId, playerId, askingPlayer, askingPlayerIndex) =>{
io.to(playerId).emit("asked", nodeId, askingPlayer, askingPlayerIndex)
socket.on("ask player", (nodeId, playerId, askingPlayer) =>{
io.to(playerId).emit("asked", nodeId, askingPlayer)
})
socket.on("asked all 1by1", (id, playerId) =>{
@ -73,15 +80,30 @@ io.on('connection', (socket) => {
for (let i = 0; i<tab.length; i++){
if (tab[i].id === socket.id){
tab.splice(i, 1)
io.to(k).emit("player left", tab, socket.id)
}
}
}
})
socket.on("node checked", (id, works, color, room, playerIndex) =>{
console.log(playerIndex)
io.to(room).emit("node checked", id, works, color, playerIndex)
io.to(room).emit("node checked", id, works, color, playerIndex, socket.id)
})
socket.on("put correct background", (id) =>{
io.to(id).emit("put correct background")
})
socket.on("put grey background", (id, player) =>{
io.to(id).emit("put grey background", player)
})
socket.on("put imossible grey", (id) =>{
io.to(id).emit("put imossible grey")
})
socket.on("end game", (winnerIndex, room) =>{
console.log("endgame")
io.to(room).emit("end game", winnerIndex)
})
});

@ -29,7 +29,7 @@ const ChoiceBar = () => {
let playerIndex = actualPlayerIndex + 1
if (indiceTester.Works(person)){
socket.emit("node checked", nodeId, true, positionToColor(actualPlayerIndex), room, nextPlayerIndex)
socket.emit("node checked", nodeId, true, actualPlayerIndex, room, nextPlayerIndex)
while(playerIndex != actualPlayerIndex){
if (playerIndex == players.length){
playerIndex = 0
@ -38,7 +38,7 @@ const ChoiceBar = () => {
const works = tester.Works(person)
await delay(500);
socket.emit("asked all 1by1", person.getId(), players[playerIndex].id)
socket.emit("node checked", nodeId, works, positionToColor(playerIndex), room, nextPlayerIndex)
socket.emit("node checked", nodeId, works, playerIndex, room, nextPlayerIndex)
if(!works){
return
}

@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React, { useEffect, useState } from "react";
import { DataSet, Network} from "vis-network/standalone/esm/vis-network";
import EdgesCreator from "../model/EdgesCreator";
import GraphCreator from "../model/Graph/GraphCreator";
@ -16,16 +16,20 @@ import JSONParser from "../JSONParser";
import PersonNetwork from "../model/PersonsNetwork";
import Person from "../model/Person";
import Indice from "../model/Indices/Indice";
import { useLocation } from "react-router-dom";
import { Navigate, useLocation, useNavigate } from "react-router-dom";
import { useGame } from "../Contexts/GameContext";
import { socket } from "../SocketConfig"
import { colorToEmoji, positionToColor } from "../ColorHelper";
import { ColorToHexa } from "../model/EnumExtender";
import Bot from "../model/Bot";
interface MyGraphComponentProps {
onNodeClick: (shouldShowChoiceBar: boolean) => void;
handleShowTurnBar: (shouldShowTurnBar: boolean) => void
handleTurnBarTextChange: (newTurnBarText: string) => void
setPlayerTouched: (newPlayerTouch: number) => void;
playerTouched: number
changecptTour: (newcptTour : number) => void
addToHistory: (message : string) => void
solo : boolean
@ -35,16 +39,45 @@ let lastAskingPlayer = 0
let lastNodeId = -1
let first = true
let askedWrong = false
let solo: boolean = true
let mapIndexPersons: Map<number, Person[]> = new Map<number, Person[]>()
let touchedPlayer = -1
let botIndex = -1
let askedWrongBot = false
let botTurnToCube = false
let lastSocketId= ""
let firstLap = true
let cptHistory = 0
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, addToHistory}) => {
let cptTour: number = 0
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, changecptTour, addToHistory, solo}) => {
const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData } = useGame();
const params = new URLSearchParams(window.location.search);
const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, onlyFalse, setOnlyFalseData } = useGame();
const navigate = useNavigate();
const [lastIndex, setLastIndex] = useState(-1)
const params = new URLSearchParams(window.location.search);
useEffect(() =>{
touchedPlayer=playerTouched
if (touchedPlayer == -1){
if (!askedWrong){
socket.emit("put correct background", socket.id)
}
}
else if (touchedPlayer < players.length && touchedPlayer>=0){
if(!askedWrong){
socket.emit("put correct background", socket.id)
socket.emit("put grey background", socket.id, touchedPlayer)
}
}
else if(touchedPlayer == players.length){
socket.emit("put imossible grey", socket.id)
}
}, [playerTouched])
let firstlap = true;
let playerIndex: number = turnPlayerIndex
let index = 0
for (let i=0; i<players.length; i++){
@ -55,10 +88,109 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
let thisPlayerIndex = index
useEffect(() =>{
if (actualPlayerIndex==0){
const bot = players[lastIndex]
if(bot instanceof Bot && botIndex != lastIndex){
botIndex = lastIndex
if (personNetwork!=null){
const [choosedPlayerIndex, personIndex] = bot.playRound(personNetwork, players)
const person = personNetwork.getPersons().find((p) => p.getId() == personIndex)
if (choosedPlayerIndex == players.length && person != undefined){
console.log(lastIndex + " All in sur => " + personNetwork.getPersons().find((p) => p.getId() == personIndex)?.getName())
let nextPlayerIndex = lastIndex + 1
if (nextPlayerIndex == players.length){
nextPlayerIndex = 0
}
let playerIndex = lastIndex + 1
let i = 0
socket.emit("node checked", personIndex, true, lastIndex, room, lastIndex)
while(playerIndex != lastIndex){
i++
if (playerIndex == players.length){
playerIndex = 0
}
const tester = IndiceTesterFactory.Create(indices[playerIndex])
const works = tester.Works(person)
socket.emit("asked all 1by1", person.getId(), players[playerIndex].id)
if (i==players.length){
socket.emit("node checked", personIndex, works, playerIndex, room, nextPlayerIndex)
}
else{
socket.emit("node checked", personIndex, works, playerIndex, room, lastIndex)
}
if(!works){
socket.emit("node checked", personIndex, works, playerIndex, room, nextPlayerIndex)
return
}
playerIndex ++
}
socket.emit("end game", lastIndex, room)
}
else{
if (person!=undefined){
if (players[choosedPlayerIndex] instanceof Bot){
console.log("BOT")
const tester = IndiceTesterFactory.Create(indices[choosedPlayerIndex])
const works = tester.Works(person)
if (works){
playerIndex = lastIndex + 1
if(playerIndex == players.length){
playerIndex = 0
}
console.log(lastIndex + " interroge " + choosedPlayerIndex + " a propos de " + person.getName() + " et dit oui")
socket.emit("node checked", personIndex, true, choosedPlayerIndex, room, playerIndex)
}
else{
console.log(lastIndex + " interroge " + choosedPlayerIndex + " a propos de " + person.getName() + " et dit non")
socket.emit("node checked", personIndex, false, choosedPlayerIndex, room, lastIndex)
const ind = bot.placeSquare(personNetwork, players)
console.log(lastIndex + " pose carré sur " + personNetwork.getPersons()[ind].getName())
playerIndex = lastIndex + 1
if(playerIndex == players.length){
playerIndex = 0
}
socket.emit("node checked", ind, false, lastIndex, room, playerIndex)
}
}
else{
console.log(choosedPlayerIndex + " => Pas bot" )
socket.emit("ask player", personIndex, players[choosedPlayerIndex].id, players[lastIndex])
console.log(lastIndex + " interroge " + +choosedPlayerIndex + " sur " + personNetwork.getPersons()[personIndex].getName())
const tester = IndiceTesterFactory.Create(indices[choosedPlayerIndex])
if (!tester.Works(person)){
const ind = bot.placeSquare(personNetwork, players)
console.log(lastIndex + " pose carré sur " + personNetwork.getPersons()[ind].getName())
playerIndex = lastIndex + 1
if(playerIndex == players.length){
playerIndex = 0
}
socket.emit("node checked", ind, false, lastIndex, room, playerIndex)
}
}
}
}
}
}
}
}, [lastIndex])
if (first){
first = false
if (!solo){
for(let i = 0; i<indices.length; i++){
mapIndexPersons.set(i, [])
}
if (actualPlayerIndex==0){
players.forEach((p, index) =>{
if (p instanceof Bot && personNetwork!=null){
p.index=index
p.initiateMap(personNetwork)
}
})
}
setActualPlayerIndexData(index)
if (playerIndex == thisPlayerIndex){
handleTurnBarTextChange("À vous de jouer")
@ -104,6 +236,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
const networkData = { nodes: nodes, edges: graph.edges };
const network = new Network(container, networkData, initialOptions);
if (!solo){
socket.on("asked all", (id) =>{
const pers = personNetwork.getPersons().find((p) => p.getId() == id)
@ -112,15 +245,35 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
})
socket.on("node checked",(id, works, color, newPlayerIndex) => {
socket.on("node checked",(id, works, askedIndex, newPlayerIndex, socketId) => {
const node = nodes.get().find((n) => id == n.id)
if (node!=undefined){
onNodeClick(false)
playerIndex = newPlayerIndex
if (!node.label.includes(colorToEmoji(color, works))){
networkData.nodes.update({id: id, label: node.label + colorToEmoji(color, works)})
addToHistory("qq1 à mis un " + colorToEmoji(color, works))
if (mapIndexPersons.get(askedIndex)?.find((p) => p.getId() == id) == undefined){
const p = personNetwork.getPersons().find((p)=> p.getId() == id)
const tab = mapIndexPersons.get(askedIndex)
if (p!=undefined && tab != undefined){
tab.push(p)
if (actualPlayerIndex == 0){
players.forEach((player) => {
if (player instanceof Bot){
player.newInformation(p, askedIndex, works)
}
})
}
}
}
if (!node.label.includes(colorToEmoji(positionToColor(askedIndex), works))){
networkData.nodes.update({id: id, label: node.label + colorToEmoji(positionToColor(askedIndex), works)})
cptHistory++
if (cptHistory % 2 == 0){
addToHistory(players[askedIndex].name + " à mis un " + colorToEmoji(positionToColor(askedIndex), works))
}
}
if (playerIndex === thisPlayerIndex){
handleTurnBarTextChange("À vous de jouer")
handleShowTurnBar(true)
@ -129,8 +282,10 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
handleShowTurnBar(false)
}
}
lastSocketId = socketId
lastAskingPlayer = 0
lastNodeId = -1
setLastIndex(newPlayerIndex)
})
socket.on("already asked", (nodeId, askedPlayer) =>{
@ -138,15 +293,15 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
socket.on("asked wrong", () =>{
setOnlyFalseData(true)
askedWrong = true
askedWrongBot=true
handleShowTurnBar(true)
handleTurnBarTextChange("Mauvais choix, posez un carré !")
socket.emit("put grey background", socket.id, thisPlayerIndex)
})
socket.on("asked", (nodeId, askingPlayer, askingPlayerIndex) => {
console.log(askingPlayerIndex)
socket.on("asked", (nodeId, askingPlayer) => {
if (askingPlayer.id !== lastAskingPlayer || nodeId !== lastNodeId ){
lastAskingPlayer = askingPlayer.id
lastNodeId = nodeId
@ -162,21 +317,31 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
if (node != undefined && indice != null){
var tester = IndiceTesterFactory.Create(indice)
let maybe = thisPlayerIndex
if (tester.Works(pers)){
playerIndex = playerIndex + 1
if(playerIndex == players.length){
playerIndex = 0
}
if (tester.Works(pers)){
socket.emit("node checked", nodeId, true, positionToColor(thisPlayerIndex), room, playerIndex)
socket.emit("node checked", nodeId, true, thisPlayerIndex, room, playerIndex)
}
else{
maybe = maybe - 1
maybe = thisPlayerIndex - 1
if(maybe == 0){
maybe = players.length - 1
}
socket.emit("node checked", nodeId, false, positionToColor(thisPlayerIndex), room, maybe)
let index = players.findIndex((p) => p.id == askingPlayer.id)
if (players[index] instanceof Bot){
index = playerIndex + 1
if(index == players.length){
index = 0
}
}
if (index != undefined){
socket.emit("node checked", nodeId, false, thisPlayerIndex, room, index)
socket.emit("asked wrong", askingPlayer, room)
}
}
}
}
}
@ -185,13 +350,67 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
}
else {
if (firstlap){
if (firstLap){
firstLap=false
addToHistory("<----- [Tour " + 1 +"/"+networkData.nodes.length + "] ----->");
firstlap = false;
}
}
socket.on("put correct background", () =>{
if (personNetwork != null){
for(const person of personNetwork.getPersons()){
networkData.nodes.update({id: person.getId(), color: ColorToHexa(person.getColor())})
}
}
})
socket.on("put grey background", (player) =>{
if (personNetwork != null){
const tab = mapIndexPersons.get(player)
if (tab != undefined){
if (player != thisPlayerIndex){
for(const person of personNetwork.getPersons().filter((p) => tab.includes(p))){
networkData.nodes.update({id: person.getId(), color: "#808080"})
}
}
else if(indice != null){
const tester = IndiceTesterFactory.Create(indice)
for(const person of personNetwork.getPersons().filter((p) => tab.includes(p) || tester.Works(p))){
networkData.nodes.update({id: person.getId(), color: "#808080"})
}
}
}
}
})
socket.on("put imossible grey", ()=>{
if (personNetwork != null && indice!=null){
const tabNodes: any = []
const tester = IndiceTesterFactory.Create(indice)
for (const pers of personNetwork.getPersons()){
const node = nodes.get().find((n) => pers.getId() == n.id)
if (node != undefined){
for(let i=0; i<players.length; i++){
if (node.label.includes(colorToEmoji(positionToColor(i), false)) || !tester.Works(pers)){
tabNodes.push(node)
break
}
}
}
}
for(const n of tabNodes){
networkData.nodes.update({id: n.id, color: "#808080"})
}
}
})
socket.on("end game", (winnerIndex) =>{
setWinnerData(players[winnerIndex])
navigate("/endgame")
})
personNetwork.getPersons().forEach(p => {
@ -234,33 +453,114 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
if(playerIndex == players.length){
playerIndex = 0
}
socket.emit("node checked", params.nodes[0], false, positionToColor(thisPlayerIndex), room, playerIndex)
socket.emit("node checked", params.nodes[0], false, thisPlayerIndex, room, playerIndex)
socket.emit("put correct background", socket.id)
touchedPlayer=-1
askedPersons.push(person)
askedWrong = false
}
}
}
else if (thisPlayerIndex == playerIndex){
onNodeClick(true)
else if(touchedPlayer != -1 && playerIndex == actualPlayerIndex && touchedPlayer<players.length){
botIndex = -1
if (players[touchedPlayer] instanceof Bot){
const ind = indices[touchedPlayer]
const test = IndiceTesterFactory.Create(ind)
const person = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0])
if (person != undefined){
if (test.Works(person)){
let nextPlayerIndex = actualPlayerIndex + 1
if (nextPlayerIndex == players.length){
nextPlayerIndex = 0
}
socket.emit("node checked", params.nodes[0], true, touchedPlayer, room, nextPlayerIndex)
}
else{
onNodeClick(false)
socket.emit("node checked", params.nodes[0], false, touchedPlayer, room, actualPlayerIndex)
socket.emit("asked wrong", players[actualPlayerIndex])
}
}
else{ // si solo -> Mastermind
}
else{
if (touchedPlayer > 0){
console.log(touchedPlayer)
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)
}
touchedPlayer=-1
}
}
else if(playerIndex == actualPlayerIndex && touchedPlayer==players.length){
botIndex = -1
const person = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0])
if (person != undefined){
const indiceTester = IndiceTesterFactory.Create(indices[actualPlayerIndex])
let nextPlayerIndex = actualPlayerIndex + 1
if (nextPlayerIndex == players.length){
nextPlayerIndex = 0
}
let playerIndex = actualPlayerIndex + 1
if (indiceTester.Works(person)){
let i = 0
socket.emit("node checked", params.nodes[0], true, actualPlayerIndex, room, actualPlayerIndex)
while(playerIndex != actualPlayerIndex){
if (playerIndex == players.length){
playerIndex = 0
}
const tester = IndiceTesterFactory.Create(indices[playerIndex])
const works = tester.Works(person)
await delay(500);
socket.emit("asked all 1by1", person.getId(), players[playerIndex].id)
if (works){
socket.emit("node checked", params.nodes[0], true, playerIndex, room, actualPlayerIndex)
}
if(!works){
socket.emit("node checked", params.nodes[0], works, playerIndex, room, nextPlayerIndex)
socket.emit("put correct background", socket.id)
touchedPlayer=-1
return
}
if (i == players.length - 1){
socket.emit("put correct background", socket.id)
await delay(1000)
socket.emit("end game", actualPlayerIndex, room)
return
}
playerIndex ++
i++
}
touchedPlayer=-1
socket.emit("put correct background", socket.id)
await delay(1000)
socket.emit("end game", actualPlayerIndex, room)
}
}
}
}
else{
const person = personNetwork?.getPersons().find((p) => p.getId() == params.nodes[0]) //person sélectionnée
if (person != undefined){
let index = 0;
// indices.forEach(async (i, index) =>{
let index =0
let works = true
for (const i of indices){
const tester = IndiceTesterFactory.Create(i)
const test = tester.Works(person)
const node = nodes.get().find((n) => params.nodes[0] == n.id)
if (node!=undefined){
if (!node.label.includes(colorToEmoji(positionToColor(index), test))){
networkData.nodes.update({id: params.nodes[0], label: node.label + colorToEmoji(positionToColor(index), test)})
await delay(500);
await delay(500)
if(!test){
works = false
}
if (index == indices.length - 1 && works){
navigate("/endgame")
}
}
index ++;
}
index++
}
addToHistory(person.getName() + " n'est pas le tueur !"); //TODO préciser le nombre d'indice qu'il a de juste
@ -276,6 +576,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
else{
// Renvoyer un false pour cacher la choice bar
onNodeClick(false)
setPlayerTouched(-1)
}
});
}, []); // Le tableau vide signifie que cela ne s'exécutera qu'une fois après le premier rendu
@ -286,9 +587,15 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
</>
);
function delay(ms: number) {
function delay(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
function putGreyBackgroud(index: number){
/*
*/
}
}

@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
/* Style */
import '../Style/Global.css'
@ -6,18 +6,48 @@ import { useTheme } from '../Style/ThemeContext';
/* Ressources */
import Person from '../res/img/Person.png'
import leave from '../res/img/bot.png'
import BotImg from '../res/img/bot.png'
import { useGame } from '../Contexts/GameContext';
import Bot from '../model/Bot';
interface PlayerStatusProps {
img: any
state: any
name: string
index: number
setPlayerTouched: (newPlayerTouch: number) => void;
playerTouched: number
showCircle: boolean
}
let touchedPlayer = -1
//@ts-ignore
function PersonStatus({img = Person, state= Person, name = "Dummy"}) {
const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle}) => {
const theme=useTheme();
const {players} = useGame()
if (players[index] instanceof Bot){
img = BotImg
}
const [touchedPlayer, setTouchedPlayer] = useState(-2)
useEffect(() =>{
setTouchedPlayer(playerTouched)
}, [playerTouched])
return (
<div className='centerDivV'>
<img src={img} alt="player" height="100" width="100"/>
<h4>{name}</h4>
<div className='centerDivV' onClick={() => setPlayerTouched(index)}>
<img src={img} alt="player" height="60" width="60"/>
<h5>{name}</h5>
{(touchedPlayer == index && showCircle) ?(
<div className='statusDiv' style={{ backgroundColor: "gold" }}>
<img src={state} alt="state" height="30" width="30"/>
</div>
): showCircle &&
(
<div className='statusDiv' style={{ backgroundColor: theme.colors.primary }}>
<img src={state} alt="state" height="30" width="30"/>
</div>
) }
</div>
);
}

@ -1,19 +1,66 @@
import React from 'react';
import { colorToEmoji, positionToColor } from '../ColorHelper';
import Player from '../model/Player';
import { useTheme } from '../Style/ThemeContext';
import PersonStatus from './PersonStatus';
import Person from '../res/img/Person.png'
import { socket } from '../SocketConfig';
//@ts-ignore
function PlayerList({ players }) {
interface PlayerListProps {
players: Player[];
playerTouched: number
setPlayerTouched: (newPlayerTouch: number) => void;
}
const PlayerList: React.FC<PlayerListProps> = ({ players, playerTouched, setPlayerTouched}) => {
const theme = useTheme();
return (
<div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px' }}>
{
//@ts-ignore
players.map((player, index) => (
<PersonStatus key={index} state={player.state} name={player.name + " " + colorToEmoji(positionToColor(index), true)} />
player.id!=socket.id && <PersonStatus img={Person} state={Person} key={index} name={player.name + " " + colorToEmoji(positionToColor(index), true)} playerTouched={playerTouched} setPlayerTouched={setPlayerTouched} index={index} showCircle={true}/>
))
}
</div>
<div
style={{display: 'flex',
justifyContent: "center",
alignSelf: "center",
alignItems:"center",
margin: 10
}}>
{(playerTouched == players.length)
?(
<button style={{
backgroundColor: "gold",
borderColor: theme.colors.secondary,
borderRadius: "10px",
border: "solid 1px",
textAlign: "center",
padding: "10px"}}
onClick={() => setPlayerTouched(players.length)}>Ask everyone</button>
):
(
<button style={{
backgroundColor: theme.colors.primary,
borderColor: theme.colors.secondary,
borderRadius: "10px",
border: "solid 1px",
textAlign: "center",
padding: "10px"}}
onClick={() => setPlayerTouched(players.length)}>Ask everyone</button>
)
}
</div>
</div>
);
}

@ -16,6 +16,7 @@ interface GameContextProps {
turnPlayerIndex: number;
room: string;
onlyFalse: boolean
winner: Player | null
setIndicesData: (newIndices: Indice[]) => void;
setIndiceData: (newIndice: Indice) => void;
setPersonData: (newPerson: Person) => void;
@ -27,6 +28,7 @@ interface GameContextProps {
setTurnPlayerIndexData: (newTurnPlayerIndex: number) => void;
setRoomData: (newRoom: string) => void;
setOnlyFalseData: (newOnlyFalse: boolean) => void
setWinnerData: (winner: Player) => void
}
const GameContext = createContext<GameContextProps | undefined>(undefined);
@ -47,6 +49,7 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
const [turnPlayerIndex, setTurnPlayerIndex] = useState<number>(-1)
const [room, setRoom] = useState<string>("")
const [onlyFalse, setOnlyFalse] = useState<boolean>(false)
const [winner, setWinner] = useState<Player | null>(null)
const setIndicesData = (newIndices: Indice[]) => {
@ -94,8 +97,12 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
setOnlyFalse(newOnlyFalse)
}
const setWinnerData = (winner: Player) =>{
setWinner(winner)
}
return (
<GameContext.Provider value={{ indices, setIndicesData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, nodeId, setNodeIdData, askedPersons, setAskedPersonsData, actualPlayerIndex, setActualPlayerIndexData, turnPlayerIndex, setTurnPlayerIndexData, room, setRoomData, onlyFalse, setOnlyFalseData }}>
<GameContext.Provider value={{ indices, setIndicesData, indice, setIndiceData, person, setPersonData, personNetwork, setPersonNetworkData, players, setPlayersData, nodeId, setNodeIdData, askedPersons, setAskedPersonsData, actualPlayerIndex, setActualPlayerIndexData, turnPlayerIndex, setTurnPlayerIndexData, room, setRoomData, onlyFalse, setOnlyFalseData, winner, setWinnerData }}>
{children}
</GameContext.Provider>
);

@ -1,3 +1,5 @@
import EasyBot from "./model/EasyBot";
import Human from "./model/Human";
import AgeIndice from "./model/Indices/AgeIndice";
import ColorEdgesIndice from "./model/Indices/ColorEdgesIndice";
import ColorIndice from "./model/Indices/ColorIndice";
@ -7,6 +9,7 @@ import NbSportIndice from "./model/Indices/NbSportIndice";
import SportIndice from "./model/Indices/SportIndice";
import Person from "./model/Person";
import PersonNetwork from "./model/PersonsNetwork";
import Player from "./model/Player";
class JSONParser{
@ -78,6 +81,17 @@ class JSONParser{
});
return tabIndice
}
static JSONToPlayer(json: any): Player{
switch (json.type){
case "Human":
return new Human(json.id, json.name)
case "EasyBot":
return new EasyBot(json.id, json.name)
default:
throw new Error("PARSER unable to parse player: " + json.type);
}
}
}
export default JSONParser

@ -32,3 +32,11 @@
flex-direction: column;
align-items: center;
}
.playerContainer {
display: flex;
flex-direction: column;
align-items: center;
padding-left: "5px";
}

@ -21,31 +21,45 @@ import { Link } from 'react-router-dom';
/* lang */
import { FormattedMessage } from 'react-intl';
import { useGame } from '../Contexts/GameContext';
function EndGame() {
const {winner, person, players, indices} =useGame()
console.log(winner)
const theme = useTheme();
return (
<div>
<div className="head">
<header className='leaderboard-header' style={{ borderColor: theme.colors.primary }}>
<h1>Dummy a gagné !</h1>
<h3>Le tueur était <u>Bob</u></h3>
<h1>{winner?.name} a gagné !</h1>
<h3>Le tueur était <u>{person?.getName()}</u></h3>
</header>
</div>
<div className='winner'>
<img src={Person} width='300' height='300'/>
<h3>{indices[players.findIndex((p) => p.id == winner?.id)].ToString("fr")}</h3>
</div>
<div className='bottom'>
<div className='centerDivH'>
<BigButtonNav dest="/play" img={Leave}/>
</div>
<div className='centerDivH'>
<PersonStatus state={Replay} name="Dummy"/>
<PersonStatus state={Leave} name="bot2"/>
<PersonStatus state={Leave} name="bot3"/>
<ul className='centerDivH'>
{
players.map((player, index) => (
<div className="playerContainer">
{player.id!=winner?.id &&
<>
<PersonStatus img={Person} state={Person} key={index} name={player.name} playerTouched={1} setPlayerTouched={() => {}} index={index} showCircle={false}/>
<h5 style={{width: 50}}>{indices[players.findIndex((p) => p.id == player?.id)].ToString("fr")}</h5>
</>
}
</div>
))
}
</ul>
<div className='centerDivH'>
<BigButtonNav dest="/lobby" img={Replay}/>
</div>

@ -74,11 +74,16 @@ const InGame = ({locale, changeLocale}) => {
const [showChoiceBar, setShowChoiceBar] = useState(false);
const [showTurnBar, setShowTurnBar] = useState(false);
const [turnBarText, setTurnBarText] = useState("");
const [playerTouched, setPlayerTouched] = useState(-2)
const handleNodeClick = (shouldShowChoiceBar: boolean) => {
setShowChoiceBar(shouldShowChoiceBar);
};
const handleSetPlayerTouched = (newPlayerTouched: number) => {
setPlayerTouched(newPlayerTouched);
};
const handleShowTurnBar = (shouldShowTurnBar: boolean) => {
setShowTurnBar(shouldShowTurnBar);
@ -157,29 +162,19 @@ const InGame = ({locale, changeLocale}) => {
handleTurnBarTextChange={handleTurnBarTextChange}
changecptTour={changecptTour}
addToHistory={addToHistory}
solo={IsSolo} />
solo={IsSolo}
setPlayerTouched={handleSetPlayerTouched}
playerTouched={playerTouched}/>
</div>
{IsSolo ? (
{IsSolo &&
<div className='nbLaps' style={{
backgroundColor: theme.colors.tertiary,
backgroundColor: theme.colors.primary,
borderColor: theme.colors.secondary
}}>
Coups : {cptTour}
Tour : {cptTour}
</div>
) : (
<div className='playerlistDiv'>
<button className='button'
style={{
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}
onClick={handleChangeP}>
Players
</button>
</div>
)
}
@ -236,6 +231,7 @@ const InGame = ({locale, changeLocale}) => {
</button>
</div>
{/*
<Offcanvas show={showP}
onHide={handleCloseP}>
<Offcanvas.Header closeButton>
@ -243,15 +239,14 @@ const InGame = ({locale, changeLocale}) => {
<h3>Il y a {players.length} joueurs</h3>
</Offcanvas.Header>
<Offcanvas.Body>
{/* affichage d'une liste responsive dynamic */}
{/* <div className='playerCanvasBody'>
<PersonStatus state={Replay} name="Dummy"/>
<PersonStatus state={Replay} name="Boat"/>
<PersonStatus state={Replay} name="Bot-tom"/>
</div> */}
<PlayerList players={players} />
</Offcanvas.Body>
</Offcanvas>
*/}
<div className='playerlistDiv'>
<PlayerList players={players} setPlayerTouched={handleSetPlayerTouched} playerTouched={playerTouched} />
</div>
<Offcanvas show={show}
onHide={handleClose}

@ -11,6 +11,7 @@
padding: 20px;
margin-right: 10px;
margin-left: 30px;
}
.lobby-vertical-divider{
@ -54,3 +55,8 @@
font-size: 20px;
cursor: pointer;
}
.centerButton {
display: flex;
justify-content: center;
}

@ -5,7 +5,6 @@ import { useTheme } from '../Style/ThemeContext';
/* res */
import PlayerItemList from '../Components/PlayerItemList'
import PersonImg from '../res/img/Person.png';
import Bot from '../res/img/bot.png';
import param from '../res/icon/param.png';
import cible from '../res/icon/cible.png';
@ -23,8 +22,12 @@ import { useNavigate } from 'react-router-dom';
import { socket } from "../SocketConfig";
import { random } from 'lodash';
import Player from '../model/Player';
import Human from '../model/Human';
import EasyBot from '../model/EasyBot';
import Bot from '../model/Bot';
let gameStarted = false
function Lobby() {
const theme=useTheme();
@ -38,49 +41,76 @@ function Lobby() {
const params = new URLSearchParams(window.location.search);
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())
}
useEffect(() => {
if (first){
first=false
socket.emit("lobby joined", room, "test name" + Math.floor(Math.random() * 10))
socket.emit("lobby joined", room, new Human("test", "Test" + Math.floor(Math.random() * 100)).toJson())
return () => {
socket.off('game created');
};
}
}, []);
}, [socket.id]);
socket.on("game created", (jsonNetwork, jsonPersonString, jsonIndicesString, playerIndex)=> {
const jsonPerson = JSON.parse(jsonPersonString)
const network: PersonNetwork = JSONParser.JSONToNetwork(jsonNetwork)
const choosenOne: Person = network.getPersons().filter((i) => i.getId() == jsonPerson.id)[0]
const choosenIndices : Indice[] = JSONParser.JSONToIndices(jsonIndicesString)
let index = 0
for (let i=0; i<players.length; i++){
if(players[i].id == socket.id){
index=i
break
const player = players[i]
if(player.id == socket.id){
setActualPlayerIndexData(i)
setIndiceData(choosenIndices[i])
}
if (player instanceof Bot){
player.indice = choosenIndices[i]
}
}
if (room != null){
setRoomData(room)
}
setTurnPlayerIndexData(playerIndex)
setActualPlayerIndexData(index)
setIndiceData(choosenIndices[index])
setPersonData(choosenOne)
setPersonNetworkData(network)
setIndicesData(choosenIndices)
first = true
gameStarted = true
navigate('/game?solo=false');
});
socket.on("new player", (tab) =>{
const tmpTab: Player[] = []
for (const p of tab){
tmpTab.push(new Player(p.id, p.name))
tmpTab.push(JSONParser.JSONToPlayer(p))
}
setPlayersData(tmpTab)
})
socket.on("player left", (tab, socketId) => {
if (gameStarted){
const i = players.findIndex((p) => p.id == socketId)
if (i != undefined){
let player = players[i]
player = new EasyBot("125", "BOT125")
if (player instanceof Bot){
player.indice = indices[i]
}
}
}
else{
const tmpTab: Player[] = []
for (const p of tab){
tmpTab.push(JSONParser.JSONToPlayer(p))
}
setPlayersData(tab.map((p: any) => new Player(p.id, p.name)))
setPlayersData(tmpTab)
}
const index = players
})
const [codeShowed, setCodeShowed] = useState(true);
@ -91,7 +121,8 @@ function Lobby() {
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)
socket.emit('network created', JSON.stringify(networkPerson, null, 2), JSON.stringify(choosenPerson), JSON.stringify(choosenIndices), room);
let start = 0
socket.emit('network created', JSON.stringify(networkPerson, null, 2), JSON.stringify(choosenPerson), JSON.stringify(choosenIndices), room, start);
}
return (
@ -111,6 +142,14 @@ function Lobby() {
{players.map((player, index) => (
<PlayerItemList key={player.id} pdp={PersonImg} name={player.name} id={player.id}/>
))}
<div className='centerButton'>
<button className='button' onClick={addBot}
style={{
backgroundColor: theme.colors.primary,
borderColor: theme.colors.secondary}}>
+
</button>
</div>
</div>
</div>

@ -38,7 +38,7 @@ function Play() {
}
function launchMastermind(){
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(5, 30)
const [networkPerson, choosenPerson, choosenIndices] = GameCreator.CreateGame(3, 30)
setPersonData(choosenPerson)
setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices)

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

@ -1,7 +1,7 @@
// theme.js
const theme = {
colors: {
primary: '#0064E0',
primary: '#7AA3F4',
secondary: '#0052B8',
tertiary: '#7aa3f4', //* Pour les boutons de l'interface.
text: '#fff'

@ -55,11 +55,11 @@
"color_start": "The suspect has",
"color_end": "hair",
"nb_friends_indice_start": "The suspect has at least",
"nb_friends_indice_start": "The suspect has",
"nb_friends_indice_end": "friends",
"nb_sports_indice_start": "The suspect is playing",
"nb_sports_indice_end": "sport",
"nb_sports_indice_end": "sport(s)",
"sport_start": "The suspect plays at least",
"sport_end": "",

@ -54,7 +54,7 @@
"color_start": "Le suspect a les cheveux",
"color_end": "",
"nb_friends_indice_start": "Le suspect a au moins",
"nb_friends_indice_start": "Le suspect",
"nb_friends_indice_end": "amis",
"nb_sports_indice_start": "Le suspect pratique",

@ -0,0 +1,32 @@
import { DataSet } from "vis-network";
import NodePerson from "./Graph/NodePerson";
import Indice from "./Indices/Indice";
import Pair from "./Pair";
import Person from "./Person";
import PersonNetwork from "./PersonsNetwork";
import Player from "./Player";
abstract class Bot extends Player{
public indice: Indice | undefined
public index : number
public actualNetwork: Map<Person, Pair<number, boolean>[]>
constructor( id: string, name: string){
super(id, name);
this.actualNetwork = new Map<Person, Pair<number, boolean>[]>()
this.index = -1
}
abstract playRound(personNetwork : PersonNetwork, players: Player[]): [number, number]
abstract placeSquare(personNetwork : PersonNetwork, players: Player[]): number
abstract newInformation(person: Person, playerIndex: number, works: boolean): void
abstract initiateMap(personNetwork: PersonNetwork): void
}
export default Bot

@ -0,0 +1,110 @@
import { DataSet } from "vis-network";
import { colorToEmoji, positionToColor } from "../ColorHelper";
import Bot from "./Bot";
import IndiceTesterFactory from "./Factory/IndiceTesterFactory";
import NodePerson from "./Graph/NodePerson";
import Indice from "./Indices/Indice";
import Pair from "./Pair";
import Person from "./Person";
import PersonNetwork from "./PersonsNetwork";
import Player from "./Player";
class EasyBot extends Bot{
constructor(id: string, name: string){
super(id, name)
}
toJson() {
return {
type: "EasyBot",
id: this.id,
name: this.name,
};
}
playRound(personNetwork: PersonNetwork, players: Player[]): [number, number] {
if (this.indice==undefined){
return [-1, -1]
}
let rand = Math.random()
const filterPlayers = players.filter((p) => p.id != this.id)
if (rand < 0.75){
const possibleCombinaison = new Map<number, number[]>()
filterPlayers.forEach((p, index) =>{
possibleCombinaison.set(index, [])
})
personNetwork.getPersons().forEach((p) =>{
players.forEach((player, index) =>{
if (index!=this.index && (!this.actualNetwork.get(p)?.includes(new Pair(index, true) || !this.actualNetwork.get(p)?.includes(new Pair(index, false))))){
const t = possibleCombinaison.get(index)
if( t==undefined){
possibleCombinaison.set(index, [p.getId()])
}
else{
t.push(p.getId())
}
}
})
})
let r = this.index
while(r==this.index){
r = Math.floor(Math.random() * players.length)
}
const tab = possibleCombinaison.get(r)
if (tab!= undefined){
const randIndex = Math.floor(Math.random() * tab.length)
const tester = IndiceTesterFactory.Create(this.indice)
const pers = personNetwork.getPersons().find((p) => p.getId() == tab[randIndex])
if (pers != undefined)
return [r, tab[randIndex]]
}
}
else{
const filterNodes = []
const possibleNodes: number[] = []
const indiceTester=IndiceTesterFactory.Create(this.indice)
personNetwork.getPersons().forEach((p) => {
let works = true
for(let i = 0; i<players.length; i++){
if (!indiceTester.Works(p) || this.actualNetwork.get(p)?.includes(new Pair(i, false))){
works = false
}
}
if (works){
possibleNodes.push(p.getId())
}
});
const index = possibleNodes[Math.floor(Math.random() * possibleNodes.length)]
return [players.length, index]
}
return [-1, -1]
}
placeSquare(personNetwork: PersonNetwork, players: Player[]): number {
const tabFilterPerson: Person[] = []
if (this.indice == undefined){
return -1
}
const indiceTester = IndiceTesterFactory.Create(this.indice)
personNetwork.getPersons().forEach((p) =>{
const tab = this.actualNetwork.get(p)
if (!indiceTester.Works(p) && (!tab?.includes(new Pair(this.index, true) || !tab?.includes(new Pair(this.index, false))))){
tabFilterPerson.push(p)
}
})
return tabFilterPerson[Math.floor(Math.random() * tabFilterPerson.length)].getId()
}
newInformation(person: Person, playerIndex: number, works: boolean): void {
this.actualNetwork.get(person)?.push(new Pair(playerIndex, works))
}
initiateMap(personNetwork: PersonNetwork): void {
personNetwork.getPersons().forEach((p) =>{
this.actualNetwork.set(p, [])
})
}
}
export default EasyBot

@ -11,9 +11,8 @@ class EdgesCreator{
CreateWorkingEdge(personNetwork: PersonNetwork, choosenPerson: Person, indice: Indice, indices: Indice[]){
let creator = IndiceEdgesFactory.Create(indice)
const nbMaxEdge = Math.floor(Math.random() * 5) + 1
creator.createWorkingEdges(personNetwork, choosenPerson, indices)
const nbMaxEdge = creator.createWorkingEdges(personNetwork, choosenPerson, indices)
if (choosenPerson.getFriends().length < nbMaxEdge){
for (const p of personNetwork.getPersons()){

@ -11,7 +11,7 @@ class GraphCreator{
const nodesPerson : NodePerson[] = []
const edges: Edge[] = []
network.getPersons().forEach((p) =>{
let label = p.getName() + "\n" + p.getAge() + "\n"
let label = p.getName() + "\n" + p.getAge() + "🎂" + "\n"
for (let i = 0; i<p.getSports().length; i++){
label += SportToIcon(p.getSports()[i])
}

@ -0,0 +1,18 @@
import Player from "./Player";
class Human extends Player{
constructor(id: string, name: string){
super(id, name)
}
toJson() {
return {
type: "Human",
id: this.id,
name: this.name,
};
}
}
export default Human

@ -40,7 +40,7 @@ class ColorIndiceEdgesCreator implements IndiceEdgesCreator{
if (testEdgeWork < indices.length){
p.addFriend(person)
person.addFriend(p)
return 1
return Math.floor(Math.random() * 4)
}
}
}

@ -18,7 +18,7 @@ class NbEdgesIndiceEdgesCreator implements IndiceEdgesCreator{
createWorkingEdges(personNetwork: PersonNetwork, person: Person, indices: Indice[]): number {
let indiceTest = new NbEdgesIndiceTester(this.indice)
const nbEdges = this.indice.getNbEdges() + Math.floor(Math.random() * 2)
const nbEdges = this.indice.getNbEdges()
personNetwork.getPersons().forEach(p => {
if (person.getFriends().length == nbEdges){
return

@ -12,7 +12,7 @@ class NbEdgesIndiceTester implements IndiceTester{
}
Works(person: Person): boolean {
return person.getFriends().length >= this.nbEdgesIndice.getNbEdges()
return person.getFriends().length == this.nbEdgesIndice.getNbEdges()
}
}

@ -13,7 +13,7 @@ class NbSportIndiceTester implements IndiceTester{
}
Works(person: Person): boolean {
return this.nbSportIndice.getNbSport() == person.getSports().length
return this.nbSportIndice.getNbSport().includes(person.getSports().length)
}
}

@ -2,21 +2,30 @@ import { GetJsonFile } from "../EnumExtender";
import Indice from "./Indice";
class NbSportIndice extends Indice {
private nbSport: number;
private nbSport: number[];
constructor(id: number, nbSport: number) {
constructor(id: number, nbSport: number[]) {
super(id);
this.nbSport = nbSport;
}
public getNbSport(): number{
public getNbSport(): number[]{
return this.nbSport
}
// Implémentation de la méthode abstraite
ToString(lang: string): string {
let json = GetJsonFile(lang)
return `${json.nb_sports_indice_start} ${this.nbSport} ${json.nb_sports_indice_end}`;
let string = `${json.nb_sports_indice_start}`;
this.nbSport.forEach((i, index) =>{
if (index == this.nbSport.length - 1){
string += i
}
else{
string += ` ${i} ${json.or} `
}
})
return string + ` ${json.nb_sports_indice_end}`
}
toJSON() {

@ -7,36 +7,40 @@ class NetworkGenerator{
static GenerateNetwork(nbPerson: number): PersonNetwork{
let json = require("../res/names.json")
const tabSports: Sport[] = [0, 1, 2, 3, 4, 5, 5, 5, 5]
const tabSports: Sport[] = [0, 1, 2, 3, 4, 5, 5, 5]
const tabColor: Color[] = [0, 1, 2, 3, 4]
const tabJeune: number[] = []
const tabAdo: number[] = []
const tabAdulte: number[] = []
const tabVieux: number[] = []
const tabTresVieux: number[] = []
const tabPerson: Person[] = []
const tabNames = json.names
/*
let id = 0
for(let i = 0; i < nbPerson/4; i++){
for(let i = 0; i < nbPerson/5; i++){
const nombreAleatoire = Math.floor(Math.random() * 14) + 1;
tabJeune.push(nombreAleatoire)
}
for(let i = 0; i < nbPerson/4; i++){
const nombreAleatoire = Math.floor(Math.random() * 5) + 15;
*/
for(let i = 0; i < nbPerson/3; i++){
const nombreAleatoire = Math.floor(Math.random() * 9) + 12;
tabAdo.push(nombreAleatoire)
}
for(let i = 0; i < nbPerson/4; i++){
for(let i = 0; i < nbPerson/3; i++){
const nombreAleatoire = Math.floor(Math.random() * 10) + 20;
tabAdulte.push(nombreAleatoire)
}
for(let i = 0; i < nbPerson/4; i++){
const nombreAleatoire = Math.floor(Math.random() * 31) + 30;
for(let i = 0; i < nbPerson/3; i++){
const nombreAleatoire = Math.floor(Math.random() * 30) + 30;
tabVieux.push(nombreAleatoire)
}
const tabAge: number[][] = [tabJeune, tabAdo, tabAdulte, tabVieux]
const tabAge: number[][] = [tabAdo, tabAdulte, tabVieux]
let tmpTabSport=[...tabSports]
let tmpTabColor = [...tabColor]

@ -0,0 +1,15 @@
class Pair<T1, T2>{
public first: T1
public second: T2
constructor(first: T1, second: T2){
this.first=first
this.second=second
}
equals(other: Pair<T1, T2>): boolean {
return this.first === other.first && this.second === other.second;
}
}
export default Pair

@ -1,5 +1,4 @@
class Player{
abstract class Player{
public id: string
public name: string;
@ -7,6 +6,8 @@ class Player{
this.id=id
this.name=name
}
abstract toJson(): any
}
export default Player

@ -13,14 +13,15 @@ class Stub{
static GenerateIndice(): Indice[]{
let indice = new NbEdgesIndice(1, 2)
let indice1 = new NbEdgesIndice(2, 3)
let ageIndice = new AgeIndice(3, 0, 14)
let ageIndice1 = new AgeIndice(4, 15, 19)
let ageIndice2 = new AgeIndice(5, 20, 29)
let ageIndice3 = new AgeIndice(6, 30, 100000)
let indice2 = new NbEdgesIndice(3, 4)
let ageIndice = new AgeIndice(4, 0, 14)
let ageIndice1 = new AgeIndice(5, 15, 19)
let ageIndice2 = new AgeIndice(6, 20, 29)
let ageIndice3 = new AgeIndice(7, 30, 100000)
let indices: Indice[] = [indice, indice1, ageIndice, ageIndice1, ageIndice2, ageIndice3]
let indices: Indice[] = [indice, indice1, indice2, ageIndice, ageIndice1, ageIndice2, ageIndice3]
let test = 7
let test = 8
for (let i: Color=0; i<5; i++){
for (let j: Color=0; j<5; j++){
if (j==i){
@ -49,9 +50,15 @@ class Stub{
//* Nombre de sport
for (let i=1; i<3; i++){
indices.push(new NbSportIndice(test, i))
for (let j=0; j<3; j++){
if (j==i){
continue
}
indices.push(new NbSportIndice(test, [i, j]))
test++
}
}
return indices
}
}

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