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

plateau qui marche

parent 07c805be
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ public class Crown extends Items{
this.setItemCase(null);
System.out.println(item.getName());
unite.setItem(item);
unite.setSymbol('c');
unite.setSymbol('');
unite.getPlateau().getCase(unite.getX(), unite.getY()).setItem(null);
}
......
......@@ -78,12 +78,11 @@ public class Case {
}
public String toString() {
/*
if (!this.isDecouverte()) {
return "~ ";
}
else */if (this.getItem() != null && this.getItem().getName().equalsIgnoreCase("crown")) {
return "c ";
else if (this.getItem() != null && this.getItem().getName().equalsIgnoreCase("crown")) {
return " ";
}
else if (this.type == Type.GRASS) {
return ". ";
......@@ -92,7 +91,7 @@ public class Case {
return "m ";
}
else if (this.type == Type.FORT) {
return "t ";
return " ";
}
else if (this.type == Type.CAMP) {
return "O ";
......
package units;
import java.util.List;
import java.util.Random;
import events.Evenements;
import items.Items;
import main.Case;
import main.Joueur;
......@@ -21,6 +23,7 @@ public abstract class Unite {
private Joueur joueur;
private Items item;
private Type temp = Type.GRASS;
private Type temp2 = null;
public Unite(int x, int y, Plateau plateau, char symbol, int armor, int damage, Joueur joueur, int vision) {
this.id = generalId;
......@@ -115,13 +118,20 @@ public abstract class Unite {
public boolean updatePosition(int x,int y) {
if(x>=0 && x<(plateau.getPlateau().length*plateau.getRegion(0, 0).region.length-1) && y>=0 && y<(plateau.getPlateau().length*plateau.getRegion(0, 0).region.length-1) ) {
this.plateau.getCase(x, y).setUnite(this);
temp = this.plateau.getCase(x, y).getType();
this.plateau.getCase(x, y).setType(Type.UNITE);
/*if(this.plateau.getCase(x, y).getEvents().length > 0){
System.out.println("oui");
}*/
return true;
if(this.plateau.getCase(x, y).getType() != Type.MOUNTAIN) {
temp2 = temp;
temp = this.plateau.getCase(x, y).getType();
this.plateau.getCase(x, y).setUnite(this);
System.out.println(temp);
this.plateau.getCase(x, y).setType(Type.UNITE);
if(this.plateau.getCase(x, y).getEvents().size() > 0){
List<Evenements> temp = this.plateau.getCase(x, y).getEvents();
for (Evenements evenements : temp) {
evenements.action(this.plateau.getCase(x, y));
}
}
return true;
}
}
return false;
}
......@@ -142,7 +152,7 @@ public abstract class Unite {
}*/
if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp);
this.plateau.getCase(x, y).setType(temp2);
this.x+=1;
updateDecouverte(this.plateau.getCase(x+1, y), this.vision);
updateItem();
......@@ -152,7 +162,7 @@ public abstract class Unite {
else if(c == 'd') {
if (updatePosition(x,y+1)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp);
this.plateau.getCase(x, y).setType(temp2);
this.y+=1;
updateDecouverte(this.plateau.getCase(x, y+1), this.vision);
updateItem();
......@@ -162,7 +172,7 @@ public abstract class Unite {
else if(c == 'q') {
if (updatePosition(x,y-1)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp);
this.plateau.getCase(x, y).setType(temp2);
this.y-=1;
updateDecouverte(this.plateau.getCase(x, y-1), this.vision);
updateItem();
......@@ -172,7 +182,7 @@ public abstract class Unite {
else if(c == 'z') {
if (updatePosition(x-1, y)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp);
this.plateau.getCase(x, y).setType(temp2);
this.x-=1;
updateDecouverte(this.plateau.getCase(x-1, y), this.vision);
updateItem();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment