Placement des objets au hasard. Peut etre besoin d'une factory.
This commit is contained in:
parent
8e08b9c8df
commit
f6da70c020
@ -3,7 +3,7 @@ package Objets;
|
||||
public class ObjetAvecBonusForce extends ObjetAbstrait {
|
||||
|
||||
|
||||
protected ObjetAvecBonusForce(String name, double lifePoint,
|
||||
public ObjetAvecBonusForce(String name, double lifePoint,
|
||||
double strength, double speed) {
|
||||
super(name, lifePoint, strength, speed);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
@ -2,7 +2,7 @@ package Objets;
|
||||
|
||||
public class ObjetAvecBonusPV extends ObjetAbstrait {
|
||||
|
||||
protected ObjetAvecBonusPV(String name, double lifePoint, double strength,
|
||||
public ObjetAvecBonusPV(String name, double lifePoint, double strength,
|
||||
double speed) {
|
||||
super(name, lifePoint, strength, speed);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
@ -2,7 +2,7 @@ package Objets;
|
||||
|
||||
public class ObjetAvecBonusVitesse extends ObjetAbstrait {
|
||||
|
||||
protected ObjetAvecBonusVitesse(String name, double lifePoint,
|
||||
public ObjetAvecBonusVitesse(String name, double lifePoint,
|
||||
double strength, double speed) {
|
||||
super(name, lifePoint, strength, speed);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
@ -1,6 +1,9 @@
|
||||
import Cases.CaseAbstraite;
|
||||
import Fabriques.Scenario.FabriqueScenarioAbstraite;
|
||||
import Objets.ObjetAbstrait;
|
||||
import Objets.ObjetAvecBonusForce;
|
||||
import Objets.ObjetAvecBonusPV;
|
||||
import Objets.ObjetAvecBonusVitesse;
|
||||
import Observateur.Organisation;
|
||||
import Person.Personnage;
|
||||
import utils.InterfaceConsole;
|
||||
@ -52,6 +55,7 @@ public class SimulationJeu {
|
||||
p.Execution(t);
|
||||
recupererInformations();
|
||||
}
|
||||
placerDesObjets();
|
||||
afficheTous();
|
||||
// bloquer le tour jusqu'a toucher une touche du clavier.
|
||||
Scanner s = new Scanner(System.in);
|
||||
@ -60,6 +64,21 @@ public class SimulationJeu {
|
||||
|
||||
}
|
||||
|
||||
private void placerDesObjets() {
|
||||
if (new Random().nextInt(2) == 1) {
|
||||
if (new Random().nextInt(3) == 1) {
|
||||
placementObjet(new ObjetAvecBonusPV("Toto", 10, 10, 10));
|
||||
}
|
||||
if (new Random().nextInt(3) == 2) {
|
||||
placementObjet(new ObjetAvecBonusVitesse("Toto", 10, 10, 10));
|
||||
|
||||
}
|
||||
if (new Random().nextInt(3) == 3) {
|
||||
placementObjet(new ObjetAvecBonusForce("tptp", 10, 10, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void placement() {
|
||||
Random rand = new Random();
|
||||
for (Personnage p : personnages) {
|
||||
@ -70,6 +89,14 @@ public class SimulationJeu {
|
||||
}
|
||||
}
|
||||
|
||||
private void placementObjet(ObjetAbstrait o) {
|
||||
Random rand = new Random();
|
||||
int x = rand.nextInt(plateau.length);
|
||||
int y = rand.nextInt(plateau[x].length);
|
||||
o.setCaseCourante(plateau[x][y]);
|
||||
plateau[x][y].setObjetOccupant(o);
|
||||
}
|
||||
|
||||
// Todo Save
|
||||
private void enregistrerSimulation(String NomFichier) {
|
||||
// Todo
|
||||
|
@ -12,8 +12,9 @@ public class InterfaceConsole {
|
||||
public void afficherPlateau() {
|
||||
for (CaseAbstraite[] aPlateau : plateau) {
|
||||
for (CaseAbstraite anAPlateau : aPlateau) {
|
||||
if (anAPlateau.getOccupant() != null) {
|
||||
System.out.print(anAPlateau.getOccupant().getNom().charAt(0) + " | ");
|
||||
if (anAPlateau.getOccupant() != null || anAPlateau.getObjetOccupant() != null) {
|
||||
char occ = ((anAPlateau.getOccupant() != null) ? anAPlateau.getOccupant().getNom().charAt(0) : anAPlateau.getObjetOccupant().getNom().charAt(0));
|
||||
System.out.print(occ + " | ");
|
||||
} else {
|
||||
System.out.print(" " + anAPlateau.affichageSpecial() + " | ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user