From d1e70947ce1e39ac55b3ba73f5521554a7999afe Mon Sep 17 00:00:00 2001 From: gdamms Date: Wed, 1 Dec 2021 21:19:08 +0100 Subject: [PATCH] feat: :fire: fin du prototyyyype java --- enigme.java/Description.java | 5 +++++ enigme.java/Interaction.java | 8 ++++---- enigme.java/Jeu.java | 39 ++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/enigme.java/Description.java b/enigme.java/Description.java index f0c68b2..adb783b 100644 --- a/enigme.java/Description.java +++ b/enigme.java/Description.java @@ -8,4 +8,9 @@ public class Description { this.texte = texte; this.condition = condition; } + + @Override + public String toString() { + return this.texte; + } } diff --git a/enigme.java/Interaction.java b/enigme.java/Interaction.java index 0a7d999..806b3db 100644 --- a/enigme.java/Interaction.java +++ b/enigme.java/Interaction.java @@ -22,14 +22,14 @@ public class Interaction { @Override public String toString() { - String res = ""; + String res = "Interraction :"; int k = 0; - for (Action a : i.actions) { + for (Action a : this.actions) { if (a.visible.evaluer()) { - res += k + " " + a + "\n"; + res += "\n" + k + " " + a; k++; } } - return super.toString(); + return res; } } diff --git a/enigme.java/Jeu.java b/enigme.java/Jeu.java index c293fd4..ad7e006 100644 --- a/enigme.java/Jeu.java +++ b/enigme.java/Jeu.java @@ -45,6 +45,7 @@ public class Jeu { if (p.visible.evaluer() && p.obligatoire.evaluer()) { for (Interaction i : p.interractions) { if (i.visible.evaluer()) { + System.out.println(i); boolean arreter_interraction = false; while (!arreter_interraction) { List actions_choix = new ArrayList<>(); @@ -94,15 +95,29 @@ public class Jeu { } if (!chemin_pris) { + int k = 0; List chemins_choix = new ArrayList<>(); for (Chemin c : territoire.chemins) { if (c.lieuIn == lieu) { if (c.visible.evaluer() && c.ouvert.evaluer()) { chemins_choix.add(c); - System.out.println(c); + System.out.println(k + " " + c); + k++; } } } + + List personnes_choix = new ArrayList<>(); + for (Personne p : personnes) { + if (lieu.personnes.contains(p)) { + if (p.visible.evaluer()) { + personnes_choix.add(p); + System.out.println(p); + k++; + } + } + } + int choix = 0; try { choix = Integer.parseInt(reader.readLine()); @@ -111,7 +126,11 @@ public class Jeu { } catch (IOException e) { e.printStackTrace(); } - lieu = chemins_choix.get(choix).lieuOut; + if (choix < chemins_choix.size()) { + lieu = chemins_choix.get(choix).lieuOut; + } else { + + } } } @@ -187,26 +206,38 @@ public class Jeu { connaissances_action_reussite.add(reussite_connaissance); + List action_reussite_descriptions = new ArrayList<>(); + + action_reussite_descriptions.add(new Description( + "Wsh jveux réussir, rwwwwwit *TOCC* NOICE", + vraie)); + Action action_reussite = new Action( vraie, connaissances_action_reussite, new ArrayList<>(), new ArrayList<>(), vraie, - new ArrayList<>()); + action_reussite_descriptions); sphinx_interaction_actions.add(action_reussite); List objets_action_echec = new ArrayList<>(); objets_action_echec.add(tentative_objet); + List action_echec_descriptions = new ArrayList<>(); + + action_echec_descriptions.add(new Description( + "Vive la défaite ! dommage (PS: JSON c B1 hein) :)", + vraie)); + Action action_echec = new Action( vraie, new ArrayList<>(), new ArrayList<>(), objets_action_echec, vraie, - new ArrayList<>()); + action_echec_descriptions); sphinx_interaction_actions.add(action_echec); Interaction sphinx_interaction = new Interaction(