Skip to content
Snippets Groups Projects
Commit f1074993 authored by CARION Baptiste's avatar CARION Baptiste
Browse files

Reparation menu et levee initiale du brouillard de guerre

parents 2278fd89 4f2a021d
No related branches found
No related tags found
No related merge requests found
package main;
public class Affichage {
public void affichage(Plateau plateau){
public static void affichage(Plateau plateau){
for(int i=0; i< plateau.getPlateau().length*5; i++) {
......
......@@ -15,9 +15,13 @@ public class Joueur {
private static int cptJoueur = 1;
private boolean win = false;
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.xCamp = xCamp;
this.yCamp = yCamp;
this.numJoueur = cptJoueur;
this.armee = new ArrayList<Unite>();
this.paJoueur = 5;
......
......@@ -6,8 +6,12 @@ import units.Chevalier;
import units.Paysant;
public class Main {
private static Joueur joueur1 = new Joueur("joueur1");
private static Joueur joueur2 = new Joueur("joueur2");
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;
static Main m = new Main();
......@@ -22,6 +26,7 @@ public class Main {
Plateau plateau = new Plateau();
int x = 5;
int y = 5;
......@@ -31,16 +36,28 @@ public class Main {
plateau.getCase(x+20, y+20).setUnite(new Chevalier(x+20, y+20, plateau, joueur2));
joueur1.getArmee().get(0).getPlateau().getRegion(0,0).changeToCamp();
joueur2.getArmee().get(0).getPlateau().getRegion(0,0).changeToCamp();
a.affichage(plateau);
/*while(y<30) {
winner.getArmee().get(0).move(deplacement());*/
joueur1.getArmee().get(0).updateDecouverte(plateau.getCase(x, y), 1);
joueur1.getArmee().get(1).updateDecouverte(plateau.getCase(x+2, y+2), 1);
joueur2.getArmee().get(0).updateDecouverte(plateau.getCase(x+20, y+20), 2);
//Affichage.affichage(plateau);
/*while(true!=false) {
joueur1.getArmee().get(0).move(deplacement());
//System.out.println(winner.getArmee().get(0).getPlateau().getRegion(0, 0).);
System.out.println('\n');
System.out.println(joueur1.getArmee().get(0).getX());
//winner.getArmee().get(0).teleporte();
a.affichage(plateau);
Affichage.affichage(plateau);
//joueur2.getArmee().get(0).move(deplacement());
//Affichage.affichage(plateau);
}*/
//Menu();
plateau.getCase(12, 0);
a.affichage(plateau);
//plateau.getCase(12, 0);
//Affichage.affichage(plateau);
m.menu(plateau);
}
......
......@@ -9,7 +9,7 @@ public class Plateau {
public Plateau() {
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 j = 0; j < plateau[0].length; j++) {
plateau[i][j] = new Region();
......@@ -18,14 +18,24 @@ public class Plateau {
plateau[i][j].fillRegion();
}
}
int rd1 = (int)random.nextInt(10)+10;
int rd2 = (int)random.nextInt(30);
int rd1;
int rd2;
do {
rd1 = (int)random.nextInt(10)+10;
rd2 = (int)random.nextInt(30);
this.getCase(rd1, rd2).setItem(new Crown(this.getCase(0, 0)));
} while (this.getCase(rd1, rd2).getType() != Type.GRASS);
}
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 ) {
/*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];
}
public Region[][] getPlateau() {
......
......@@ -7,7 +7,7 @@ public class Archer extends Unite{
public static final int ARMOR = 5;
public static final int DAMAGE = 5;
public static final char SYMBOL = 'A';
public static final char SYMBOL = 'Ð';
public static final int VISION = 2;
public Archer(int x, int y, Plateau plateau, Joueur joueur) {
......
......@@ -9,7 +9,7 @@ public class Chevalier extends Unite {
public static final int ARMOR = 10;
public static final int DAMAGE = 5;
public static final char SYMBOL = 'C';
public static final char SYMBOL = '';
public static final int VISION = 2;
public static final int PATOGIVE = 2;
......
......@@ -9,9 +9,7 @@ public class Combattre {
uniteDef.setArmor(uniteDef.getArmor()-uniteAttq.getDamage());
if (isAlive(uniteDef)) {
//TODO: peut tre mettre moins de dgat pour l'unit qui dfend
uniteAttq.setArmor(uniteAttq.getArmor()-uniteDef.getDamage());
//TODO: attention au archer !
isAlive(uniteAttq);
}
}
......
......@@ -7,7 +7,7 @@ public class Eclaireur extends Unite {
public static final int ARMOR = 1;
public static final int DAMAGE = 0;
public static final char SYMBOL = 'E';
public static final char SYMBOL = '';
public static final int VISION = 2;
public Eclaireur(int x, int y, Plateau plateau, Joueur joueur) {
......
......@@ -9,7 +9,7 @@ public class Paysant extends Unite{
public static final int ARMOR = 2;
public static final int DAMAGE = 1;
public static final char SYMBOL = 'p';
public static final char SYMBOL = '';
public static final int PATOGIVE = 1;
public static final int VISION = 1;
......
......@@ -117,7 +117,10 @@ 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) ) {
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 ) {
temp2 = temp;
temp = this.plateau.getCase(x, y).getType();
......@@ -147,9 +150,9 @@ public abstract class Unite {
public boolean move(char c) {
if(c == 's') {
/*if (plateau.getCase(x+1,y).getUnite() != null || plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) {
//combat();
}*/
if (plateau.getCase(x+1,y).getUnite() != null && plateau.getCase(x+1, y).getUnite().getJoueur() != this.joueur) {
return false;
}
if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp2);
......@@ -160,6 +163,9 @@ public abstract class Unite {
}
}
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)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp2);
......@@ -170,6 +176,9 @@ public abstract class Unite {
}
}
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)) {
this.plateau.getCase(x, y).setUnite(null);
this.plateau.getCase(x, y).setType(temp2);
......@@ -180,6 +189,9 @@ public abstract class Unite {
}
}
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)) {
this.plateau.getCase(x, y).setUnite(null);
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