commit
6eb6e9f6a5
@ -1,6 +1,6 @@
|
||||
import { io } from "socket.io-client";
|
||||
|
||||
|
||||
const socket = io("http://localhost:3002");
|
||||
const socket = io("http://172.20.10.4:3002");
|
||||
|
||||
export {socket}
|
@ -0,0 +1,74 @@
|
||||
import IndiceTesterFactory from "./Factory/IndiceTesterFactory";
|
||||
import Indice from "./Indices/Indice";
|
||||
import Pair from "./Pair";
|
||||
import Person from "./Person";
|
||||
import PersonNetwork from "./PersonsNetwork";
|
||||
|
||||
class EnigmeDuJourCreator{
|
||||
|
||||
|
||||
static createEnigme(personNetwork: PersonNetwork, choosenIndices: Indice[], choosenPerson: Person, allIndices: Indice[]): Map<number, Pair<Indice, boolean>[]>{
|
||||
const map = new Map<number, Pair<Indice, boolean>[]>()
|
||||
personNetwork.getPersons().forEach((p) =>{
|
||||
map.set(p.getId(), [])
|
||||
})
|
||||
|
||||
console.log("START ENIGME")
|
||||
|
||||
choosenIndices.forEach((choosenIndice) => {
|
||||
const choosenIndiceTester = IndiceTesterFactory.Create(choosenIndice)
|
||||
const modifiedPersons: Pair<Person, boolean>[] = []
|
||||
let possibleIndices: Indice[] = [...allIndices]
|
||||
|
||||
let i = 0
|
||||
|
||||
while (possibleIndices.length != 1){
|
||||
let tmpPossibleIndices: Indice[] = [...possibleIndices]
|
||||
let choosenPair : Pair<Person, boolean> = new Pair(personNetwork.getPersons()[0], true)
|
||||
for(const person of personNetwork.getPersons().filter((p) => p.getId() !== choosenPerson.getId())){
|
||||
const veryTmpIndice = [...possibleIndices]
|
||||
if (!choosenIndiceTester.Works(person)){
|
||||
possibleIndices.forEach((possibleIndice, index) =>{
|
||||
const tester = IndiceTesterFactory.Create(possibleIndice)
|
||||
if (tester.Works(person)){
|
||||
const t = veryTmpIndice.findIndex((tmpIndice) => tmpIndice.getId() == possibleIndice.getId())
|
||||
if (t != -1){
|
||||
veryTmpIndice.splice(t, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
if (veryTmpIndice.length<tmpPossibleIndices.length){
|
||||
tmpPossibleIndices = veryTmpIndice
|
||||
choosenPair = new Pair(person, false)
|
||||
}
|
||||
}
|
||||
else{
|
||||
possibleIndices.forEach((possibleIndice, index) =>{
|
||||
const tester = IndiceTesterFactory.Create(possibleIndice)
|
||||
if (!tester.Works(person)){
|
||||
const t = veryTmpIndice.findIndex((tmpIndice) => tmpIndice.getId() == possibleIndice.getId())
|
||||
if (t != -1){
|
||||
veryTmpIndice.splice(t, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
if (veryTmpIndice.length<tmpPossibleIndices.length){
|
||||
tmpPossibleIndices = veryTmpIndice
|
||||
choosenPair = new Pair(person, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
possibleIndices = [...tmpPossibleIndices]
|
||||
modifiedPersons.push(choosenPair)
|
||||
console.log(possibleIndices)
|
||||
}
|
||||
console.log("choosenIndice => " + choosenIndice.ToString("fr"))
|
||||
console.log("possibleIndices => " + possibleIndices[0].ToString("fr"))
|
||||
modifiedPersons.forEach((pair) =>{
|
||||
map.get(pair.first.getId())?.push(new Pair(choosenIndice, pair.second))
|
||||
})
|
||||
})
|
||||
return map
|
||||
}
|
||||
}
|
||||
export default EnigmeDuJourCreator
|
@ -1,18 +0,0 @@
|
||||
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
|
@ -0,0 +1,25 @@
|
||||
import Player from "./Player";
|
||||
|
||||
class User extends Player{
|
||||
|
||||
public soloStats: any
|
||||
public onlineStats: any
|
||||
|
||||
constructor(id: string, name: string, profilePicture: string, soloStats: any, onlineStats: any){
|
||||
super(id, name, profilePicture)
|
||||
this.soloStats=soloStats
|
||||
this.onlineStats=onlineStats
|
||||
}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
type: "User",
|
||||
id: this.id,
|
||||
pseudo: this.pseudo,
|
||||
soloStats: this.soloStats,
|
||||
onlineStats: this.onlineStats
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default User
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue