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