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

update move

parent a35b27cd
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,13 @@ public class Main { ...@@ -16,9 +16,13 @@ public class Main {
}*/ }*/
Plateau plateau = new Plateau(); Plateau plateau = new Plateau();
plateau.getCase(12, 7).setUnite(new Paysant(plateau.getCase(12, 7), plateau, winner)); int x = 11;
int y = 0;
plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner));
Affichage.affichage(plateau);
plateau.getCase(x, y).getUnite().move(Direction.HAUT);
System.out.println('\n');
Affichage.affichage(plateau); Affichage.affichage(plateau);
} }
private Joueur Game (Joueur[] joueurs) { private Joueur Game (Joueur[] joueurs) {
......
...@@ -13,8 +13,8 @@ public class Paysant extends Unite{ ...@@ -13,8 +13,8 @@ public class Paysant extends Unite{
public static final char SYMBOL = 'p'; public static final char SYMBOL = 'p';
public static final int PATOGIVE = 1; public static final int PATOGIVE = 1;
public Paysant(Case caseUnit, Plateau plateau, Joueur joueur) { public Paysant(int x, int y, Plateau plateau, Joueur joueur) {
super(caseUnit, plateau, SYMBOL, ARMOR, DAMAGE, joueur); super(x, y, plateau, SYMBOL, ARMOR, DAMAGE, joueur);
} }
...@@ -49,7 +49,7 @@ public class Paysant extends Unite{ ...@@ -49,7 +49,7 @@ public class Paysant extends Unite{
sc.close(); sc.close();
return true; return true;
}else { }else {
//TODO:utiliser un systme de vrification d'entre globale //TODO:utiliser un systme de vrification d'entre globale
System.out.println("ERROR"); System.out.println("ERROR");
} }
...@@ -59,7 +59,7 @@ public class Paysant extends Unite{ ...@@ -59,7 +59,7 @@ public class Paysant extends Unite{
} }
public void combattre() { public void combattre() {
//TODO: il faut d'abord regarder si une unit est prsente autour //TODO: il faut d'abord regarder si une unit est prsente autour
} }
public void actionGivePA() { public void actionGivePA() {
......
...@@ -20,15 +20,15 @@ public abstract class Unite { ...@@ -20,15 +20,15 @@ public abstract class Unite {
private Joueur joueur; private Joueur joueur;
private Items item; private Items item;
public Unite(Case caseUnit, Plateau plateau, char symbol, int armor, int damage, Joueur joueur) { public Unite(int x, int y, Plateau plateau, char symbol, int armor, int damage, Joueur joueur) {
this.id = generalId; this.id = generalId;
generalId++; generalId++;
this.plateau = plateau; this.plateau = plateau;
this.symbol = symbol; this.symbol = symbol;
this.armor = armor; this.armor = armor;
this.damage = damage; this.damage = damage;
this.x = 14; this.x = x;
this.y = 28; this.y = y;
this.joueur = joueur; this.joueur = joueur;
this.item = null; this.item = null;
} }
...@@ -110,7 +110,7 @@ public abstract class Unite { ...@@ -110,7 +110,7 @@ public abstract class Unite {
} }
public boolean updatePosition(int x,int y) { public boolean updatePosition(int x,int y) {
if(this.plateau.getCase(x, y)!=null) { if(x>=0 && x<plateau.getPlateau().length*plateau.getRegion(0, 0).region.length && y>=0 && y<plateau.getPlateau().length*plateau.getRegion(0, 0).region.length ) {
this.plateau.getCase(x, y).setUnite(this); this.plateau.getCase(x, y).setUnite(this);
this.plateau.getCase(x, y).setType(Type.UNITE); this.plateau.getCase(x, y).setType(Type.UNITE);
if(this.plateau.getCase(x, y).isDecouverte()==false) { if(this.plateau.getCase(x, y).isDecouverte()==false) {
...@@ -118,34 +118,39 @@ public abstract class Unite { ...@@ -118,34 +118,39 @@ public abstract class Unite {
} }
if(this.plateau.getCase(x, y).getEvent() == Event.FORT) { if(this.plateau.getCase(x, y).getEvent() == Event.FORT) {
this.plateau.getRegion(x, y).setProprietaire(joueur); this.plateau.getRegion(x, y).setProprietaire(joueur);
this.joueur.getRoyaume().add(this.plateau.getRegion(x, y)); //this.joueur.getRoyaume().add(this.plateau.getRegion(x, y));
} }
return true; return true;
} }
return false; return false;
} }
//à voir le type //à voir le type
public void move(Direction d) { public boolean move(Direction d) {
if(d == Direction.BAS) { if(d == Direction.BAS) {
if (updatePosition(x,y+1)) { if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true;
} }
} }
else if(d == Direction.DROITE) { else if(d == Direction.DROITE) {
if (updatePosition(x+1,y)) { if (updatePosition(x,y+1)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true;
} }
} }
else if(d == Direction.GAUCHE) { else if(d == Direction.GAUCHE) {
if (updatePosition(x-1,y)) { if (updatePosition(x,y-1)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true;
} }
} }
else if(d == Direction.HAUT) { else if(d == Direction.HAUT) {
if (updatePosition(x, y-1)) { if (updatePosition(x-1, y)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true;
} }
} }
return false;
} }
public abstract String toString(); public abstract String toString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment