diff --git a/src/main/Case.java b/src/main/Case.java index a47af92925524e6e3d8e5dc8a33a2cb2ca0cc3bb..40864f49a9b22eb2fe2d0244e0dcfc9d3084a159 100644 --- a/src/main/Case.java +++ b/src/main/Case.java @@ -74,6 +74,9 @@ public class Case { else if (this.type == Type.FORT) { return "♜ "; } + else if (this.type == Type.CAMP) { + return "O "; + } else { return "? ";} } } diff --git a/src/main/Main.java b/src/main/Main.java index 8c43cd4b81b8f77432322b50d24bf95c989a9a06..15bcdedda6a883419cd7e1668f002ab1dc8a0b03 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -7,44 +7,47 @@ import units.Paysant; public class Main { private static Joueur winner = new Joueur("Winner"); private int actionPoint; - + public static void main(String[] args) { - /*Region[][] regions = new Region[6][6]; - for(int i = 0; i<regions.length; i++) { - for(int j = 0; j<regions[i].length; j++) { - regions[i][j] = new Region(); - } - }*/ - + /* + * Region[][] regions = new Region[6][6]; for(int i = 0; i<regions.length; i++) + * { for(int j = 0; j<regions[i].length; j++) { regions[i][j] = new Region(); } + * } + */ + Plateau plateau = new Plateau(); int x = 11; int y = 10; plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner)); + winner.getArmee().get(0).getPlateau().getRegion(0,0).changeToCamp(); Affichage.affichage(plateau); - winner.getArmee().get(0).move(deplacement()); - System.out.println('\n'); - Affichage.affichage(plateau); + while (y != 30) { + winner.getArmee().get(0).move(deplacement()); + System.out.println('\n'); + Affichage.affichage(plateau); + } Menu(); plateau.getCase(12, 0); Affichage.affichage(plateau); } - - public static void Menu () { + + public static void Menu() { System.out.print("Bienvenue dans Game of Crown, vous êtes actuellement sur le Menu !"); } + public static char deplacement() { Scanner sc = new Scanner(System.in); System.out.println("Veuillez choisir une direction"); while (!sc.hasNext("[zqsd]")) { - System.out.println("Cette touche n'est pas acceptés, veuillez réessayer"); - sc.next(); + System.out.println("Cette touche n'est pas acceptés, veuillez réessayer"); + sc.next(); } return sc.next().charAt(0); } - - private Joueur Game (Joueur[] joueurs) { + + private Joueur Game(Joueur[] joueurs) { boolean gameEnd = false; - while(gameEnd){ + while (gameEnd) { for (Joueur currentPlayer : joueurs) { setActionPoint(currentPlayer); Tour(currentPlayer, actionPoint); @@ -52,28 +55,28 @@ public class Main { } return getWinner(); } - - public void Tour (Joueur currentPlayer, int actionPoint) { - + + public void Tour(Joueur currentPlayer, int actionPoint) { + } - - public void setActionPoint (int actionPoint) { + + public void setActionPoint(int actionPoint) { this.actionPoint = actionPoint; } - - public void setActionPoint (Joueur currentPlayer) { + + public void setActionPoint(Joueur currentPlayer) { this.actionPoint = currentPlayer.getArmee().size() + (currentPlayer.getRoyaume().size() * 3); } - - public int getActionPoint () { + + public int getActionPoint() { return this.actionPoint; } - - public void setWinner (Joueur winner) { + + public void setWinner(Joueur winner) { this.winner = winner; } - - public Joueur getWinner () { + + public Joueur getWinner() { return this.winner; } } diff --git a/src/main/Region.java b/src/main/Region.java index 4b9c87b60a9a005b45127bce1da81ddd540dc8ca..b08ee1270a95f3c7aafd5266d5b79efb6a88e84b 100644 --- a/src/main/Region.java +++ b/src/main/Region.java @@ -30,6 +30,15 @@ public class Region { region[rd1][rd2].setEvent(Event.FORT); region[rd1][rd2].setType(Type.FORT); } + public void changeToCamp() { + for (int i = 0; i < region.length; i++) { + for (int j = 0; j < region[0].length; j++) { + if (region[i][j].getType()==Type.FORT) { + region[i][j].setType(Type.CAMP); + } + } + } + } public void setX(int x) { this.x = x; } diff --git a/src/main/Type.java b/src/main/Type.java index 59fb26206d3636820dea9b4c1ef28b8e03aac2b6..bdfacc4ab2b794f54a2785d7d71be011f0b47d1e 100644 --- a/src/main/Type.java +++ b/src/main/Type.java @@ -1,5 +1,5 @@ package main; public enum Type { - UNITE,GRASS, MOUNTAIN, VILLAGE, FORT; + UNITE,GRASS, MOUNTAIN, CAMP, FORT; } diff --git a/src/units/Unite.java b/src/units/Unite.java index 6892bb48ad8093010dfee65b929bbfeeed84eca1..a87edd006391df136772e18392e5eb0b994d60d8 100644 --- a/src/units/Unite.java +++ b/src/units/Unite.java @@ -22,6 +22,7 @@ public abstract class Unite { public static int generalId = 1; private Joueur joueur; private Items item; + private Type temp = Type.GRASS; public Unite(int x, int y, Plateau plateau, char symbol, int armor, int damage, Joueur joueur, int vision) { this.id = generalId; @@ -115,28 +116,31 @@ public abstract class Unite { } public boolean updatePosition(int x,int y) { - 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 ) { + 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).getEvent() == Event.FORT) { this.plateau.getRegion(x, y).setProprietaire(joueur); this.joueur.getRoyaume().add(this.plateau.getRegion(x, y)); } + /*if(this.plateau.getCase(x, y).getEvents().length > 0){ + System.out.println("oui"); + }*/ return true; } return false; } //à voir le type public boolean move(char c) { - /*if(c=='s' && updatePosition(x+1,y))*/ if(c == 's') { - if (plateau.getCase(x+1,y).getUnite() != null || plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) { + /*if (plateau.getCase(x+1,y).getUnite() != null || plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) { //combat(); - } + }*/ if (updatePosition(x+1,y)) { this.plateau.getCase(x, y).setUnite(null); - this.plateau.getCase(x, y).setType(Type.GRASS); + this.plateau.getCase(x, y).setType(temp); this.x+=1; updateDecouverte(this.plateau.getCase(x+1, y), this.vision); return true; @@ -145,7 +149,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(Type.GRASS); + this.plateau.getCase(x, y).setType(temp); this.y+=1; updateDecouverte(this.plateau.getCase(x, y+1), this.vision); return true; @@ -154,7 +158,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(Type.GRASS); + this.plateau.getCase(x, y).setType(temp); this.y-=1; updateDecouverte(this.plateau.getCase(x, y-1), this.vision); return true; @@ -163,7 +167,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(Type.GRASS); + this.plateau.getCase(x, y).setType(temp); this.x-=1; updateDecouverte(this.plateau.getCase(x-1, y), this.vision); return true;