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

final

parent 3a742f8c
No related branches found
No related tags found
No related merge requests found
...@@ -15,9 +15,13 @@ public class Joueur { ...@@ -15,9 +15,13 @@ public class Joueur {
private static int cptJoueur = 1; private static int cptJoueur = 1;
private boolean win = false; private boolean win = false;
private List<Region> royaume; private List<Region> royaume;
public int xCamp;
public int yCamp;
public Joueur (String nom) { public Joueur (String nom, int xCamp, int yCamp) {
this.nomJoueur = nom; this.nomJoueur = nom;
this.xCamp = xCamp;
this.yCamp = yCamp;
this.numJoueur = cptJoueur; this.numJoueur = cptJoueur;
this.armee = new ArrayList<Unite>(); this.armee = new ArrayList<Unite>();
this.paJoueur = 5; this.paJoueur = 5;
......
...@@ -5,7 +5,9 @@ import java.util.Scanner; ...@@ -5,7 +5,9 @@ import java.util.Scanner;
import units.Paysant; import units.Paysant;
public class Main { public class Main {
private static Joueur winner = new Joueur("Winner"); private static Joueur joueur1 = new Joueur("Joueur 1", 5, 15);
private static Joueur joueur2 = new Joueur("Joueur 2", 25, 15);
private Joueur winner = null;
private int actionPoint; private int actionPoint;
public static void main(String[] args) { public static void main(String[] args) {
...@@ -17,23 +19,27 @@ public class Main { ...@@ -17,23 +19,27 @@ public class Main {
Plateau plateau = new Plateau(); Plateau plateau = new Plateau();
int x = 11; plateau.getCase(joueur1.xCamp, joueur1.yCamp).setUnite(new Paysant(joueur1.xCamp, joueur1.yCamp, plateau, joueur1));
int y = 10; plateau.getCase(joueur2.xCamp, joueur2.yCamp).setUnite(new Paysant(joueur2.xCamp, joueur2.yCamp, plateau, joueur2));
joueur1.getArmee().get(0).getPlateau().getRegion(joueur1.xCamp-1,joueur1.yCamp-1).changeToCamp();
joueur2.getArmee().get(0).getPlateau().getRegion(joueur2.xCamp,joueur2.yCamp).changeToCamp();
plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner));
winner.getArmee().get(0).getPlateau().getRegion(0,0).changeToCamp();
Affichage.affichage(plateau); Affichage.affichage(plateau);
while(y<30) { while(true!=false) {
winner.getArmee().get(0).move(deplacement()); joueur1.getArmee().get(0).move(deplacement());
//System.out.println(winner.getArmee().get(0).getPlateau().getRegion(0, 0).);
System.out.println('\n'); System.out.println('\n');
System.out.println(joueur1.getArmee().get(0).getX());
//winner.getArmee().get(0).teleporte(); //winner.getArmee().get(0).teleporte();
Affichage.affichage(plateau); Affichage.affichage(plateau);
//joueur2.getArmee().get(0).move(deplacement());
//Affichage.affichage(plateau);
} }
Menu(); //Menu();
plateau.getCase(12, 0); //plateau.getCase(12, 0);
Affichage.affichage(plateau); //Affichage.affichage(plateau);
//Menu(); //Menu();
} }
......
...@@ -9,7 +9,7 @@ public class Plateau { ...@@ -9,7 +9,7 @@ public class Plateau {
public Plateau() { public Plateau() {
Random random = new Random(); Random random = new Random();
this.plateau = new Region[6][6]; this.plateau = new Region[7][7];
for (int i = 0; i < plateau.length; i++) { for (int i = 0; i < plateau.length; i++) {
for (int j = 0; j < plateau[0].length; j++) { for (int j = 0; j < plateau[0].length; j++) {
plateau[i][j] = new Region(); plateau[i][j] = new Region();
...@@ -23,9 +23,15 @@ public class Plateau { ...@@ -23,9 +23,15 @@ public class Plateau {
this.getCase(rd1, rd2).setItem(new Crown(this.getCase(0, 0))); this.getCase(rd1, rd2).setItem(new Crown(this.getCase(0, 0)));
} }
public Case getCase(int x, int y) { public Case getCase(int x, int y) {
return plateau[x/5][y/5].region[x%5][y%5]; return getRegion(x,y).region[x%5][y%5];
} }
public Region getRegion(int x, int y ) { public Region getRegion(int x, int y ) {
/*if(x/5!=(x-1)/5) {
return plateau[x/5-1][y/5];
}
else if(y/5!=(y-1)/5) {
return plateau[x/5][y/5-1];
}*/
return plateau[x/5][y/5]; return plateau[x/5][y/5];
} }
public Region[][] getPlateau() { public Region[][] getPlateau() {
......
...@@ -117,7 +117,10 @@ public abstract class Unite { ...@@ -117,7 +117,10 @@ 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==33 || x==1 || y==29 || y==33 || y==0) {
return false;
}
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(this.plateau.getCase(x, y).getType() != Type.MOUNTAIN ) { if(this.plateau.getCase(x, y).getType() != Type.MOUNTAIN ) {
temp2 = temp; temp2 = temp;
temp = this.plateau.getCase(x, y).getType(); temp = this.plateau.getCase(x, y).getType();
...@@ -147,9 +150,9 @@ public abstract class Unite { ...@@ -147,9 +150,9 @@ public abstract class Unite {
public boolean move(char c) { public boolean move(char c) {
if(c == 's') { 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(); return false;
}*/ }
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(temp2); this.plateau.getCase(x, y).setType(temp2);
...@@ -160,6 +163,9 @@ public abstract class Unite { ...@@ -160,6 +163,9 @@ public abstract class Unite {
} }
} }
else if(c == 'd') { else if(c == 'd') {
if (plateau.getCase(x+1,y).getUnite() != null && plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) {
return false;
}
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(temp2); this.plateau.getCase(x, y).setType(temp2);
...@@ -170,6 +176,9 @@ public abstract class Unite { ...@@ -170,6 +176,9 @@ public abstract class Unite {
} }
} }
else if(c == 'q') { else if(c == 'q') {
if (plateau.getCase(x+1,y).getUnite() != null && plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) {
return false;
}
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(temp2); this.plateau.getCase(x, y).setType(temp2);
...@@ -180,6 +189,9 @@ public abstract class Unite { ...@@ -180,6 +189,9 @@ public abstract class Unite {
} }
} }
else if(c == 'z') { else if(c == 'z') {
if (plateau.getCase(x+1,y).getUnite() != null && plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) {
return false;
}
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(temp2); this.plateau.getCase(x, y).setType(temp2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment