Skip to content
Snippets Groups Projects
Commit 6f6cbd7a authored by Maxime Wallart's avatar Maxime Wallart :speech_balloon:
Browse files

Merge branch 'Maxime'

parents ab0dfb19 9d1a5a5c
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ public class Main {
while(y<30) {
winner.getArmee().get(0).move(deplacement());
System.out.println('\n');
winner.getArmee().get(0).teleporte();
Affichage.affichage(plateau);
}
Menu();
......
package units;
import java.util.Random;
import items.Items;
import main.Affichage;
import main.Case;
......@@ -128,6 +130,9 @@ public abstract class Unite {
//à voir le type
public boolean move(char c) {
if(c == 's') {
/*if (plateau.getCase(x+1,y).getUnite() != null) {
combat();
}*/
if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(Type.GRASS);
......@@ -162,6 +167,23 @@ public abstract class Unite {
return false;
}
public void teleporte() {
Random alea = new Random();
int longueur = plateau.getPlateau().length*plateau.getRegion(0, 0).region.length;
int rd1 = alea.nextInt(longueur);
int rd2 = alea.nextInt(longueur);
while(plateau.getCase(rd1, rd2).getType()!=Type.GRASS) {
rd1 = alea.nextInt(longueur);
rd2 = alea.nextInt(longueur);
}
updatePosition(rd1,rd2);
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(Type.GRASS);
this.x=rd1;
this.y=rd2;
}
public abstract String toString();
public abstract boolean action();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment