diff --git a/src/main/Affichage.java b/src/main/Affichage.java index 2419afa8c96b0f63547e052b61046b2a3fe29850..dcdcc1cee10c028de8c2c6ce60bf69d5e93cf3c6 100644 --- a/src/main/Affichage.java +++ b/src/main/Affichage.java @@ -1,7 +1,7 @@ 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++) { diff --git a/src/main/Joueur.java b/src/main/Joueur.java index 1c72c1e908ea2dfb156638cfe8de921f36c5121d..c71a531badd242e0d0b899f286e3f487e5b81e59 100644 --- a/src/main/Joueur.java +++ b/src/main/Joueur.java @@ -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; diff --git a/src/main/Main.java b/src/main/Main.java index c2df656c214c140f284caacaaa5e2326856539cf..c38a0df24c79d777db6207c6eb06c2ab255848ce 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -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); } diff --git a/src/main/Plateau.java b/src/main/Plateau.java index c9c05b50141f66cd6cd62de56b766dd55ae5f99d..53cfef0ceeee1ff3bc7b25cc22eaff31bc913fbe 100644 --- a/src/main/Plateau.java +++ b/src/main/Plateau.java @@ -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); - this.getCase(rd1, rd2).setItem(new Crown(this.getCase(0, 0))); + 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() { diff --git a/src/units/Archer.java b/src/units/Archer.java index 83586c1e38f552b1c144fdeb7b23de971db999ef..be192c95ce4b2aba157679f6c6e6faa1e4389b3e 100644 --- a/src/units/Archer.java +++ b/src/units/Archer.java @@ -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) { diff --git a/src/units/Chevalier.java b/src/units/Chevalier.java index f5d1676bdf79ef62f6cd615a9472aa3e3692d67c..55d1b19c1752af8c1b2ca3736f16d1a46c589482 100644 --- a/src/units/Chevalier.java +++ b/src/units/Chevalier.java @@ -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; diff --git a/src/units/Combattre.java b/src/units/Combattre.java index 5fcf9f75895b0a0b0721bc3ab78fd6c7a21b424f..3778dab0f9d17368a96616b7f95d512afd6684a7 100644 --- a/src/units/Combattre.java +++ b/src/units/Combattre.java @@ -9,9 +9,7 @@ public class Combattre { uniteDef.setArmor(uniteDef.getArmor()-uniteAttq.getDamage()); if (isAlive(uniteDef)) { - //TODO: peut �tre mettre moins de d�gat pour l'unit� qui d�fend uniteAttq.setArmor(uniteAttq.getArmor()-uniteDef.getDamage()); - //TODO: attention au archer ! isAlive(uniteAttq); } } diff --git a/src/units/Eclaireur.java b/src/units/Eclaireur.java index 62aaeb6e6db81bec5623ebcfdaab96da03986d49..451122afcc6a67108952b379cc40cd6f9ec33bf0 100644 --- a/src/units/Eclaireur.java +++ b/src/units/Eclaireur.java @@ -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) { diff --git a/src/units/Paysant.java b/src/units/Paysant.java index 82b305201a6e0099c31baa193785d15fe2b6dff3..613cb2dc9dc3c0b4e6496076f65865cdec64048b 100644 --- a/src/units/Paysant.java +++ b/src/units/Paysant.java @@ -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; diff --git a/src/units/Unite.java b/src/units/Unite.java index bbc3ffa0ca331740df28851a88ce916958d74f77..35b2860cfb9b60d848bb63752a2d681fb32a885b 100644 --- a/src/units/Unite.java +++ b/src/units/Unite.java @@ -117,8 +117,11 @@ 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(this.plateau.getCase(x, y).getType() != Type.MOUNTAIN) { + 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(); this.plateau.getCase(x, y).setUnite(this); @@ -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);