2021-12-01 19:55:46 +00:00
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.IOException;
|
2021-12-01 08:48:38 +00:00
|
|
|
import java.util.ArrayList;
|
2021-12-01 12:54:02 +00:00
|
|
|
import java.util.List;
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-11-30 19:49:01 +00:00
|
|
|
public class Jeu {
|
2021-11-30 22:02:55 +00:00
|
|
|
public static Explorateur explorateur;
|
2021-11-30 19:49:01 +00:00
|
|
|
Territoire territoire;
|
2021-12-01 07:58:07 +00:00
|
|
|
List<Objet> objets;
|
|
|
|
List<Connaissance> connaissances;
|
|
|
|
List<Personne> personnes;
|
|
|
|
List<Transformation> transformations;
|
2021-11-30 19:49:01 +00:00
|
|
|
|
|
|
|
public Jeu(
|
|
|
|
Territoire territoire,
|
2021-12-01 07:58:07 +00:00
|
|
|
List<Objet> objets,
|
|
|
|
List<Connaissance> connaissances,
|
|
|
|
List<Personne> personnes,
|
|
|
|
List<Transformation> transformations) {
|
2021-11-30 19:49:01 +00:00
|
|
|
this.territoire = territoire;
|
|
|
|
this.objets = objets;
|
|
|
|
this.connaissances = connaissances;
|
|
|
|
this.personnes = personnes;
|
|
|
|
this.transformations = transformations;
|
|
|
|
}
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
void jouer() {
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
|
|
|
|
|
|
|
Lieu lieu = null;
|
|
|
|
for (Lieu l : territoire.lieux) {
|
|
|
|
if (l.depart.evaluer()) {
|
|
|
|
lieu = l;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!lieu.fin.evaluer()) {
|
2021-12-02 13:23:06 +00:00
|
|
|
boolean recommencer = false;
|
|
|
|
|
|
|
|
System.out.println("\n\n\n\n\n\n\n\n\n\nLieu : " + lieu + "\n");
|
2021-12-01 19:55:46 +00:00
|
|
|
System.out.println(Jeu.explorateur);
|
2021-12-02 13:23:06 +00:00
|
|
|
|
|
|
|
for (Personne p : lieu.personnes) {
|
|
|
|
if (p.visible.evaluer() && p.obligatoire.evaluer()) {
|
|
|
|
System.out.println(p + " :");
|
|
|
|
|
|
|
|
p.interragir(reader, lieu);
|
|
|
|
recommencer = true;
|
|
|
|
break;
|
2021-12-01 19:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-02 13:23:06 +00:00
|
|
|
if (recommencer) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-12-01 19:55:46 +00:00
|
|
|
|
|
|
|
for (Chemin c : territoire.chemins) {
|
|
|
|
if (c.lieuIn == lieu) {
|
|
|
|
if (c.visible.evaluer() && c.obligatoire.evaluer() && c.ouvert.evaluer()) {
|
|
|
|
lieu = c.lieuOut;
|
2021-12-02 13:23:06 +00:00
|
|
|
recommencer = true;
|
|
|
|
break;
|
2021-12-01 19:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-02 13:23:06 +00:00
|
|
|
if (recommencer) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-12-01 19:55:46 +00:00
|
|
|
|
2021-12-02 13:23:06 +00:00
|
|
|
int k = 0;
|
|
|
|
List<Chemin> 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("[" + k + "] " + c);
|
|
|
|
k++;
|
2021-12-01 19:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-02 13:23:06 +00:00
|
|
|
}
|
2021-12-01 20:19:08 +00:00
|
|
|
|
2021-12-02 13:23:06 +00:00
|
|
|
List<Personne> personnes_choix = new ArrayList<>();
|
|
|
|
for (Personne p : personnes) {
|
|
|
|
if (lieu.personnes.contains(p)) {
|
|
|
|
if (p.visible.evaluer()) {
|
|
|
|
personnes_choix.add(p);
|
|
|
|
System.out.println("[" + k + "] " + p);
|
|
|
|
k++;
|
2021-12-01 20:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-02 13:23:06 +00:00
|
|
|
}
|
2021-12-01 20:19:08 +00:00
|
|
|
|
2021-12-02 13:23:06 +00:00
|
|
|
int choix = 0;
|
|
|
|
try {
|
|
|
|
System.out.print("\nChoix : ");
|
|
|
|
choix = Integer.parseInt(reader.readLine());
|
2021-12-01 20:19:08 +00:00
|
|
|
if (choix < chemins_choix.size()) {
|
|
|
|
lieu = chemins_choix.get(choix).lieuOut;
|
|
|
|
} else {
|
2021-12-02 13:23:06 +00:00
|
|
|
Personne p = personnes_choix.get(choix - chemins_choix.size());
|
|
|
|
|
|
|
|
System.out.println("\n\n\n\n\n\n\n\n\n\nLieu : " + lieu + "\n");
|
|
|
|
System.out.println(Jeu.explorateur);
|
|
|
|
System.out.println(p + " :");
|
2021-12-01 20:19:08 +00:00
|
|
|
|
2021-12-02 13:23:06 +00:00
|
|
|
p.interragir(reader, lieu);
|
2021-12-01 20:19:08 +00:00
|
|
|
}
|
2021-12-02 13:23:06 +00:00
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
continue;
|
|
|
|
} catch (IndexOutOfBoundsException e) {
|
|
|
|
continue;
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
2021-12-01 19:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("FIN : " + lieu.nom);
|
|
|
|
}
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
public static void main(String[] args) {
|
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
// raccourcis "true" "false"
|
2021-12-01 08:48:38 +00:00
|
|
|
Condition faux = new Condition(new ConditionEt(new ConditionBoolean(false)));
|
|
|
|
Condition vraie = new Condition(new ConditionEt(new ConditionBoolean(true)));
|
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
// "Objets": [
|
|
|
|
|
|
|
|
List<Objet> jeu_objets = new ArrayList<>();
|
|
|
|
|
|
|
|
Objet tentative_objet = new Objet(
|
|
|
|
"tentative",
|
|
|
|
1,
|
|
|
|
vraie,
|
|
|
|
new ArrayList<>());
|
|
|
|
jeu_objets.add(tentative_objet);
|
|
|
|
|
|
|
|
// "Connaissances" : [
|
|
|
|
|
|
|
|
List<Connaissance> jeu_connaissances = new ArrayList<>();
|
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
Connaissance reussite_connaissance = new Connaissance(
|
2021-12-01 12:54:02 +00:00
|
|
|
"Réussite",
|
|
|
|
vraie,
|
|
|
|
new ArrayList<>());
|
|
|
|
jeu_connaissances.add(reussite_connaissance);
|
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
// Conditions
|
|
|
|
|
|
|
|
Condition condition0 = new Condition(new ConditionEt(
|
|
|
|
new ConditionConnaissance(reussite_connaissance, true),
|
|
|
|
new ConditionObjet(tentative_objet, ">", 0)));
|
|
|
|
Condition condition1 = new Condition(new ConditionEt(
|
|
|
|
new ConditionObjet(tentative_objet, ">", 0)));
|
|
|
|
Condition condition2 = new Condition(new ConditionEt(
|
|
|
|
new ConditionConnaissance(reussite_connaissance, true)));
|
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
// "Transformations" : [
|
|
|
|
|
|
|
|
List<Transformation> transformations = new ArrayList<>();
|
|
|
|
|
|
|
|
// "Explorateur" : [
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
int explorateur_tailleInventaire = 3;
|
2021-12-01 19:55:46 +00:00
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
List<Objet> explorateur_inventaire = new ArrayList<>();
|
2021-12-01 19:55:46 +00:00
|
|
|
explorateur_inventaire.add(tentative_objet);
|
|
|
|
explorateur_inventaire.add(tentative_objet);
|
|
|
|
explorateur_inventaire.add(tentative_objet);
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
List<Connaissance> explorateur_connaissances = new ArrayList<>();
|
2021-12-01 19:55:46 +00:00
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
Jeu.explorateur = new Explorateur(
|
|
|
|
explorateur_tailleInventaire,
|
2021-12-01 19:55:46 +00:00
|
|
|
explorateur_connaissances,
|
|
|
|
explorateur_inventaire);
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
// "Personnes" : [
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
List<Personne> jeu_personnes = new ArrayList<>();
|
2021-12-01 08:48:38 +00:00
|
|
|
|
|
|
|
List<Interaction> sphinx_interactions = new ArrayList<>();
|
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
List<Action> sphinx_interaction_actions = new ArrayList<>();
|
|
|
|
|
|
|
|
List<Connaissance> connaissances_action_reussite = new ArrayList<>();
|
|
|
|
|
|
|
|
connaissances_action_reussite.add(reussite_connaissance);
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 20:19:08 +00:00
|
|
|
List<Description> action_reussite_descriptions = new ArrayList<>();
|
|
|
|
|
|
|
|
action_reussite_descriptions.add(new Description(
|
|
|
|
"Wsh jveux réussir, rwwwwwit *TOCC* NOICE",
|
|
|
|
vraie));
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
Action action_reussite = new Action(
|
|
|
|
vraie,
|
2021-12-01 19:55:46 +00:00
|
|
|
connaissances_action_reussite,
|
2021-12-01 08:48:38 +00:00
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
2021-12-01 19:55:46 +00:00
|
|
|
vraie,
|
2021-12-01 20:19:08 +00:00
|
|
|
action_reussite_descriptions);
|
2021-12-01 08:48:38 +00:00
|
|
|
sphinx_interaction_actions.add(action_reussite);
|
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
List<Objet> objets_action_echec = new ArrayList<>();
|
|
|
|
|
|
|
|
objets_action_echec.add(tentative_objet);
|
|
|
|
|
2021-12-01 20:19:08 +00:00
|
|
|
List<Description> action_echec_descriptions = new ArrayList<>();
|
|
|
|
|
|
|
|
action_echec_descriptions.add(new Description(
|
|
|
|
"Vive la défaite ! dommage (PS: JSON c B1 hein) :)",
|
|
|
|
vraie));
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
Action action_echec = new Action(
|
|
|
|
vraie,
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
2021-12-01 19:55:46 +00:00
|
|
|
objets_action_echec,
|
|
|
|
vraie,
|
2021-12-01 20:19:08 +00:00
|
|
|
action_echec_descriptions);
|
2021-12-01 08:48:38 +00:00
|
|
|
sphinx_interaction_actions.add(action_echec);
|
|
|
|
|
|
|
|
Interaction sphinx_interaction = new Interaction(
|
|
|
|
vraie,
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
2021-12-01 19:55:46 +00:00
|
|
|
new ArrayList<>(),
|
|
|
|
sphinx_interaction_actions);
|
2021-12-01 08:48:38 +00:00
|
|
|
sphinx_interactions.add(sphinx_interaction);
|
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
Personne sphinx_personne = new Personne(
|
2021-12-01 08:48:38 +00:00
|
|
|
"Sphinx",
|
2021-12-01 19:55:46 +00:00
|
|
|
condition0,
|
2021-12-01 08:48:38 +00:00
|
|
|
vraie,
|
|
|
|
sphinx_interactions);
|
2021-12-01 19:55:46 +00:00
|
|
|
jeu_personnes.add(sphinx_personne);
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
// "Territoire" : {
|
2021-12-01 12:54:02 +00:00
|
|
|
|
|
|
|
List<Lieu> lieux = new ArrayList<>();
|
|
|
|
|
|
|
|
List<Personne> debut_personnes = new ArrayList<>();
|
2021-12-01 19:55:46 +00:00
|
|
|
debut_personnes.add(sphinx_personne);
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
Lieu enigme = new Lieu(
|
|
|
|
"Énigme",
|
2021-12-01 08:48:38 +00:00
|
|
|
faux,
|
|
|
|
vraie,
|
|
|
|
faux,
|
|
|
|
debut_personnes,
|
2021-12-01 12:54:02 +00:00
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>());
|
2021-12-01 19:55:46 +00:00
|
|
|
lieux.add(enigme);
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
Lieu succes = new Lieu(
|
2021-12-01 12:54:02 +00:00
|
|
|
"Succès",
|
|
|
|
faux,
|
|
|
|
faux,
|
|
|
|
vraie,
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>());
|
|
|
|
lieux.add(succes);
|
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
Lieu echec = new Lieu(
|
2021-12-01 12:54:02 +00:00
|
|
|
"Échec",
|
|
|
|
faux,
|
|
|
|
faux,
|
|
|
|
vraie,
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>());
|
|
|
|
lieux.add(echec);
|
|
|
|
|
|
|
|
List<Chemin> chemins = new ArrayList<>();
|
|
|
|
|
2021-12-02 13:23:06 +00:00
|
|
|
List<Description> descriptions_chemin_enigme_succes = new ArrayList<>();
|
|
|
|
|
|
|
|
descriptions_chemin_enigme_succes.add(new Description("Route du succes", vraie));
|
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
Chemin enigme_succes = new Chemin(
|
2021-12-01 19:55:46 +00:00
|
|
|
enigme,
|
2021-12-01 12:54:02 +00:00
|
|
|
succes,
|
|
|
|
vraie,
|
2021-12-01 19:55:46 +00:00
|
|
|
condition1,
|
|
|
|
vraie,
|
2021-12-01 12:54:02 +00:00
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
2021-12-02 13:23:06 +00:00
|
|
|
descriptions_chemin_enigme_succes);
|
2021-12-01 12:54:02 +00:00
|
|
|
chemins.add(enigme_succes);
|
|
|
|
|
2021-12-02 13:23:06 +00:00
|
|
|
List<Description> descriptions_chemin_enigme_echec = new ArrayList<>();
|
|
|
|
|
|
|
|
descriptions_chemin_enigme_echec.add(new Description("Chemin de la mort", vraie));
|
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
Chemin enigme_echec = new Chemin(
|
2021-12-01 19:55:46 +00:00
|
|
|
enigme,
|
2021-12-01 12:54:02 +00:00
|
|
|
echec,
|
|
|
|
vraie,
|
2021-12-01 19:55:46 +00:00
|
|
|
condition2,
|
|
|
|
vraie,
|
2021-12-01 12:54:02 +00:00
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(),
|
2021-12-02 13:23:06 +00:00
|
|
|
descriptions_chemin_enigme_echec);
|
2021-12-01 12:54:02 +00:00
|
|
|
chemins.add(enigme_echec);
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
Territoire territoire = new Territoire(
|
|
|
|
lieux,
|
|
|
|
chemins);
|
|
|
|
|
2021-12-01 12:54:02 +00:00
|
|
|
Jeu jeu = new Jeu(
|
|
|
|
territoire,
|
|
|
|
jeu_objets,
|
|
|
|
jeu_connaissances,
|
2021-12-01 19:55:46 +00:00
|
|
|
jeu_personnes,
|
2021-12-01 12:54:02 +00:00
|
|
|
transformations);
|
2021-12-01 08:48:38 +00:00
|
|
|
|
2021-12-01 19:55:46 +00:00
|
|
|
jeu.jouer();
|
|
|
|
|
2021-12-01 08:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-30 22:02:55 +00:00
|
|
|
}
|