diff --git a/doc/sprint-3/README.md b/doc/sprint-3/README.md index 704d0a15594abc2eb39c7394b26af5e7ec37b27e..3e1662b3ebaae0f473f11a981d7a53903091c033 100644 --- a/doc/sprint-3/README.md +++ b/doc/sprint-3/README.md @@ -1,12 +1,12 @@ # Sprint 3 -## D�mo + Planification du sprint suivant +## Démo + Planification du sprint suivant ### Ce que nous avons fait durant ce sprint -Cr�ation des evenements et des d�placement +Création des evenements et des déplacement mise en place de l'affichage ### Ce que nous allons faire durant le prochain sprint -ajout� les unit�s et r�alis� le syst�me d'action +ajouté les unités et réalisé le système d'action -## R�tro +## Rétro diff --git a/doc/sprint-4/README.md b/doc/sprint-4/README.md new file mode 100644 index 0000000000000000000000000000000000000000..43ba1514b6f3061193fa707b5c5341d05b05505a --- /dev/null +++ b/doc/sprint-4/README.md @@ -0,0 +1,13 @@ +# Sprint 4 + +## Démo + Planification du sprint suivant + +### Ce que nous avons fait durant ce sprint +Toutes les unités ont été ajouté +Les actions sont misent en places via l'interface + +### Ce que nous allons faire durant le prochain sprint +réalisation partiel de l'interface +réalisation des événements + +## Rétro \ No newline at end of file diff --git a/doc/sprint-4/radiateur.jpg b/doc/sprint-4/radiateur.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e2e2292acd77105993eea3cf70fd5774e3711188 Binary files /dev/null and b/doc/sprint-4/radiateur.jpg differ diff --git a/doc/sprint-5/README.md b/doc/sprint-5/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7abc22ad717c5159f473374c323fcf306e85547c --- /dev/null +++ b/doc/sprint-5/README.md @@ -0,0 +1,13 @@ +# Sprint 5 + +## Démo + Planification du sprint suivant + +### Ce que nous avons fait durant ce sprint +réalisation partiel de l'interface +réalisation des événements +réalisateur des cases procédurale + +### Ce que nous allons faire durant le prochain sprint + + +## Rétro \ No newline at end of file diff --git a/doc/sprint-5/radiateur.jpg b/doc/sprint-5/radiateur.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bd5524346e2a9318db3455b2c2b368de4df61587 Binary files /dev/null and b/doc/sprint-5/radiateur.jpg differ diff --git a/src/events/FortEvent.java b/src/events/FortEvent.java index 604f4107b1e7051ddeb9e47f2e59ca543cd27296..6d589be5fd006012f7d8a1fd65f68dcebf845355 100644 --- a/src/events/FortEvent.java +++ b/src/events/FortEvent.java @@ -19,11 +19,13 @@ public class FortEvent implements Evenements{ uniteVisiteur.setArmor(uniteVisiteur.getArmor()-fortDamage); if (Combattre.isAlive(uniteVisiteur)) { owner = visiteur; + uniteVisiteur.getPlateau().getRegion(uniteVisiteur.getX(), uniteVisiteur.getY()).setProprietaire(visiteur); } }else if(owner.getNomJoueur().equals(visiteur.getNomJoueur())) { System.out.println("Vous accupez maintenant votre fort !"); }else{ owner = visiteur; + uniteVisiteur.getPlateau().getRegion(uniteVisiteur.getX(), uniteVisiteur.getY()).setProprietaire(visiteur); } } diff --git a/src/events/TeleportationEvent.java b/src/events/TeleportationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..ac6adb9d0372b389f69afbe2ac96dc318c276cd8 --- /dev/null +++ b/src/events/TeleportationEvent.java @@ -0,0 +1,15 @@ +package events; + +import main.Case; + +public class TeleportationEvent implements Evenements{ + + public void action(Case eventCase) { + //TODO:téléporter l'unité sur une case random qui n'est ni un + } + + public String getName() { + return "Teleportation Event"; + } + +} diff --git a/src/items/Crown.java b/src/items/Crown.java index 97da0c6ee93d6d1933b383591a117f2996e6a85a..33e2c3675db6bfc44c31f1daf51c5cc818126143 100644 --- a/src/items/Crown.java +++ b/src/items/Crown.java @@ -15,7 +15,10 @@ public class Crown extends Items{ @Override public void usage(Joueur joueur) { //TODO: premi�re version, tu prend la couronne tu gagne, ensuite faire de syst�me de r�cup et d'arriver au camp - joueur.setWin(true); + if (this.getPower() != 0) { + joueur.setWin(true); + this.setPower(0); + } } @Override diff --git a/src/items/Items.java b/src/items/Items.java index fcf570e9e7eb5063b1da5ff55a4ebc05fc60b5cc..eddd6d333650645395c819961cc177629d055bb7 100644 --- a/src/items/Items.java +++ b/src/items/Items.java @@ -6,6 +6,7 @@ import main.Joueur; public abstract class Items { private String name; private Case itemCase; + private int power = 1; public Items(String name, Case itemCase) { super(); @@ -17,6 +18,15 @@ public abstract class Items { return name; } + public int getPower() { + return power; + } + + + public void setPower(int power) { + this.power = power; + } + public Case getItemCase() { return itemCase; } diff --git a/src/main/Case.java b/src/main/Case.java index ff8c99e9e7d08bf969ffd41e5cdf7e095ade5d3b..8e206ff03f6034051ec185e6ac2f4a72440a13f2 100644 --- a/src/main/Case.java +++ b/src/main/Case.java @@ -1,11 +1,17 @@ package main; +import java.util.ArrayList; +import java.util.List; + +import events.Evenements; +import items.Items; import units.Unite; public class Case { private Type type; private boolean decouverte; - private Event event; + private List<Evenements> events; + private Items item; private Unite unite; private int x; private int y; @@ -14,8 +20,8 @@ public class Case { public Case(Type type) { this.type = type; this.decouverte = false; - this.event = null; this.unite = null; + this.events = new ArrayList<Evenements>(); this.x = 0; this.y = 0; } @@ -37,12 +43,16 @@ public class Case { public boolean isDecouverte() { return decouverte; - } + } - public Event getEvent() { - return event; + public List<Evenements> getEvents() { + return events; } - + + public boolean addEvents(Evenements event) { + return events.add(event); + } + public Unite getUnite() { return unite; } @@ -51,10 +61,6 @@ public class Case { this.decouverte = decouverte; } - public void setEvent(Event event) { - this.event = event; - } - public void setUnite(Unite unite) { this.unite = unite; this.type = Type.UNITE; @@ -62,6 +68,15 @@ public class Case { public void setType(Type type) { this.type = type; } + + public Items getItem() { + return item; + } + + public void setItem(Items item) { + this.item = item; + } + public String toString() { if (!this.isDecouverte()) { return "~ "; diff --git a/src/main/Direction.java b/src/main/Direction.java deleted file mode 100644 index 2ac77660afd332a7dcf93c7aca97bd07b57c7348..0000000000000000000000000000000000000000 --- a/src/main/Direction.java +++ /dev/null @@ -1,7 +0,0 @@ -package main; - -public enum Direction { -HAUT, GAUCHE, BAS, DROITE; -} - - diff --git a/src/main/Event.java b/src/main/Event.java deleted file mode 100644 index d661d23d8c20f193c5083b41967c68adf65d7c03..0000000000000000000000000000000000000000 --- a/src/main/Event.java +++ /dev/null @@ -1,5 +0,0 @@ -package main; - -public enum Event { - FORT; -} diff --git a/src/main/Interface.java b/src/main/Interface.java index aa7ba6f86ad063c2a704591130e526b09f6380cc..e4ac55e248668c50a79a15a61b5f092552af9eb8 100644 --- a/src/main/Interface.java +++ b/src/main/Interface.java @@ -1,5 +1,7 @@ package main; +import units.Unite; + public class Interface { private static int rep = 0; public static void start() { @@ -24,11 +26,36 @@ public class Interface { for(int i = 0; i< j1.getArmee().size(); i++) { System.out.println(i+": "+ j1.getArmee().get(1).toString()); } - Scan.scan(j1.getArmee().size()); - System.out.println("vous pouvez déplacer une unité..."); - System.out.println("1: Vers le haut"); - System.out.println("2: Vers le bas"); - System.out.println("3: Vers la droite"); - System.out.println("4: Vers la gauche"); + Unite u =j1.getArmee().get((Scan.scan(j1.getArmee().size()))); + System.out.println("vous pouvez..."); + if(u.getX()>0) { + if(plateau.getCase(u.getX()-1, u.getY()).getUnite()!=null){ + System.out.println("1: Combattre l'unité au-dessus"); + }else { + System.out.println("1: Se déplacer vers le haut"); + } + } + if(u.getX()<plateau.getPlateau().length*5) { + if(plateau.getCase(u.getX()+1, u.getY()).getUnite()!=null){ + System.out.println("2: Combattre l'unité en bas"); + }else { + System.out.println("2: Se déplacer vers le bas"); + } + } + if(u.getY()<plateau.getPlateau().length*5) { + if(plateau.getCase(u.getX(), u.getY()+1).getUnite()!=null){ + System.out.println("3: Combattre l'unité à droite"); + }else { + System.out.println("3: Se déplacer vers la droite"); + } + } + if(u.getY()>0) { + if(plateau.getCase(u.getX(), u.getY()-1).getUnite()!=null){ + System.out.println("4: Combattre l'unité à gauche"); + }else { + System.out.println("4: Se déplacer vers la gauche"); + } + } + rep = Scan.scan(4); } } diff --git a/src/main/Main.java b/src/main/Main.java index fe5f475bbe6fea1e47ba4a4165a93b371dafd9ca..94ca0e44de8c48b8cb827533bc518d607d2953fb 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -1,9 +1,11 @@ package main; +import java.util.Scanner; + import units.Paysant; public class Main { - private static Joueur winner; + private static Joueur winner = new Joueur("Winner"); private int actionPoint; public static void main(String[] args) { @@ -15,23 +17,40 @@ public class Main { }*/ Plateau plateau = new Plateau(); - int x = 13; - int y = 23; + + int x = 11; + int y = 10; + + plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner)); Affichage.affichage(plateau); - plateau.getCase(x, y).getUnite().move(Direction.HAUT); + while(y<30) { + winner.getArmee().get(0).move(deplacement()); System.out.println('\n'); + winner.getArmee().get(0).teleporte(); + Affichage.affichage(plateau); + } + Menu(); + plateau.getCase(12, 0); Affichage.affichage(plateau); //Menu(); } public static void Menu () { - System.out.print("Bienvenu dans Game of Crown, vous êtes actuellement sur le Menu !"); - Interface.start(); + 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(); + } + return sc.next().charAt(0); } - public Joueur Game (Joueur[] joueurs) { + private Joueur Game (Joueur[] joueurs) { boolean gameEnd = false; while(gameEnd){ for (Joueur currentPlayer : joueurs) { diff --git a/src/main/Region.java b/src/main/Region.java index ea1a573be58c922a43f0cdda6f4a77e22ab2b800..6eb76d39e4b0f656df2d9df2bcb69e55af9dba58 100644 --- a/src/main/Region.java +++ b/src/main/Region.java @@ -2,6 +2,8 @@ package main; import java.util.Random; +import events.FortEvent; + public class Region { public Case[][] region = new Case[5][5]; private Joueur proprietaire = null; @@ -27,7 +29,7 @@ public class Region { } int rd1 = (int)random.nextInt(5); int rd2 = (int)random.nextInt(5); - region[rd1][rd2].setEvent(Event.FORT); + region[rd1][rd2].addEvents(new FortEvent()); region[rd1][rd2].setType(Type.FORT); } public void setX(int x) { diff --git a/src/units/Archer.java b/src/units/Archer.java index 958234d87022d8df7b73a7ca1ee25cd5ebb2e0bd..83586c1e38f552b1c144fdeb7b23de971db999ef 100644 --- a/src/units/Archer.java +++ b/src/units/Archer.java @@ -1,6 +1,5 @@ package units; -import main.Case; import main.Joueur; import main.Plateau; @@ -9,10 +8,10 @@ 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 int VISION = 2; public Archer(int x, int y, Plateau plateau, Joueur joueur) { - super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur); - + super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur, VISION); } @Override diff --git a/src/units/Chevalier.java b/src/units/Chevalier.java index 6a1f134b0e0159438a440ea0dfae8efb83e8a802..583bfb0bc41f78e31b160f62530e0521a9d7b8dd 100644 --- a/src/units/Chevalier.java +++ b/src/units/Chevalier.java @@ -1,6 +1,5 @@ package units; -import main.Case; import main.Joueur; import main.Plateau; @@ -9,9 +8,10 @@ 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 int VISION = 2; public Chevalier(int x, int y, Plateau plateau, Joueur joueur) { - super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur); + super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur, VISION); } diff --git a/src/units/Eclaireur.java b/src/units/Eclaireur.java index c7cbeba173c9f1807d4e641e7d2e3e17b1a666d4..62aaeb6e6db81bec5623ebcfdaab96da03986d49 100644 --- a/src/units/Eclaireur.java +++ b/src/units/Eclaireur.java @@ -1,6 +1,5 @@ package units; -import main.Case; import main.Joueur; import main.Plateau; @@ -9,9 +8,10 @@ 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 int VISION = 2; public Eclaireur(int x, int y, Plateau plateau, Joueur joueur) { - super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur); + super(x,y, plateau, SYMBOL, ARMOR, DAMAGE, joueur, VISION); } diff --git a/src/units/Paysant.java b/src/units/Paysant.java index 125145f52b09e750dccf1996a60cfd2556c6a054..f361b7e5fb16d3d4d09396d93d3af5b09304e6eb 100644 --- a/src/units/Paysant.java +++ b/src/units/Paysant.java @@ -2,7 +2,6 @@ package units; import java.util.Scanner; -import main.Case; import main.Joueur; import main.Plateau; @@ -50,7 +49,7 @@ public class Paysant extends Unite{ sc.close(); return true; }else { - //TODO:utiliser un syst�me de v�rification d'entr�e globale + //TODO:utiliser un système de vérification d'entrée globale System.out.println("ERROR"); } @@ -60,7 +59,7 @@ public class Paysant extends Unite{ } public void combattre() { - //TODO: il faut d'abord regarder si une unit� est pr�sente autour + //TODO: il faut d'abord regarder si une unité est présente autour } public void actionGivePA() { diff --git a/src/units/Unite.java b/src/units/Unite.java index 26c43201d1eeee7ad7a4e19cb8ae17e1a698a89d..98b0f2ec74aa271c48c9d2c751e1c880f17fe65d 100644 --- a/src/units/Unite.java +++ b/src/units/Unite.java @@ -1,9 +1,9 @@ package units; +import java.util.Random; + import items.Items; import main.Case; -import main.Direction; -import main.Event; import main.Joueur; import main.Plateau; import main.Type; @@ -31,6 +31,7 @@ public abstract class Unite { this.x = x; this.y = y; this.joueur = joueur; + this.joueur.ajoutUnit(this); this.item = null; this.vision = vision; } @@ -115,40 +116,50 @@ public abstract class Unite { 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 ) { this.plateau.getCase(x, y).setUnite(this); 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)); - } + return true; } return false; } //à voir le type - public boolean move(Direction d) { - if(d == Direction.BAS) { + 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) { + //combat(); + } if (updatePosition(x+1,y)) { this.plateau.getCase(x, y).setUnite(null); + this.plateau.getCase(x, y).setType(Type.GRASS); + this.x+=1; updateDecouverte(this.plateau.getCase(x+1, y), this.vision); return true; } } - else if(d == Direction.DROITE) { + 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.y+=1; updateDecouverte(this.plateau.getCase(x, y+1), this.vision); return true; } } - else if(d == Direction.GAUCHE) { + 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.y-=1; updateDecouverte(this.plateau.getCase(x, y-1), this.vision); return true; } } - else if(d == Direction.HAUT) { + 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.x-=1; updateDecouverte(this.plateau.getCase(x-1, y), this.vision); return true; } @@ -156,6 +167,22 @@ public abstract class Unite { return false; } + public void teleporte() { + Random alea = new Random(); + int longueur = plateau.getPlateau().length*plateau.getRegion(0, 0).region.length; + int rd1 = alea.nextInt(longueur); + int rd2 = alea.nextInt(longueur); + + while(plateau.getCase(rd1, rd2).getType()!=Type.GRASS) { + rd1 = alea.nextInt(longueur); + rd2 = alea.nextInt(longueur); + } + updatePosition(rd1,rd2); + this.plateau.getCase(x, y).setUnite(null); + this.plateau.getCase(x, y).setType(Type.GRASS); + this.x=rd1; + this.y=rd2; + } public void updateDecouverte (Case emplacement, int vision) { if (vision > -1) { if (emplacement.getX() < 29) { @@ -184,7 +211,6 @@ public abstract class Unite { } } } - public abstract String toString();