petites modifs qui font plaisir

pull/92/head
Thomas Chazot 1 year ago
parent 28935fe77d
commit 5f57189eaf

@ -53,4 +53,41 @@ function colorToEmoji(color: string, works: boolean): string{
}
}
export {colorToEmoji, positionToColor}
function positionToEmoji(pos: number, works: boolean): string{
if (works){
switch (pos) {
case 0:
return "🔵";
case 1:
return "🟢";
case 2:
return "🟡";
case 3:
return "🟣";
case 4:
return "🔴";
default:
return "🟤";
}
}
else{
switch (pos) {
case 0:
return "🟦";
case 1:
return "🟩";
case 2:
return "🟨";
case 3:
return "🟪";
case 4:
return "🟥";
default:
return "🟫";
}
}
}
export {colorToEmoji, positionToColor, positionToEmoji}

@ -7,7 +7,7 @@ import Person from "../model/Person";
import { Navigate, useLocation, useNavigate } from "react-router-dom";
import { useGame } from "../Contexts/GameContext";
import { socket } from "../SocketConfig"
import { colorToEmoji, positionToColor } from "../ColorHelper";
import { colorToEmoji, positionToColor, positionToEmoji } from "../ColorHelper";
import { ColorToHexa } from "../model/EnumExtender";
import Bot from "../model/Bot";
import NodePerson from "../model/Graph/NodePerson";
@ -30,12 +30,10 @@ 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
@ -97,7 +95,6 @@ let cptTour: number = 0
break
}
}
let thisPlayerIndex = index
useEffect(() =>{
if (actualPlayerIndex==0){
@ -197,6 +194,7 @@ let cptTour: number = 0
if (first){
first = false
if (!solo){
for(let i = 0; i<indices.length; i++){
mapIndexPersons.set(i, [])
@ -210,7 +208,7 @@ let cptTour: number = 0
})
}
setActualPlayerIndexData(index)
if (playerIndex == thisPlayerIndex){
if (playerIndex == actualPlayerIndex){
handleTurnBarTextChange("À vous de jouer")
handleShowTurnBar(true)
}
@ -286,6 +284,7 @@ let cptTour: number = 0
})
socket.on("node checked",(id, works, askedIndex, newPlayerIndex, socketId) => {
console.log(newPlayerIndex)
const node = nodes.get().find((n) => id == n.id)
if (node!=undefined){
onNodeClick(false)
@ -306,15 +305,15 @@ let cptTour: number = 0
}
if (!node.label.includes(colorToEmoji(positionToColor(askedIndex), works))){
networkData.nodes.update({id: id, label: node.label + colorToEmoji(positionToColor(askedIndex), works)})
networkData.nodes.update({id: id, label: node.label + positionToEmoji(askedIndex, works)})
cptHistory++
if (cptHistory % 2 == 0){
lastNodes.push(node)
addToHistory(players[askedIndex].name + " à mis un " + colorToEmoji(positionToColor(askedIndex), works) + " à " + personNetwork.getPersons()[id].getName())
addToHistory(players[askedIndex].name + " à mis un " + positionToEmoji(askedIndex, works) + " à " + personNetwork.getPersons()[id].getName())
}
}
if (playerIndex === thisPlayerIndex){
if (playerIndex === actualPlayerIndex){
handleTurnBarTextChange("À vous de jouer")
handleShowTurnBar(true)
}
@ -337,7 +336,7 @@ let cptTour: number = 0
askedWrongBot=true
handleShowTurnBar(true)
handleTurnBarTextChange("Mauvais choix, posez un carré !")
socket.emit("put grey background", socket.id, thisPlayerIndex)
socket.emit("put grey background", socket.id, actualPlayerIndex)
})
@ -356,16 +355,16 @@ let cptTour: number = 0
const node = nodes.get().find((n) => nodeId == n.id)
if (node != undefined && indice != null){
var tester = IndiceTesterFactory.Create(indice)
let maybe = thisPlayerIndex
let maybe = actualPlayerIndex
if (tester.Works(pers)){
playerIndex = playerIndex + 1
if(playerIndex == players.length){
playerIndex = 0
}
socket.emit("node checked", nodeId, true, thisPlayerIndex, room, playerIndex)
socket.emit("node checked", nodeId, true, actualPlayerIndex, room, playerIndex)
}
else{
maybe = thisPlayerIndex - 1
maybe = actualPlayerIndex - 1
if(maybe == 0){
maybe = players.length - 1
}
@ -377,7 +376,7 @@ let cptTour: number = 0
}
}
if (index != undefined){
socket.emit("node checked", nodeId, false, thisPlayerIndex, room, index)
socket.emit("node checked", nodeId, false, actualPlayerIndex, room, index)
socket.emit("asked wrong", askingPlayer, room)
}
@ -409,7 +408,7 @@ let cptTour: number = 0
if (personNetwork != null){
const tab = mapIndexPersons.get(player)
if (tab != undefined){
if (player != thisPlayerIndex){
if (player != actualPlayerIndex){
for(const person of personNetwork.getPersons().filter((p) => tab.includes(p))){
networkData.nodes.update({id: person.getId(), color: "#808080"})
}
@ -432,7 +431,7 @@ let cptTour: number = 0
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)){
if (node.label.includes(positionToEmoji(i, false)) || !tester.Works(pers)){
tabNodes.push(node)
break
}
@ -452,6 +451,23 @@ let cptTour: number = 0
setLastIndex(-1)
setPlayerTouched(-1)
setWinnerData(players[winnerIndex])
first = true
cptHistory = 0
askedWrong=false
askedWrongBot=false
socket.off("end game")
socket.off("asked all")
socket.off("opacity activated")
socket.off("opacity deactivated")
socket.off("reset graph")
socket.off("node checked")
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")
navigate("/endgame")
})
@ -494,11 +510,11 @@ let cptTour: number = 0
if (person !== undefined && indice !== null){
const tester = IndiceTesterFactory.Create(indice)
if (!tester.Works(person) && !askedPersons.includes(person)){
playerIndex = thisPlayerIndex + 1
playerIndex = actualPlayerIndex + 1
if(playerIndex == players.length){
playerIndex = 0
}
socket.emit("node checked", params.nodes[0], false, thisPlayerIndex, room, playerIndex)
socket.emit("node checked", params.nodes[0], false, actualPlayerIndex, room, playerIndex)
socket.emit("put correct background", socket.id)
touchedPlayer=-1
askedPersons.push(person)
@ -599,8 +615,8 @@ let cptTour: number = 0
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)})
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

@ -29,6 +29,7 @@ interface GameContextProps {
setRoomData: (newRoom: string) => void;
setOnlyFalseData: (newOnlyFalse: boolean) => void
setWinnerData: (winner: Player) => void
reset: () => void
}
const GameContext = createContext<GameContextProps | undefined>(undefined);
@ -101,8 +102,22 @@ export const GameProvider: React.FC<GameProviderProps> = ({ children }) => {
setWinner(winner)
}
const reset = () => {
setIndices([])
setActualPlayerIndex(-1)
setAskedPersons([])
setPlayers([])
setPerson(null)
setPersonNetwork(null)
setRoom("")
setWinner(null)
setTurnPlayerIndex(-1)
setNodeId(-1)
setIndice(null)
}
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, winner, setWinnerData }}>
<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, reset }}>
{children}
</GameContext.Provider>
);

