-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gdai_on_linux_n7
committed
Jan 11, 2022
1 parent
4fda4a6
commit 28b0b24
Showing
17 changed files
with
821 additions
and
11 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
...ojets/ProjetIDM/L12-06/.svn/pristine/55/552144e275fc5784c906fe68231197a129a425d9.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jV" nsURI="http://www.n7.fr/JV" nsPrefix="jV"> | ||
<eClassifiers xsi:type="ecore:EClass" name="Game"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="inventorySize" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="gameElements" upperBound="-1" | ||
eType="#//GameElement" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="objects" upperBound="-1" | ||
eType="#//Prize" containment="true"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Description"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="text" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="optionalText" upperBound="-1" | ||
eType="#//OptionalText" containment="true"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="OptionalText"> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="condition" upperBound="-1" | ||
eType="#//Condition" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="text" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="GameElement"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="prizesID" unique="false" | ||
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Places" eSuperTypes="#//GameElement"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="start" eType="#//BOOLEAN"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="finish" eType="#//BOOLEAN"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="persons" upperBound="-1" | ||
eType="#//Person" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="pathsID" unique="false" | ||
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EEnum" name="BOOLEAN"> | ||
<eLiterals name="TRUE" literal="true"/> | ||
<eLiterals name="FALSE" value="1" literal="false"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Prize"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="description" eType="#//Description" | ||
containment="true"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Condition"/> | ||
<eClassifiers xsi:type="ecore:EClass" name="ObjectCondition" eSuperTypes="#//Condition"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="objectRequiredID" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="amount" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="minAmount" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="maxAmount" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="KnowledgeCondition" eSuperTypes="#//Condition"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="knowledgeRequiredID" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Person"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="visible" eType="#//BOOLEAN"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mandatory" eType="#//BOOLEAN"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="actions" upperBound="-1" | ||
eType="#//Action" containment="true"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Action"> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="displayCondition" upperBound="-1" | ||
eType="#//Condition" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="endCondition" upperBound="-1" | ||
eType="#//Condition" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="condition" upperBound="-1" | ||
eType="#//Condition" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="prizesID" unique="false" | ||
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="consumedID" unique="false" | ||
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Knowledge" eSuperTypes="#//Prize"> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="visible" eType="#//Condition" | ||
containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="condition" upperBound="-1" | ||
eType="#//Condition" containment="true"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Path" eSuperTypes="#//GameElement"> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="description" eType="#//Description" | ||
containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="open" upperBound="-1" eType="#//Condition" | ||
containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="visible" upperBound="-1" | ||
eType="#//Condition" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mandatory" eType="#//BOOLEAN"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="consumedID" unique="false" | ||
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="InventoryObject" eSuperTypes="#//Prize"> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="transformationCondition" | ||
upperBound="-1" eType="#//Condition" containment="true"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="ObjectAfterTransformationID" | ||
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="size" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
</eClassifiers> | ||
</ecore:EPackage> |
47 changes: 47 additions & 0 deletions
47
...ojets/ProjetIDM/L12-06/.svn/pristine/72/7204e489f8788e59ff541e9f572df79592aaef86.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'JV.ecore' | ||
|
||
package jV | ||
|
||
context Game | ||
|
||
-- Contrainte: Le nom du modèle n'est pas vide | ||
inv NonNull_name('Le nom du modèle est nul'): | ||
self.name <> null | ||
|
||
--context Game | ||
-- Contrainte E6: Le nombre d’objets que peut posséder un explorateur est limité par la taille cumulée des objets possédés. | ||
--inv LimiteTailleObject('Erreur: le nombre d\'objets d\'un explorateur est supérieure à la limite '): | ||
|
||
|
||
context Game | ||
def: cherchePath(): | ||
Sequence(Path) = self.gameElements-> select(e | e.oclIsKindOf(Path)) | ||
-> collect(e | e.oclAsType(Path)) | ||
-> asSequence() | ||
|
||
def: cherchePathObligatoire(): | ||
Sequence(Path) = self.cherchePath() -> select(e | e.mandatory = BOOLEAN::TRUE) | ||
-> collect(e | e.mandatory = BOOLEAN::TRUE) | ||
-> asSequence() | ||
|
||
-- Contrainte E17: Il ne peut y avoir qu’un seul chemin obligatoire visible et ouvert par lieu. | ||
inv UniqueCheminObligatoireVisible('Erreur : plusieurs chemins obligatoires visibles sont ouverts pour un même lieu'): | ||
let somme = self.cherchePathObligatoire() -> size() in somme < 2 | ||
|
||
context Game | ||
-- Contrainte E26: Il ne peut y avoir qu’une seule personne obligatoire par lieu | ||
def: cherchePlaces(): | ||
Sequence(Places) = self.gameElements-> select(e2 | e2.oclIsKindOf(Places)) | ||
-> collect(e2 | e2.oclAsType(Places)) | ||
-> asSequence() | ||
def: cherchePersonneObligatoire(): | ||
Sequence(Person) = self.cherchePlaces() -> select( e2 | e2.oclIsKindOf(Person)) | ||
-> collect(e2 | e2.oclAsType(Person)) | ||
-> collect( e2 | e2.mandatory = BOOLEAN::TRUE | ||
-> asSequence() | ||
) | ||
|
||
inv UneSeulePersonneObligatoire('Erreur : plusieurs personnes obligatoires sont présentes dans un même lieu'): | ||
let somme2 = self.cherchePersonneObligatoire() -> size() in somme2 < 2 | ||
|
||
endpackage |
18 changes: 18 additions & 0 deletions
18
...ojets/ProjetIDM/L12-06/.svn/pristine/95/951811a43ac925677cf53f98721a6d9f31c53c76.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jV:Game xmi:version="2.0" | ||
xmlns:xmi="http://www.omg.org/XMI" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:jV="http://www.n7.fr/JV" | ||
xsi:schemaLocation="http://www.n7.fr/JV JV.ecore" | ||
name="Test sans erreur"> | ||
<gameElements | ||
xsi:type="jV:Path"/> | ||
<gameElements | ||
xsi:type="jV:Places"> | ||
<persons/> | ||
<persons/> | ||
</gameElements> | ||
<gameElements | ||
xsi:type="jV:Path" | ||
mandatory="false"/> | ||
</jV:Game> |
20 changes: 20 additions & 0 deletions
20
...ojets/ProjetIDM/L12-06/.svn/pristine/a1/a109a28bed4cf0ad5b955e70ca3180e4c3acb75b.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Game2PetriNet; | ||
create OUT: PetriNet from IN: Game; | ||
|
||
|
||
helper context jv!GameElement | ||
def: getGame(): jv!Game = | ||
jv!Game.allInstances() | ||
->select(p | p.gameElements->includes(self)) | ||
->asSequence()->first(); | ||
|
||
rule InventoryObject2Petrinet { | ||
from io: jv!InventoryObject | ||
to | ||
-- PLACES d'un InventoryObject | ||
p_quantite: PetriNet!Place( | ||
name <- io.name + '_quantite', | ||
marking <- io.size, | ||
net <- io.getGame()), | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...ojets/ProjetIDM/L12-06/.svn/pristine/b0/b099e7966860fcde20766b9e76ac53d9f96264b1.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jV:Game xmi:version="2.0" | ||
xmlns:xmi="http://www.omg.org/XMI" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:jV="http://www.n7.fr/JV" | ||
xsi:schemaLocation="http://www.n7.fr/JV JV.ecore"> | ||
<gameElements | ||
xsi:type="jV:Places"> | ||
<persons/> | ||
<persons/> | ||
</gameElements> | ||
<gameElements | ||
xsi:type="jV:Path"/> | ||
<gameElements | ||
xsi:type="jV:Path"/> | ||
</jV:Game> |
78 changes: 78 additions & 0 deletions
78
...ojets/ProjetIDM/L12-06/.svn/pristine/b3/b3961799b008a1d0726306b30ab2cbd2430f70ac.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package app; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Scanner; | ||
import java.util.Map.Entry; | ||
|
||
/** | ||
* Prototype en mode texte pour un jeu consistant à ce déplacer | ||
* de lieu en lieu, jusqu'a trouver une connaissance signifiant la fin de | ||
* la partie. | ||
* Cet exemple permet de mettre en avant : | ||
* - l'utilisation des chemins non obligatoires, | ||
* - la présence d'objets et de connaissances sur un lieu | ||
* - l'utilisation d'une condition sur une connaissance pour acceder à la fin du jeu. | ||
* | ||
* @author jcolin2 | ||
*/ | ||
public class TrouverLaCle { | ||
|
||
/** Connaissances du joueur. */ | ||
private static boolean fin; | ||
|
||
/** | ||
* Lieux indentifiés par un nom, associés à d'autres lieux où l'on peut acceder | ||
* depuis ce lieu. | ||
*/ | ||
private static Map<String, List<String>> lieux = new HashMap<>(); | ||
|
||
public static void main(String... args) { | ||
// initialisation des lieux | ||
lieux.put("Départ", Arrays.asList("lieu A", "lieu B")); | ||
lieux.put("lieu A", Arrays.asList("lieu B", "lieu C")); | ||
lieux.put("lieu B", Arrays.asList("lieu D")); | ||
lieux.put("lieu C", Arrays.asList("lieu F", "lieu B")); | ||
lieux.put("lieu D", Arrays.asList("lieu C", "lieu F")); | ||
|
||
String lieuCourant = "Départ"; | ||
do { | ||
// Choix du prochain lieu. Tous les chemins sont visibles et non obligatoires | ||
Map<String, String> options = new HashMap<>(); | ||
int i = 0; | ||
for (String destination : lieux.get(lieuCourant)) { | ||
options.put(destination, Integer.toString(i)); | ||
i++; | ||
} | ||
String reponse = displayMenu("Vous vous trouvez dans le lieu " + lieuCourant | ||
+ ". Dans quel lieu souhaitez vous vous dirigez ?", options); | ||
// déplacement vers le prochain lieu | ||
lieuCourant = lieux.get(lieuCourant).get(Integer.parseInt(reponse)); | ||
|
||
if (lieuCourant.equals("lieu F")) { | ||
// on donne la connaissance fin | ||
fin = true; | ||
} | ||
|
||
} while (!fin); | ||
|
||
// la connaissance "fin" rend visible et obligatoire un chemin qui va du lieu F vers un lieu "Sortie". | ||
System.out.println("Vous avez trouver la sortie"); | ||
} | ||
|
||
public static String displayMenu(String message, Map<String, String> options) { | ||
Scanner scan = new Scanner(System.in); | ||
|
||
// affichage des options | ||
System.out.println(message); | ||
for (Entry<String, String> entry : options.entrySet()) { | ||
System.out.println(entry.getKey() + " --> " + entry.getValue()); | ||
} | ||
System.out.println(); | ||
|
||
return scan.next(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...ojets/ProjetIDM/L12-06/.svn/pristine/c3/c39b6b893350f867df00cef316e4c1a4092f2e15.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package app; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Scanner; | ||
import java.util.Map.Entry; | ||
|
||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.emf.ecore.resource.ResourceSet; | ||
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; | ||
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
import fr.n7.jV.BOOLEAN; | ||
import fr.n7.jV.Game; | ||
import fr.n7.jV.GameElement; | ||
import fr.n7.jV.Places; | ||
import fr.n7.jV.JVPackage; | ||
|
||
/** | ||
* Prototype en mode texte pour le jeu de l'enigme | ||
* @author jcolin2 | ||
* | ||
*/ | ||
public class Enigme { | ||
|
||
/** Connaissances du joueur */ | ||
private static boolean reussite; | ||
|
||
/** Objets du joueur */ | ||
private static int tentatives = 3; | ||
|
||
public static void main(String... args) { | ||
|
||
do { | ||
// intéraction avec la personne du lieu | ||
Map<String, String> options = new HashMap<>(); | ||
options.put("réponse 1", "a"); | ||
options.put("réponse 2", "b"); | ||
options.put("réponse 3", "c"); | ||
String reponse = displayMenu("il vous reste " + tentatives | ||
+ " tentatives, quelle est la bonne réponse ? :", options); | ||
switch (reponse) { | ||
case "a" : | ||
reussite = true; | ||
break; | ||
case "b" : | ||
tentatives--; | ||
break; | ||
case "c" : | ||
tentatives--; | ||
break; | ||
default: | ||
continue; | ||
} | ||
|
||
} while (!reussite && tentatives > 0); // conditions vers les chemins obligatoires | ||
|
||
if (reussite) { | ||
// déplacement vers le lieu Succes, fin du jeu | ||
System.out.println("Succes !"); | ||
} else { | ||
// déplacement vers le lieu Echec, fin du jeu | ||
System.out.println("Echec !"); | ||
} | ||
} | ||
|
||
public static String displayMenu(String message, Map<String, String> options) { | ||
Scanner scan = new Scanner(System.in); | ||
|
||
// affichage des options | ||
System.out.println(message); | ||
for (Entry<String, String> entry : options.entrySet()) { | ||
System.out.println(entry.getKey() + " --> " + entry.getValue()); | ||
} | ||
System.out.println(); | ||
|
||
return scan.next(); | ||
} | ||
} |
Oops, something went wrong.