From d14b25f71f87583bdf3640d73cc4b89a748544ff Mon Sep 17 00:00:00 2001
From: Maxime WALLART <maxime.wallart.etu@univ-lille.fr>
Date: Wed, 2 Sep 2020 09:11:37 +0200
Subject: [PATCH] merge master

---
 src/main/Case.java   |  3 ++
 src/main/Main.java   | 65 +++++++++++++++++++++++---------------------
 src/main/Region.java |  9 ++++++
 src/main/Type.java   |  2 +-
 src/units/Unite.java | 20 ++++++++------
 5 files changed, 59 insertions(+), 40 deletions(-)

diff --git a/src/main/Case.java b/src/main/Case.java
index a47af92..40864f4 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 8c43cd4..15bcded 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 4b9c87b..b08ee12 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 59fb262..bdfacc4 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 6892bb4..a87edd0 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;
-- 
GitLab