@ -26,6 +26,12 @@ import { useGame } from '../Contexts/GameContext';
function EndGame() {
const {reset} = useGame()
const resetAll = () => {
reset()
}
const {winner, person, players, indices} =useGame()
console.log(winner)
@ -52,7 +58,7 @@ function EndGame() {
<h3 className='indiceDisplay'>{indices[players.findIndex((p) => p.id == winner?.id)].ToString("fr")}</h3>
</div>
<div className='bottom'>
<div className='centerDivH'>
<div className='centerDivH' onClick={resetAll}>
<BigButtonNav dest="/play" img={Leave}/>
</div>
<div className="losingPlayersContainer">

@ -21,6 +21,7 @@ import Info from "../res/icon/infoGreen.png";
import Check from "../res/icon/checkboxGreen.png";
import Alpha from "../res/GreekLetters/alphaW.png";
import MGlass from "../res/icon/magnifying-glass.png";
import Download from "../res/icon/download.png"
import Reset from "../res/icon/reset.png";
import Oeye from "../res/icon/eye.png";
import Ceye from "../res/icon/hidden.png";
@ -319,7 +320,7 @@ const InGame = ({locale, changeLocale}) => {
backgroundColor: theme.colors.tertiary,
borderColor: theme.colors.secondary
}}>
<img src={MGlass} alt="indice" height="40"/>
<img src={Download} alt="indice" height="40"/>
</button>
</div>

@ -1,131 +0,0 @@
\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{times}
\usepackage{tikz}
\usepackage{paralist}
\usetikzlibrary {shapes.multipart}
\newcommand{\Basketball}{\includegraphics[width=.5cm]{ballon-de-basket.png}}
\newcommand{\Football}{\includegraphics[width=.4cm]{ballon-de-foot.png}}
\newcommand{\Bowling}{\includegraphics[width=.5cm]{bowling.png}}
\newcommand{\Baseball}{\includegraphics[width=.5cm]{baseball.png}}
\newcommand{\Tennis}{\includegraphics[width=.5cm]{tennis.png}}
\begin{document}
\thispagestyle{empty}
Voici le graphe de SocialGraphe
\begin{center}
\begin{tikzpicture}[scale=.17]
\node[draw, circle split] (0) at (17.56,12.89) { Noah \nodepart{lower} \Bowling{}};
\node[draw, circle split] (1) at (10.33,-12.44) { Victoria \nodepart{lower} \Baseball{} \Basketball{}};
\node[draw, circle split] (2) at (47.11,-11.56) { Ava \nodepart{lower} \Tennis{} \Football{}};
\node[draw, circle split] (3) at (42.89,9.67) { Joseph \nodepart{lower} \Tennis{}};
\node[draw, circle split] (4) at (-35.44,-31.89) { Daniel \nodepart{lower} \Basketball{} \Football{} \Bowling{}};
\node[draw, circle split] (5) at (35.44,-45.00) { Violet \nodepart{lower} \Baseball{}};
\node[draw, circle split] (6) at (-14.56,49.78) { Aurora \nodepart{lower} \Bowling{} \Baseball{} \Basketball{}};
\node[draw, circle split] (7) at (-5.44,-4.78) { Stella \nodepart{lower} \Tennis{} \Football{}};
\node[draw, circle split] (8) at (-28.22,-11.44) { Brayden \nodepart{lower} \Football{} \Baseball{}};
\node[draw, circle split] (9) at (-25.56,25.22) { Sophia \nodepart{lower} \Bowling{} \Basketball{}};
\node[draw, circle split] (10) at (-34.67,-52.11) { Aurora \nodepart{lower} \Tennis{}};
\node[draw, circle split] (11) at (-9.22,-58.67) { Grace \nodepart{lower} \Football{} \Bowling{}};
\node[draw, circle split] (12) at (-14.67,-20.56) { William \nodepart{lower} \Baseball{} \Basketball{} \Tennis{}};
\node[draw, circle split] (13) at (-53.22,-11.00) { Connor \nodepart{lower} \Basketball{} \Football{}};
\node[draw, circle split] (14) at (17.33,35.44) { Amelia \nodepart{lower} \Tennis{} \Bowling{}};
\node[draw, circle split] (15) at (45.00,33.33) { Riley \nodepart{lower} \Baseball{}};
\node[draw, circle split] (16) at (-6.00,32.67) { Carter \nodepart{lower} \Tennis{} \Bowling{}};
\node[draw, circle split] (17) at (30.11,32.78) { Nathan \nodepart{lower} \Baseball{} \Basketball{}};
\node[draw, circle split] (18) at (-1.33,-23.89) { Noah \nodepart{lower} \Football{} \Football{}};
\node[draw, circle split] (19) at (25.11,-3.11) { Ryan \nodepart{lower} \Bowling{} \Tennis{}};
\node[draw, circle split] (20) at (-1.33,6.33) { Isabella \nodepart{lower} \Baseball{}};
\node[draw, circle split] (21) at (15.00,-41.78) { Alexander \nodepart{lower} \Basketball{} \Bowling{} \Baseball{}};
\node[draw, circle split] (22) at (2.67,22.56) { Emily \nodepart{lower} \Football{}};
\node[draw, circle split] (23) at (26.33,-22.56) { Matthew \nodepart{lower} \Basketball{} \Tennis{}};
\node[draw, circle split] (24) at (-45.11,8.44) { Aurora \nodepart{lower} \Basketball{}};
\node[draw, circle split] (25) at (-2.00,-44.00) { Mia \nodepart{lower} \Tennis{} \Bowling{} \Baseball{}};
\node[draw, circle split] (26) at (-8.78,11.67) { Liam \nodepart{lower} \Football{}};
\node[draw, circle split] (27) at (-20.89,5.00) { Henry \nodepart{lower} \Basketball{} \Football{}};
\node[draw, circle split] (28) at (-0.56,66.00) { Aiden \nodepart{lower} \Tennis{} \Baseball{}};
\node[draw, circle split] (29) at (-45.67,31.67) { Nora \nodepart{lower} \Bowling{} \Basketball{}};
\draw (0) -- (19);
\draw (0) -- (14);
\draw (0) -- (20);
\draw (0) -- (3);
\draw (0) -- (17);
\draw (1) -- (19);
\draw (1) -- (21);
\draw (1) -- (12);
\draw (1) -- (23);
\draw (2) -- (19);
\draw (2) -- (23);
\draw (3) -- (0);
\draw (3) -- (15);
\draw (4) -- (12);
\draw (4) -- (8);
\draw (5) -- (23);
\draw (6) -- (16);
\draw (6) -- (28);
\draw (7) -- (26);
\draw (7) -- (8);
\draw (7) -- (18);
\draw (8) -- (4);
\draw (8) -- (7);
\draw (8) -- (13);
\draw (8) -- (27);
\draw (9) -- (26);
\draw (9) -- (29);
\draw (9) -- (16);
\draw (10) -- (11);
\draw (11) -- (10);
\draw (11) -- (25);
\draw (12) -- (1);
\draw (12) -- (4);
\draw (13) -- (8);
\draw (14) -- (0);
\draw (14) -- (16);
\draw (15) -- (3);
\draw (16) -- (6);
\draw (16) -- (9);
\draw (16) -- (14);
\draw (16) -- (26);
\draw (17) -- (0);
\draw (18) -- (7);
\draw (18) -- (21);
\draw (18) -- (25);
\draw (18) -- (23);
\draw (19) -- (0);
\draw (19) -- (1);
\draw (19) -- (2);
\draw (20) -- (0);
\draw (20) -- (27);
\draw (20) -- (22);
\draw (21) -- (1);
\draw (21) -- (18);
\draw (22) -- (20);
\draw (23) -- (1);
\draw (23) -- (2);
\draw (23) -- (5);
\draw (23) -- (18);
\draw (24) -- (27);
\draw (24) -- (29);
\draw (25) -- (11);
\draw (25) -- (18);
\draw (26) -- (7);
\draw (26) -- (9);
\draw (26) -- (16);
\draw (27) -- (8);
\draw (27) -- (20);
\draw (27) -- (24);
\draw (28) -- (6);
\draw (29) -- (9);
\draw (29) -- (24);
\end{tikzpicture}
\end{center}
\paragraph{Première énigme}
Trouver qui est le coupable avec les indices suivants.
\begin{compactitem}
\item Indice 1 : Le suspect a ou a plus de 30 ans.
\item Indice 2 : Le suspect a les cheveux Noir ou Roux .
\item Indice 3 : Le suspect 3 amis.
\end{compactitem}
% Solution : Ryan
\end{document}

@ -74,6 +74,7 @@ class EdgesCreator{
}
CreateAllEdges(personNetwork: PersonNetwork, choosenPerson: Person, indices: Indice[]){
const nbTryConnex = 10
const test = new Map<number, number>()
const tabEdgesSize: number[] = []
for (let i = 0; i<personNetwork.getPersons().length / 4; i++){
@ -100,6 +101,48 @@ class EdgesCreator{
this.CreateNotWorkingEdge(personNetwork, p, choosenPerson, indices, test)
}
});
let [isConnected, connectedNodes, unconnectedNodes] = personNetwork.getConnectivityDetails()
let i = 0
while(!isConnected){
if (i==nbTryConnex){
return
}
for(const pers of unconnectedNodes){
let canBreak = false
for(const newFriend of connectedNodes){
if (pers != newFriend && newFriend!=choosenPerson){
let testEdgeWork1 = 0
let testEdgeWork2 = 0
const p1 = cloneDeep(pers);
const personEdge = cloneDeep(newFriend);
p1.addFriend(personEdge)
personEdge.addFriend(p1)
indices.forEach((indice) => {
const tester = IndiceTesterFactory.Create(indice)
if (tester.Works(p1)){
testEdgeWork1 ++
}
if (tester.Works(personEdge)){
testEdgeWork2 ++
}
});
if (testEdgeWork1 < indices.length && testEdgeWork2 < indices.length){
pers.addFriend(newFriend)
newFriend.addFriend(pers)
canBreak = true
break
}
}
}
if (canBreak){
break
}
}
[isConnected, connectedNodes, unconnectedNodes] = personNetwork.getConnectivityDetails()
i++
}
}
}

@ -27,7 +27,7 @@ class NetworkGenerator{
}
*/
for(let i = 0; i < nbPerson/3; i++){
const nombreAleatoire = Math.floor(Math.random() * 9) + 12;
const nombreAleatoire = Math.floor(Math.random() * 8) + 12;
tabAdo.push(nombreAleatoire)
}
for(let i = 0; i < nbPerson/3; i++){
@ -35,7 +35,7 @@ class NetworkGenerator{
tabAdulte.push(nombreAleatoire)
}
for(let i = 0; i < nbPerson/3; i++){
const nombreAleatoire = Math.floor(Math.random() * 30) + 30;
const nombreAleatoire = Math.floor(Math.random() * 40) + 30;
tabVieux.push(nombreAleatoire)
}

@ -18,6 +18,41 @@ class PersonNetwork{
addPerson(person: Person){
this.persons.push(person)
}
private dfs(startNode: Person, visited: Set<number>) {
visited.add(startNode.getId());
for (const friend of startNode.getFriends()) {
if (!visited.has(friend.getId())) {
this.dfs(friend, visited);
}
}
}
getConnectivityDetails(): [boolean, Person[], Person[]] {
if (this.persons.length === 0) {
// Si la liste de personnes est vide, le graphe est considéré comme connexe.
return [true, [], []]
}
const visited: Set<number> = new Set();
const connectedNodes: Person[] = [];
// Commencez la recherche en profondeur à partir du premier nœud du réseau.
this.dfs(this.persons[0], visited);
// Obtenez les nœuds connectés.
for (const person of this.persons) {
if (visited.has(person.getId())) {
connectedNodes.push(person);
}
}
// Obtenez les nœuds non connectés.
const unconnectedNodes: Person[] = this.persons.filter(person => !visited.has(person.getId()));
return [unconnectedNodes.length === 0, connectedNodes, unconnectedNodes];
}
}
export default PersonNetwork

@ -14,14 +14,13 @@ class Stub{
let indice = new NbEdgesIndice(1, 2)
let indice1 = new NbEdgesIndice(2, 3)
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 ageIndice = new AgeIndice(4, 12, 19)
let ageIndice1 = new AgeIndice(5, 20, 29)
let ageIndice2 = new AgeIndice(6, 30, 100000)
let indices: Indice[] = [indice, indice1, indice2, ageIndice, ageIndice1, ageIndice2, ageIndice3]
let indices: Indice[] = [indice, indice1, indice2, ageIndice, ageIndice1, ageIndice2]
let test = 8
let test = 7
for (let i: Color=0; i<5; i++){
for (let j: Color=0; j<5; j++){
if (j==i){

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Loading…
Cancel
Save