From d5c34cb3e363dbd338b7eb35692d0629ac1139f9 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 26 Apr 2019 18:42:39 +0200 Subject: [PATCH] =?UTF-8?q?nouveau=20g=C3=A9nrateur=20pour=20le=20labyrint?= =?UTF-8?q?he=20et=20ajout=20fichier=20lab.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/json/Generateur.java | 29 +++++++++++++++ JAVA/PROJET-PMT_STRI1A/src/json/lab.json | 36 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 JAVA/PROJET-PMT_STRI1A/src/json/Generateur.java create mode 100755 JAVA/PROJET-PMT_STRI1A/src/json/lab.json diff --git a/JAVA/PROJET-PMT_STRI1A/src/json/Generateur.java b/JAVA/PROJET-PMT_STRI1A/src/json/Generateur.java new file mode 100644 index 0000000..4fbc645 --- /dev/null +++ b/JAVA/PROJET-PMT_STRI1A/src/json/Generateur.java @@ -0,0 +1,29 @@ +package json; + + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; + +import com.google.gson.Gson; + +import modeles.*; +public class Generateur { + + public Labyrinthe labyrithe() { + BufferedReader bfr= null; + try { + bfr = new BufferedReader(new FileReader("/home/nicolas/workspqce_eclipse/projet/src/json/lab.json")); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //FileReader file = new FileReader(json); + Gson gson = new Gson(); + String str="{\"positionX\":0,\"positionY\":0,\"sortie\":false,\"monstre\":[{\"nom\":\"premier monstre\",\"pAttaque\":5}],\"porte\":[{\"ouvert\":true, \"position\":\"H\"}]}"; + Labyrinthe labyrithe = gson.fromJson(str, Labyrinthe.class); + return labyrithe; + } + + +} diff --git a/JAVA/PROJET-PMT_STRI1A/src/json/lab.json b/JAVA/PROJET-PMT_STRI1A/src/json/lab.json new file mode 100755 index 0000000..6844518 --- /dev/null +++ b/JAVA/PROJET-PMT_STRI1A/src/json/lab.json @@ -0,0 +1,36 @@ + +{ +"listePersonnage":[ + { + "nom":"test", + "pVieMax":10, + "pVie":10, + "pAttaque":20, + "arme":"", + "armure":"", + "bourse":100 + } +], +"listeSalle":[ + + {"positionX":0, + "positionY":0, + "sortie":false, + "monstre":[{"nom":"premiermonstre", + "pAttaque":5} + ], + "porte":[{"ouvert":true, + "position":"H"}] + } + ], +"listeArme":[ + {"nom":"arme1", + "prix":10, + "resistance":10, + "pArme":10}], +"listeArmure":[ {"nom":"armure1", + "prix":10, + "resistance":10, + "pArmure":10}] + +}