diff --git a/src/main/Main.java b/src/main/Main.java index cdc75ac29f8eba4f9c97542bfe5ef4a46328f095..c2df656c214c140f284caacaaa5e2326856539cf 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -2,10 +2,12 @@ package main; import java.util.Scanner; +import units.Chevalier; import units.Paysant; public class Main { - private static Joueur winner = new Joueur("Winner"); + private static Joueur joueur1 = new Joueur("joueur1"); + private static Joueur joueur2 = new Joueur("joueur2"); private int actionPoint; static Main m = new Main(); @@ -20,12 +22,15 @@ public class Main { Plateau plateau = new Plateau(); - int x = 11; - int y = 10; + int x = 5; + int y = 5; - plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner)); - winner.getArmee().get(0).getPlateau().getRegion(0,0).changeToCamp(); + plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, joueur1)); + plateau.getCase(x+2, y+2).setUnite(new Paysant(x+2, y+2, plateau, joueur1)); + 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());*/ @@ -47,7 +52,7 @@ public class Main { } if(continuer !=3) { continuer =2; - m.game(new Joueur[]{winner,null}, plateau); + m.game(new Joueur[]{joueur1,joueur2}, plateau); } } } @@ -74,6 +79,7 @@ public class Main { } public void Tour(Joueur currentPlayer, int actionPoint, Plateau plateau) { + System.out.println("Debut du tour de : " + currentPlayer.getNomJoueur()); for(int i =0; i<actionPoint; i++) { Interface.tourDeJeu(plateau, currentPlayer); } @@ -84,6 +90,7 @@ public class Main { } public void setActionPoint(Joueur currentPlayer) { + System.out.println("" + currentPlayer.getArmee().size() + (currentPlayer.getRoyaume().size() * 3)); this.actionPoint = currentPlayer.getArmee().size() + (currentPlayer.getRoyaume().size() * 3); } @@ -93,10 +100,10 @@ public class Main { public void setWinner(Joueur winner) { - this.winner = winner; + this.joueur1 = winner; } public Joueur getWinner() { - return this.winner; + return this.joueur1; } } diff --git a/src/units/Chevalier.java b/src/units/Chevalier.java index 583bfb0bc41f78e31b160f62530e0521a9d7b8dd..f5d1676bdf79ef62f6cd615a9472aa3e3692d67c 100644 --- a/src/units/Chevalier.java +++ b/src/units/Chevalier.java @@ -1,5 +1,7 @@ package units; +import java.util.Scanner; + import main.Joueur; import main.Plateau; @@ -9,6 +11,7 @@ public class Chevalier extends Unite { public static final int DAMAGE = 5; public static final char SYMBOL = 'C'; public static final int VISION = 2; + public static final int PATOGIVE = 2; public Chevalier(int x, int y, Plateau plateau, Joueur joueur) { super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur, VISION); @@ -22,9 +25,46 @@ public class Chevalier extends Unite { @Override public boolean action() { - // TODO Auto-generated method stub + //TODO: le paysant doit regarder si il peut attaquer ou donne un PA pour le prochain tour + Scanner sc = new Scanner(System.in); + StringBuilder builder = new StringBuilder(); + builder.append("Voici les action disponnible pour le Paysant ") + .append(this.getId()).append(":\n"); + /* + if (this.getUnitCase().haveUnitNear) { + builder.append("1. Combattre\n") + .append("2. Donner un Point d'Action\n"); + }else{ + builder.append("2. Donner un Point d'Action\n") + } + */ + System.out.println(builder.toString()); + + int res = sc.nextInt(); + + if (res == 1) { + combattre(); + }else if(res == 2){ + actionGivePA(); + sc.close(); + return true; + }else { + //TODO:utiliser un système de vérification d'entrée globale + System.out.println("ERROR"); + } + + sc.close(); + return false; } + + public void combattre() { + //TODO: il faut d'abord regarder si une unité est présente autour + } + + public void actionGivePA() { + this.getJoueur().addPa(PATOGIVE); + } }