From 998bb7d0ba86c721fe032cb4bd38e4c2429c3430 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Fri, 10 Nov 2023 09:05:49 +0100 Subject: [PATCH] Chngement du nom du dossier model + ajoue d'une classe GameCreator --- .../src/Components/GraphContainer.tsx | 39 ++++++------------- .../src/{source => model}/Color.ts | 0 .../src/{source => model}/EdgesCreator.ts | 0 .../src/{source => model}/EnumExtender.ts | 0 .../Factory/IndiceEdgesCreatorFactory.ts | 0 .../Factory/IndiceTesterFactory.ts | 0 cryptide_project/src/model/GameCreator.ts | 36 +++++++++++++++++ .../src/{source => model}/Graph/Edge.ts | 0 .../src/{source => model}/Graph/Font.ts | 0 .../{source => model}/Graph/GraphCreator.ts | 0 .../{source => model}/Graph/GraphPerson.ts | 0 .../src/{source => model}/Graph/NodePerson.ts | 0 .../src/{source => model}/IndiceChooser.ts | 2 +- .../ColorIndiceEdgesCreator.ts | 0 .../IndiceEdgesCreator.ts | 0 .../NbEdgesIndiceEdgesCreator.ts | 0 .../IndiceTester/ColorIndiceEdgesTester.ts | 9 ----- .../IndiceTester/ColorIndiceTester.ts | 4 -- .../IndiceTester/IndiceTester.ts | 1 - .../IndiceTester/IndiceTesterAge.ts | 4 -- .../IndiceTester/NbEdgesIndiceTester.ts | 4 -- .../IndiceTester/NbSportIndiceTester.ts | 4 -- .../IndiceTester/SportIndiceTester.ts | 9 ----- .../{source => model}/Indices/AgeIndice.ts | 0 .../Indices/ColorEdgesIndice.ts | 0 .../{source => model}/Indices/ColorIndice.ts | 0 .../{source => model}/Indices/EdgesIndice.ts | 0 .../src/{source => model}/Indices/Indice.ts | 0 .../Indices/NbEdgesIndice.ts | 0 .../Indices/NbSportIndice.ts | 0 .../{source => model}/Indices/SportIndice.ts | 0 .../src/{source => model}/NetworkGenerator.ts | 0 .../src/{source => model}/Person.ts | 0 .../src/{source => model}/PersonsNetwork.ts | 0 .../src/{source => model}/Sport.ts | 0 .../src/{source => model}/Stub.ts | 0 36 files changed, 49 insertions(+), 63 deletions(-) rename cryptide_project/src/{source => model}/Color.ts (100%) rename cryptide_project/src/{source => model}/EdgesCreator.ts (100%) rename cryptide_project/src/{source => model}/EnumExtender.ts (100%) rename cryptide_project/src/{source => model}/Factory/IndiceEdgesCreatorFactory.ts (100%) rename cryptide_project/src/{source => model}/Factory/IndiceTesterFactory.ts (100%) create mode 100644 cryptide_project/src/model/GameCreator.ts rename cryptide_project/src/{source => model}/Graph/Edge.ts (100%) rename cryptide_project/src/{source => model}/Graph/Font.ts (100%) rename cryptide_project/src/{source => model}/Graph/GraphCreator.ts (100%) rename cryptide_project/src/{source => model}/Graph/GraphPerson.ts (100%) rename cryptide_project/src/{source => model}/Graph/NodePerson.ts (100%) rename cryptide_project/src/{source => model}/IndiceChooser.ts (95%) rename cryptide_project/src/{source => model}/IndiceEdgesCreator.ts/ColorIndiceEdgesCreator.ts (100%) rename cryptide_project/src/{source => model}/IndiceEdgesCreator.ts/IndiceEdgesCreator.ts (100%) rename cryptide_project/src/{source => model}/IndiceEdgesCreator.ts/NbEdgesIndiceEdgesCreator.ts (100%) rename cryptide_project/src/{source => model}/IndiceTester/ColorIndiceEdgesTester.ts (72%) rename cryptide_project/src/{source => model}/IndiceTester/ColorIndiceTester.ts (75%) rename cryptide_project/src/{source => model}/IndiceTester/IndiceTester.ts (67%) rename cryptide_project/src/{source => model}/IndiceTester/IndiceTesterAge.ts (70%) rename cryptide_project/src/{source => model}/IndiceTester/NbEdgesIndiceTester.ts (82%) rename cryptide_project/src/{source => model}/IndiceTester/NbSportIndiceTester.ts (77%) rename cryptide_project/src/{source => model}/IndiceTester/SportIndiceTester.ts (70%) rename cryptide_project/src/{source => model}/Indices/AgeIndice.ts (100%) rename cryptide_project/src/{source => model}/Indices/ColorEdgesIndice.ts (100%) rename cryptide_project/src/{source => model}/Indices/ColorIndice.ts (100%) rename cryptide_project/src/{source => model}/Indices/EdgesIndice.ts (100%) rename cryptide_project/src/{source => model}/Indices/Indice.ts (100%) rename cryptide_project/src/{source => model}/Indices/NbEdgesIndice.ts (100%) rename cryptide_project/src/{source => model}/Indices/NbSportIndice.ts (100%) rename cryptide_project/src/{source => model}/Indices/SportIndice.ts (100%) rename cryptide_project/src/{source => model}/NetworkGenerator.ts (100%) rename cryptide_project/src/{source => model}/Person.ts (100%) rename cryptide_project/src/{source => model}/PersonsNetwork.ts (100%) rename cryptide_project/src/{source => model}/Sport.ts (100%) rename cryptide_project/src/{source => model}/Stub.ts (100%) diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 6f85b1f..bf8061a 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -1,41 +1,26 @@ import React, { useEffect } from "react"; import { DataSet, Network} from "vis-network/standalone/esm/vis-network"; -import EdgesCreator from "../source/EdgesCreator"; -import GraphCreator from "../source/Graph/GraphCreator"; -import IndiceChooser from "../source/IndiceChooser"; -import SportIndice from "../source/Indices/SportIndice"; -import NetworkGenerator from "../source/NetworkGenerator"; -import Sport from "../source/Sport"; -import Stub from "../source/Stub"; +import EdgesCreator from "../model/EdgesCreator"; +import GraphCreator from "../model/Graph/GraphCreator"; +import IndiceChooser from "../model/IndiceChooser"; +import SportIndice from "../model/Indices/SportIndice"; +import NetworkGenerator from "../model/NetworkGenerator"; +import Sport from "../model/Sport"; +import Stub from "../model/Stub"; import "./GraphContainer.css"; -import NodePerson from "../source/Graph/NodePerson"; -import IndiceTesterFactory from "../source/Factory/IndiceTesterFactory"; +import NodePerson from "../model/Graph/NodePerson"; +import IndiceTesterFactory from "../model/Factory/IndiceTesterFactory"; +import GameCreator from "../model/GameCreator"; -const edgesCreator = new EdgesCreator() +const [networkPerson, choosenPerson, choosenIndices, graph] = GameCreator.CreateGame(3, 30) -const chooser = new IndiceChooser() -const indices = Stub.GenerateIndice() - -const networkPerson = NetworkGenerator.GenerateNetwork(50) - -const rand = Math.floor(Math.random() * 50) -const person = networkPerson.getPersons()[rand] - -const choosenIndices = chooser.chooseIndice(networkPerson, person, indices, 8) - -edgesCreator.CreateAllEdges(networkPerson, person, choosenIndices) - -const graph = GraphCreator.CreateGraph(networkPerson) - - -let indice = new SportIndice(12, [Sport.TENNIS, Sport.BASEBALL]) console.log(networkPerson) console.log(graph) choosenIndices.forEach((indice) =>{ console.log(indice.ToString("fr")) }); -console.log(person) +console.log(choosenPerson) const testIndice = choosenIndices[0] interface MyGraphComponentProps { diff --git a/cryptide_project/src/source/Color.ts b/cryptide_project/src/model/Color.ts similarity index 100% rename from cryptide_project/src/source/Color.ts rename to cryptide_project/src/model/Color.ts diff --git a/cryptide_project/src/source/EdgesCreator.ts b/cryptide_project/src/model/EdgesCreator.ts similarity index 100% rename from cryptide_project/src/source/EdgesCreator.ts rename to cryptide_project/src/model/EdgesCreator.ts diff --git a/cryptide_project/src/source/EnumExtender.ts b/cryptide_project/src/model/EnumExtender.ts similarity index 100% rename from cryptide_project/src/source/EnumExtender.ts rename to cryptide_project/src/model/EnumExtender.ts diff --git a/cryptide_project/src/source/Factory/IndiceEdgesCreatorFactory.ts b/cryptide_project/src/model/Factory/IndiceEdgesCreatorFactory.ts similarity index 100% rename from cryptide_project/src/source/Factory/IndiceEdgesCreatorFactory.ts rename to cryptide_project/src/model/Factory/IndiceEdgesCreatorFactory.ts diff --git a/cryptide_project/src/source/Factory/IndiceTesterFactory.ts b/cryptide_project/src/model/Factory/IndiceTesterFactory.ts similarity index 100% rename from cryptide_project/src/source/Factory/IndiceTesterFactory.ts rename to cryptide_project/src/model/Factory/IndiceTesterFactory.ts diff --git a/cryptide_project/src/model/GameCreator.ts b/cryptide_project/src/model/GameCreator.ts new file mode 100644 index 0000000..1d9d8ca --- /dev/null +++ b/cryptide_project/src/model/GameCreator.ts @@ -0,0 +1,36 @@ +import { TupleType } from "typescript"; +import EdgesCreator from "./EdgesCreator"; +import GraphCreator from "./Graph/GraphCreator"; +import GraphPerson from "./Graph/GraphPerson"; +import IndiceChooser from "./IndiceChooser"; +import Indice from "./Indices/Indice"; +import NetworkGenerator from "./NetworkGenerator"; +import Person from "./Person"; +import PersonNetwork from "./PersonsNetwork"; +import Stub from "./Stub"; + +class GameCreator{ + static CreateGame(nbPlayers: number, nbNodes: number): [PersonNetwork, Person, Indice[], GraphPerson]{ + const edgesCreator = new EdgesCreator() + + const chooser = new IndiceChooser() + + const indices = Stub.GenerateIndice() + + const networkPerson = NetworkGenerator.GenerateNetwork(nbNodes) + + const rand = Math.floor(Math.random() * nbNodes) + const person = networkPerson.getPersons()[rand] + + const choosenIndices = chooser.chooseIndice(person, indices, nbPlayers) + + edgesCreator.CreateAllEdges(networkPerson, person, choosenIndices) + + const graph = GraphCreator.CreateGraph(networkPerson) + + return [networkPerson, person, choosenIndices, graph] + + } +} + +export default GameCreator \ No newline at end of file diff --git a/cryptide_project/src/source/Graph/Edge.ts b/cryptide_project/src/model/Graph/Edge.ts similarity index 100% rename from cryptide_project/src/source/Graph/Edge.ts rename to cryptide_project/src/model/Graph/Edge.ts diff --git a/cryptide_project/src/source/Graph/Font.ts b/cryptide_project/src/model/Graph/Font.ts similarity index 100% rename from cryptide_project/src/source/Graph/Font.ts rename to cryptide_project/src/model/Graph/Font.ts diff --git a/cryptide_project/src/source/Graph/GraphCreator.ts b/cryptide_project/src/model/Graph/GraphCreator.ts similarity index 100% rename from cryptide_project/src/source/Graph/GraphCreator.ts rename to cryptide_project/src/model/Graph/GraphCreator.ts diff --git a/cryptide_project/src/source/Graph/GraphPerson.ts b/cryptide_project/src/model/Graph/GraphPerson.ts similarity index 100% rename from cryptide_project/src/source/Graph/GraphPerson.ts rename to cryptide_project/src/model/Graph/GraphPerson.ts diff --git a/cryptide_project/src/source/Graph/NodePerson.ts b/cryptide_project/src/model/Graph/NodePerson.ts similarity index 100% rename from cryptide_project/src/source/Graph/NodePerson.ts rename to cryptide_project/src/model/Graph/NodePerson.ts diff --git a/cryptide_project/src/source/IndiceChooser.ts b/cryptide_project/src/model/IndiceChooser.ts similarity index 95% rename from cryptide_project/src/source/IndiceChooser.ts rename to cryptide_project/src/model/IndiceChooser.ts index 711e47f..d455a5e 100644 --- a/cryptide_project/src/source/IndiceChooser.ts +++ b/cryptide_project/src/model/IndiceChooser.ts @@ -13,7 +13,7 @@ import NbSportIndice from "./Indices/NbSportIndice"; class IndiceChooser{ - chooseIndice(personNetwork: PersonNetwork, choosenPerson: Person, indices: Indice[], nbPlayer: number): Indice[]{ + chooseIndice(choosenPerson: Person, indices: Indice[], nbPlayer: number): Indice[]{ const choosenIndices: Indice[] = [] const ageIndice : Indice[] = [] const sportIndice : Indice[] = [] diff --git a/cryptide_project/src/source/IndiceEdgesCreator.ts/ColorIndiceEdgesCreator.ts b/cryptide_project/src/model/IndiceEdgesCreator.ts/ColorIndiceEdgesCreator.ts similarity index 100% rename from cryptide_project/src/source/IndiceEdgesCreator.ts/ColorIndiceEdgesCreator.ts rename to cryptide_project/src/model/IndiceEdgesCreator.ts/ColorIndiceEdgesCreator.ts diff --git a/cryptide_project/src/source/IndiceEdgesCreator.ts/IndiceEdgesCreator.ts b/cryptide_project/src/model/IndiceEdgesCreator.ts/IndiceEdgesCreator.ts similarity index 100% rename from cryptide_project/src/source/IndiceEdgesCreator.ts/IndiceEdgesCreator.ts rename to cryptide_project/src/model/IndiceEdgesCreator.ts/IndiceEdgesCreator.ts diff --git a/cryptide_project/src/source/IndiceEdgesCreator.ts/NbEdgesIndiceEdgesCreator.ts b/cryptide_project/src/model/IndiceEdgesCreator.ts/NbEdgesIndiceEdgesCreator.ts similarity index 100% rename from cryptide_project/src/source/IndiceEdgesCreator.ts/NbEdgesIndiceEdgesCreator.ts rename to cryptide_project/src/model/IndiceEdgesCreator.ts/NbEdgesIndiceEdgesCreator.ts diff --git a/cryptide_project/src/source/IndiceTester/ColorIndiceEdgesTester.ts b/cryptide_project/src/model/IndiceTester/ColorIndiceEdgesTester.ts similarity index 72% rename from cryptide_project/src/source/IndiceTester/ColorIndiceEdgesTester.ts rename to cryptide_project/src/model/IndiceTester/ColorIndiceEdgesTester.ts index 84d1a10..c844d07 100644 --- a/cryptide_project/src/source/IndiceTester/ColorIndiceEdgesTester.ts +++ b/cryptide_project/src/model/IndiceTester/ColorIndiceEdgesTester.ts @@ -22,15 +22,6 @@ class ColorEdgesIndiceTester implements IndiceTester{ }); return res } - - TestWorks(person: Person): boolean { - person.getFriends().forEach(p => { - if(this.colorEdgesIndice.getColors().includes(p.getColor())){ - return true - } - }); - return false - } } export default ColorEdgesIndiceTester \ No newline at end of file diff --git a/cryptide_project/src/source/IndiceTester/ColorIndiceTester.ts b/cryptide_project/src/model/IndiceTester/ColorIndiceTester.ts similarity index 75% rename from cryptide_project/src/source/IndiceTester/ColorIndiceTester.ts rename to cryptide_project/src/model/IndiceTester/ColorIndiceTester.ts index a31ebce..5665728 100644 --- a/cryptide_project/src/source/IndiceTester/ColorIndiceTester.ts +++ b/cryptide_project/src/model/IndiceTester/ColorIndiceTester.ts @@ -14,10 +14,6 @@ class ColorIndiceTester implements IndiceTester{ Works(person: Person): boolean { return this.colorIndice.getColors().includes(person.getColor()) } - - TestWorks(person: Person): boolean { - return this.colorIndice.getColors().includes(person.getColor()) - } } export default ColorIndiceTester \ No newline at end of file diff --git a/cryptide_project/src/source/IndiceTester/IndiceTester.ts b/cryptide_project/src/model/IndiceTester/IndiceTester.ts similarity index 67% rename from cryptide_project/src/source/IndiceTester/IndiceTester.ts rename to cryptide_project/src/model/IndiceTester/IndiceTester.ts index d317107..e5d551c 100644 --- a/cryptide_project/src/source/IndiceTester/IndiceTester.ts +++ b/cryptide_project/src/model/IndiceTester/IndiceTester.ts @@ -4,7 +4,6 @@ import Person from "../Person" interface IndiceTester{ Works(person: Person): boolean - TestWorks(person: Person): boolean } export default IndiceTester \ No newline at end of file diff --git a/cryptide_project/src/source/IndiceTester/IndiceTesterAge.ts b/cryptide_project/src/model/IndiceTester/IndiceTesterAge.ts similarity index 70% rename from cryptide_project/src/source/IndiceTester/IndiceTesterAge.ts rename to cryptide_project/src/model/IndiceTester/IndiceTesterAge.ts index 23feb2a..64588c6 100644 --- a/cryptide_project/src/source/IndiceTester/IndiceTesterAge.ts +++ b/cryptide_project/src/model/IndiceTester/IndiceTesterAge.ts @@ -13,10 +13,6 @@ class IndiceTesterAge implements IndiceTester{ Works(person: Person): boolean { return person.getAge() >= this.ageIndice.getMinimum() && person.getAge()<= this.ageIndice.getMaximum() } - - TestWorks(person: Person): boolean { - return person.getAge() >= this.ageIndice.getMinimum() && person.getAge()= this.nbEdgesIndice.getNbEdges() } - - TestWorks(person: Person): boolean { - return true - } } export default NbEdgesIndiceTester \ No newline at end of file diff --git a/cryptide_project/src/source/IndiceTester/NbSportIndiceTester.ts b/cryptide_project/src/model/IndiceTester/NbSportIndiceTester.ts similarity index 77% rename from cryptide_project/src/source/IndiceTester/NbSportIndiceTester.ts rename to cryptide_project/src/model/IndiceTester/NbSportIndiceTester.ts index 6adbc4f..a0cf2dc 100644 --- a/cryptide_project/src/source/IndiceTester/NbSportIndiceTester.ts +++ b/cryptide_project/src/model/IndiceTester/NbSportIndiceTester.ts @@ -15,10 +15,6 @@ class NbSportIndiceTester implements IndiceTester{ Works(person: Person): boolean { return this.nbSportIndice.getNbSport() == person.getSports().length } - - TestWorks(person: Person): boolean { - return this.nbSportIndice.getNbSport() == person.getSports().length - } } export default NbSportIndiceTester \ No newline at end of file diff --git a/cryptide_project/src/source/IndiceTester/SportIndiceTester.ts b/cryptide_project/src/model/IndiceTester/SportIndiceTester.ts similarity index 70% rename from cryptide_project/src/source/IndiceTester/SportIndiceTester.ts rename to cryptide_project/src/model/IndiceTester/SportIndiceTester.ts index 9c8f87a..1391582 100644 --- a/cryptide_project/src/source/IndiceTester/SportIndiceTester.ts +++ b/cryptide_project/src/model/IndiceTester/SportIndiceTester.ts @@ -20,15 +20,6 @@ class SportIndiceTester implements IndiceTester{ } return false } - - TestWorks(person: Person): boolean { - for (const sport of person.getSports()){ - if (this.sportIndice.getSports().includes(sport)){ - return true - } - } - return false - } } export default SportIndiceTester \ No newline at end of file diff --git a/cryptide_project/src/source/Indices/AgeIndice.ts b/cryptide_project/src/model/Indices/AgeIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/AgeIndice.ts rename to cryptide_project/src/model/Indices/AgeIndice.ts diff --git a/cryptide_project/src/source/Indices/ColorEdgesIndice.ts b/cryptide_project/src/model/Indices/ColorEdgesIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/ColorEdgesIndice.ts rename to cryptide_project/src/model/Indices/ColorEdgesIndice.ts diff --git a/cryptide_project/src/source/Indices/ColorIndice.ts b/cryptide_project/src/model/Indices/ColorIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/ColorIndice.ts rename to cryptide_project/src/model/Indices/ColorIndice.ts diff --git a/cryptide_project/src/source/Indices/EdgesIndice.ts b/cryptide_project/src/model/Indices/EdgesIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/EdgesIndice.ts rename to cryptide_project/src/model/Indices/EdgesIndice.ts diff --git a/cryptide_project/src/source/Indices/Indice.ts b/cryptide_project/src/model/Indices/Indice.ts similarity index 100% rename from cryptide_project/src/source/Indices/Indice.ts rename to cryptide_project/src/model/Indices/Indice.ts diff --git a/cryptide_project/src/source/Indices/NbEdgesIndice.ts b/cryptide_project/src/model/Indices/NbEdgesIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/NbEdgesIndice.ts rename to cryptide_project/src/model/Indices/NbEdgesIndice.ts diff --git a/cryptide_project/src/source/Indices/NbSportIndice.ts b/cryptide_project/src/model/Indices/NbSportIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/NbSportIndice.ts rename to cryptide_project/src/model/Indices/NbSportIndice.ts diff --git a/cryptide_project/src/source/Indices/SportIndice.ts b/cryptide_project/src/model/Indices/SportIndice.ts similarity index 100% rename from cryptide_project/src/source/Indices/SportIndice.ts rename to cryptide_project/src/model/Indices/SportIndice.ts diff --git a/cryptide_project/src/source/NetworkGenerator.ts b/cryptide_project/src/model/NetworkGenerator.ts similarity index 100% rename from cryptide_project/src/source/NetworkGenerator.ts rename to cryptide_project/src/model/NetworkGenerator.ts diff --git a/cryptide_project/src/source/Person.ts b/cryptide_project/src/model/Person.ts similarity index 100% rename from cryptide_project/src/source/Person.ts rename to cryptide_project/src/model/Person.ts diff --git a/cryptide_project/src/source/PersonsNetwork.ts b/cryptide_project/src/model/PersonsNetwork.ts similarity index 100% rename from cryptide_project/src/source/PersonsNetwork.ts rename to cryptide_project/src/model/PersonsNetwork.ts diff --git a/cryptide_project/src/source/Sport.ts b/cryptide_project/src/model/Sport.ts similarity index 100% rename from cryptide_project/src/source/Sport.ts rename to cryptide_project/src/model/Sport.ts diff --git a/cryptide_project/src/source/Stub.ts b/cryptide_project/src/model/Stub.ts similarity index 100% rename from cryptide_project/src/source/Stub.ts rename to cryptide_project/src/model/Stub.ts