diff --git a/src/items/Crown.java b/src/items/Crown.java index 939fffd9cef45fe8551d9c5e4e8ab28b41906be7..1c138dba9d3fdeb78a29c1896b6be881fac1d4a1 100644 --- a/src/items/Crown.java +++ b/src/items/Crown.java @@ -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); } diff --git a/src/main/Case.java b/src/main/Case.java index f2f38196cae14f311b86cf6dc853cf26d92d6551..b2c7ca80c9142f44dbc2e81641c43dca45ca1653 100644 --- a/src/main/Case.java +++ b/src/main/Case.java @@ -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 "; diff --git a/src/units/Unite.java b/src/units/Unite.java index 25eac3c1654a3da92f9a6abacf08a831338f6094..5303c5c3fb742feb344015febed73c75c352f2de 100644 --- a/src/units/Unite.java +++ b/src/units/Unite.java @@ -1,7 +1,9 @@ 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();