LesSyms4/src/SimulationJeu.java

69 lines
1.7 KiB
Java
Raw Normal View History

2015-01-07 09:41:16 +00:00
import Cases.CaseAbstraite;
2014-12-03 08:13:23 +00:00
import Fabriques.Scenario.FabriqueScenarioAbstraite;
2015-02-07 10:35:29 +00:00
import Observateur.Arbitre;
2014-12-03 08:13:23 +00:00
import Person.Personnage;
import utils.InterfaceConsole;
2014-10-03 13:34:03 +00:00
import java.util.ArrayList;
2015-01-07 09:41:16 +00:00
import java.util.Scanner;
2014-10-03 13:34:03 +00:00
2015-01-20 18:16:30 +00:00
2015-02-08 08:30:03 +00:00
class SimulationJeu {
private final CaseAbstraite[][] plateau;
private final FabriqueScenarioAbstraite f;
private final InterfaceConsole intefaceC;
private final Arbitre a;
private ArrayList<Personnage> personnages;
2015-01-20 18:16:30 +00:00
2014-12-03 08:13:23 +00:00
public SimulationJeu(FabriqueScenarioAbstraite fb) {
f = fb;
2015-01-07 09:41:16 +00:00
personnages = new ArrayList<Personnage>();
plateau = f.CreerPlateau();
2015-02-07 10:35:29 +00:00
personnages = f.CreerPersonnages(plateau);
2015-01-07 09:41:16 +00:00
2015-02-01 14:27:28 +00:00
f.creerObjets(plateau);
intefaceC = new InterfaceConsole(plateau);
2015-02-07 10:35:29 +00:00
a = new Arbitre();
2014-10-03 13:34:03 +00:00
}
2015-02-08 08:30:03 +00:00
void afficheTous() {
System.out.println("");
intefaceC.afficherPlateau();
2014-10-03 13:34:03 +00:00
}
2015-02-08 08:30:03 +00:00
void recupererInformations() {
2015-01-31 10:03:59 +00:00
for (Personnage p : personnages) {
2015-02-08 08:30:03 +00:00
p.afficherInfos();
}
2014-10-03 13:34:03 +00:00
}
2015-01-07 09:41:16 +00:00
public void lancerJeu() {
2015-02-07 10:35:29 +00:00
for (Personnage p : personnages) {
a.attach(p);
}
2015-01-07 09:41:16 +00:00
boolean continuer = true;
afficheTous();
2015-01-07 09:41:16 +00:00
while (continuer) {
2015-02-07 10:35:29 +00:00
a.update();
2015-01-07 09:41:16 +00:00
for (Personnage p : personnages) {
p.Execution(p.AnalyseSituation());
2015-01-07 09:41:16 +00:00
recupererInformations();
}
2015-02-01 13:37:33 +00:00
f.tourParTour(plateau);
afficheTous();
2015-02-01 13:37:33 +00:00
2015-01-07 09:41:16 +00:00
// bloquer le tour jusqu'a toucher une touche du clavier.
Scanner s = new Scanner(System.in);
2015-02-08 08:04:20 +00:00
String choix = s.nextLine();
2015-02-08 08:30:03 +00:00
if (choix.equals("s")) {
2015-02-08 08:04:20 +00:00
continuer = false;
}
2014-10-03 13:34:03 +00:00
}
2015-01-07 09:41:16 +00:00
2014-10-03 13:34:03 +00:00
}
}