Skip to content
Snippets Groups Projects
Commit 0233c3e3 authored by CARION Baptiste's avatar CARION Baptiste
Browse files
parents d421f2f7 3a742f8c
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ public class Crown extends Items{ ...@@ -24,7 +24,7 @@ public class Crown extends Items{
this.setItemCase(null); this.setItemCase(null);
System.out.println(item.getName()); System.out.println(item.getName());
unite.setItem(item); unite.setItem(item);
unite.setSymbol('c'); unite.setSymbol('');
unite.getPlateau().getCase(unite.getX(), unite.getY()).setItem(null); unite.getPlateau().getCase(unite.getX(), unite.getY()).setItem(null);
} }
......
...@@ -99,12 +99,11 @@ public class Case { ...@@ -99,12 +99,11 @@ public class Case {
} }
public String toString() { public String toString() {
/*
if (!this.isDecouverte()) { if (!this.isDecouverte()) {
return "~ "; return "~ ";
} }
else */if (this.getItem() != null && this.getItem().getName().equalsIgnoreCase("crown")) { else if (this.getItem() != null && this.getItem().getName().equalsIgnoreCase("crown")) {
return "c "; return " ";
} }
else if (this.type == Type.GRASS) { else if (this.type == Type.GRASS) {
return ". "; return ". ";
...@@ -113,7 +112,7 @@ public class Case { ...@@ -113,7 +112,7 @@ public class Case {
return "m "; return "m ";
} }
else if (this.type == Type.FORT) { else if (this.type == Type.FORT) {
return "t "; return " ";
} }
else if (this.type == Type.CAMP) { else if (this.type == Type.CAMP) {
return "O "; return "O ";
......
package units; package units;
import java.util.List;
import java.util.Random; import java.util.Random;
import events.Evenements;
import items.Items; import items.Items;
import main.Case; import main.Case;
import main.Joueur; import main.Joueur;
...@@ -21,6 +23,7 @@ public abstract class Unite { ...@@ -21,6 +23,7 @@ public abstract class Unite {
private Joueur joueur; private Joueur joueur;
private Items item; private Items item;
private Type temp = Type.GRASS; 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) { public Unite(int x, int y, Plateau plateau, char symbol, int armor, int damage, Joueur joueur, int vision) {
this.id = generalId; this.id = generalId;
...@@ -115,13 +118,20 @@ public abstract class Unite { ...@@ -115,13 +118,20 @@ public abstract class Unite {
public boolean updatePosition(int x,int y) { 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) ) { 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); if(this.plateau.getCase(x, y).getType() != Type.MOUNTAIN) {
temp = this.plateau.getCase(x, y).getType(); temp2 = temp;
this.plateau.getCase(x, y).setType(Type.UNITE); temp = this.plateau.getCase(x, y).getType();
/*if(this.plateau.getCase(x, y).getEvents().length > 0){ this.plateau.getCase(x, y).setUnite(this);
System.out.println("oui"); System.out.println(temp);
}*/ this.plateau.getCase(x, y).setType(Type.UNITE);
return true; 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; return false;
} }
...@@ -142,7 +152,7 @@ public abstract class Unite { ...@@ -142,7 +152,7 @@ public abstract class Unite {
}*/ }*/
if (updatePosition(x+1,y)) { if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp); this.plateau.getCase(x, y).setType(temp2);
this.x+=1; this.x+=1;
updateDecouverte(this.plateau.getCase(x+1, y), this.vision); updateDecouverte(this.plateau.getCase(x+1, y), this.vision);
updateItem(); updateItem();
...@@ -152,7 +162,7 @@ public abstract class Unite { ...@@ -152,7 +162,7 @@ public abstract class Unite {
else if(c == 'd') { else if(c == 'd') {
if (updatePosition(x,y+1)) { if (updatePosition(x,y+1)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp); this.plateau.getCase(x, y).setType(temp2);
this.y+=1; this.y+=1;
updateDecouverte(this.plateau.getCase(x, y+1), this.vision); updateDecouverte(this.plateau.getCase(x, y+1), this.vision);
updateItem(); updateItem();
...@@ -162,7 +172,7 @@ public abstract class Unite { ...@@ -162,7 +172,7 @@ public abstract class Unite {
else if(c == 'q') { else if(c == 'q') {
if (updatePosition(x,y-1)) { if (updatePosition(x,y-1)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp); this.plateau.getCase(x, y).setType(temp2);
this.y-=1; this.y-=1;
updateDecouverte(this.plateau.getCase(x, y-1), this.vision); updateDecouverte(this.plateau.getCase(x, y-1), this.vision);
updateItem(); updateItem();
...@@ -172,7 +182,7 @@ public abstract class Unite { ...@@ -172,7 +182,7 @@ public abstract class Unite {
else if(c == 'z') { else if(c == 'z') {
if (updatePosition(x-1, y)) { if (updatePosition(x-1, y)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp); this.plateau.getCase(x, y).setType(temp2);
this.x-=1; this.x-=1;
updateDecouverte(this.plateau.getCase(x-1, y), this.vision); updateDecouverte(this.plateau.getCase(x-1, y), this.vision);
updateItem(); updateItem();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment