diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 18bd2d7..17e588e 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -175,6 +175,11 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS if(!works){ socket.emit("node checked", personIndex, works, playerIndex, room, nextPlayerIndex) const ind = bot.placeSquare(personNetwork, players) + if (ind == -1 ){ + addToHistory(lastIndex.toString() + "177") + socket.emit("can't put square", lastIndex, room) + return + } console.log(lastIndex + " pose carré sur " + personNetwork.getPersons()[ind].getName()) playerIndex = lastIndex + 1 if(playerIndex == players.length){ @@ -205,6 +210,11 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS 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) + if (ind == -1 ){ + addToHistory(lastIndex.toString() + "212") + socket.emit("can't put square", playerIndex, room) + return + } console.log(lastIndex + " pose carré sur " + personNetwork.getPersons()[ind].getName()) playerIndex = lastIndex + 1 if(playerIndex == players.length){ @@ -220,6 +230,11 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS const tester = IndiceTesterFactory.Create(indices[choosedPlayerIndex]) if (!tester.Works(person)){ const ind = bot.placeSquare(personNetwork, players) + if (ind == -1 ){ + addToHistory(lastIndex.toString() + "232") + socket.emit("can't put square", playerIndex, room) + return + } console.log(lastIndex + " pose carré sur " + personNetwork.getPersons()[ind].getName()) playerIndex = lastIndex + 1 if(playerIndex == players.length){ @@ -481,6 +496,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS playerIndex = 0 } setPlayerIndex(playerIndex) + setLastIndex(playerIndex) if (playerIndex === actualPlayerIndex){ handleTurnBarTextChange("À vous de jouer") handleShowTurnBar(true) @@ -510,7 +526,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS const node = nodes.get().find((n) => nodeId == n.id) if (node != undefined && indice != null){ var tester = IndiceTesterFactory.Create(indice) - let maybe = actualPlayerIndex if (tester.Works(pers)){ playerIndex = playerIndex + 1 if(playerIndex == players.length){ @@ -519,11 +534,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS socket.emit("node checked", nodeId, true, actualPlayerIndex, room, playerIndex) } else{ - maybe = actualPlayerIndex - 1 - if(maybe == 0){ - maybe = players.length - 1 - } - //@ts-ignore let index = players.findIndex((p) => p.id == askingPlayer.id) if (players[index] instanceof Bot){ index = playerIndex + 1 @@ -566,7 +576,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS const tab = mapIndexPersons.get(player) if (tab != undefined){ if (player != actualPlayerIndex){ - console.log("player != actualPlayerIndex") for(const person of personNetwork.getPersons().filter((p) => tab.includes(p))){ networkData.nodes.update({id: person.getId(), color: "#808080"}) } @@ -594,7 +603,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS socket.on("put imossible grey", ()=>{ if (personNetwork != null && indice!=null){ - console.log("impossible grey") const tabNodes: any = [] const tester = IndiceTesterFactory.Create(indice) for (const pers of personNetwork.getPersons()){ @@ -692,7 +700,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS } if (a==indices.length){ //networkData.nodes.update({id: p.getId(), label: p.getName() + "\n🔵"}) - console.log(p) + //console.log(p) } }); diff --git a/cryptide_project/src/model/EasyBot.ts b/cryptide_project/src/model/EasyBot.ts index bf71353..7cda2f2 100644 --- a/cryptide_project/src/model/EasyBot.ts +++ b/cryptide_project/src/model/EasyBot.ts @@ -98,6 +98,9 @@ class EasyBot extends Bot{ tabFilterPerson.push(p) } }) + if (tabFilterPerson.length == 0){ + return -1 + } return tabFilterPerson[Math.floor(Math.random() * tabFilterPerson.length)].getId() }