diff --git a/assets/.nfs000000000aec14f700000040 b/assets/.nfs000000000aec14f700000040 deleted file mode 100644 index 3824c2cfa6d57ed073ec9ad88effe88f20d33bf0..0000000000000000000000000000000000000000 --- a/assets/.nfs000000000aec14f700000040 +++ /dev/null @@ -1,19 +0,0 @@ -________________________________________________________________________________________________________________________ - - - - - - - - - - -________________________________________________________________________________________________________________________ - -Commandes : - - a - Attaquer - q - Quitter - -________________________________________________________________________________________________________________________ \ No newline at end of file diff --git a/assets/DialogBox.text b/assets/DialogBox.text index a0fe731c5faa5accf1db9755257991abc02ec850..3824c2cfa6d57ed073ec9ad88effe88f20d33bf0 100644 --- a/assets/DialogBox.text +++ b/assets/DialogBox.text @@ -15,6 +15,5 @@ Commandes : a - Attaquer q - Quitter - r - Règles ________________________________________________________________________________________________________________________ \ No newline at end of file diff --git a/doc/sprint-7/README.md b/doc/sprint-7/README.md index 979dc474dcacc52a19946f439d16e1c3b094c94d..877f8e7df16a9b5b7bb95d4d117383cb5ddc4daa 100644 --- a/doc/sprint-7/README.md +++ b/doc/sprint-7/README.md @@ -1,7 +1,9 @@ # Sprint 7 ### Ce que nous avons fait durant ce sprint - +- Correction commune d'une majorité du main +- Ajout des caractéristiques aléatoires +- Implémentation du score et de la sauvegarde ### Ce que nous allons faire durant le prochain sprint diff --git a/res/Defeat b/res/Defeat new file mode 100644 index 0000000000000000000000000000000000000000..f2a6c75e852dfdf71b1b10ba1b52560b7a0a3f26 --- /dev/null +++ b/res/Defeat @@ -0,0 +1,8 @@ + ______ _______ _______ _______ _______ _________ +( __ \ ( ____ \( ____ \( ____ \( ___ )\__ __/ +| ( \ )| ( \/| ( \/| ( \/| ( ) | ) ( +| | ) || (__ | (__ | (__ | (___) | | | +| | | || __) | __) | __) | ___ | | | +| | ) || ( | ( | ( | ( ) | | | +| (__/ )| (____/\| ) | (____/\| ) ( | | | +(______/ (_______/|/ (_______/|/ \| )_( \ No newline at end of file diff --git a/res/You b/res/You new file mode 100644 index 0000000000000000000000000000000000000000..011fa174b95a34adcd17b4232b8acf149fc1392d --- /dev/null +++ b/res/You @@ -0,0 +1,18 @@ +|\ /|( ___ )|\ /| +( \ / )| ( ) || ) ( | + \ (_) / | | | || | | | + \ / | | | || | | | + ) ( | | | || | | | + | | | (___) || (___) | + \_/ (_______)(_______) + + + + + + + + + + + diff --git a/res/game b/res/game new file mode 100644 index 0000000000000000000000000000000000000000..fb842619a8d9be0494ab0d8b92f1ee454fab6174 --- /dev/null +++ b/res/game @@ -0,0 +1,9 @@ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⡀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⠀⠀⠀⢀⣴⣿⡶⠀⣾⣿⣿⡿⠟⠛⠁ +⠀⠀⠀⠀⠀⠀⣀⣀⣄⣀⠀⠀⠀⠀⣶⣶⣦⠀⠀⠀⠀⣼⣿⣿⡇⠀⣠⣿⣿⣿⠇⣸⣿⣿⣧⣤⠀⠀⠀ +⠀⠀⢀⣴⣾⣿⡿⠿⠿⠿⠇⠀⠀⣸⣿⣿⣿⡆⠀⠀⢰⣿⣿⣿⣷⣼⣿⣿⣿⡿⢀⣿⣿⡿⠟⠛⠁⠀⠀ +⠀⣴⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⢠⣿⣿⣹⣿⣿⣿⣿⣿⣿⡏⢻⣿⣿⢿⣿⣿⠃⣼⣿⣯⣤⣴⣶⣿⡤⠀ +⣼⣿⠏⠀⣀⣠⣤⣶⣾⣷⠄⣰⣿⣿⡿⠿⠻⣿⣯⣸⣿⡿⠀⠀⠀⠁⣾⣿⡏⢠⣿⣿⠿⠛⠋⠉⠀⠀⠀ +⣿⣿⠲⢿⣿⣿⣿⣿⡿⠋⢰⣿⣿⠋⠀⠀⠀⢻⣿⣿⣿⠇⠀⠀⠀⠀⠙⠛⠀⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀ +⠹⢿⣷⣶⣿⣿⠿⠋⠀⠀⠈⠙⠃⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠈⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ \ No newline at end of file diff --git a/res/gamedata b/res/gamedata new file mode 100644 index 0000000000000000000000000000000000000000..fafc4f3b042ef346d262a267ce84ed591d917112 Binary files /dev/null and b/res/gamedata differ diff --git a/res/lose b/res/lose new file mode 100644 index 0000000000000000000000000000000000000000..e26b10a481f01425e1ea55b4ca36ec323b811d1d --- /dev/null +++ b/res/lose @@ -0,0 +1,7 @@ +( \ ( ___ )( ____ \( ____ \ +| ( | ( ) || ( \/| ( \/ +| | | | | || (_____ | (__ +| | | | | |(_____ )| __) +| | | | | | ) || ( +| (____/\| (___) |/\____) || (____/\ +(_______/(_______)\_______)(_______/ \ No newline at end of file diff --git a/res/over b/res/over new file mode 100644 index 0000000000000000000000000000000000000000..a54006d1cfd826effc27fe1e93f72aa8073230b4 --- /dev/null +++ b/res/over @@ -0,0 +1,8 @@ +⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣤⣴⣶⣦⣤⡀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⡇⢰⣶⣶⣾⡿⠷⣿⣿⣿⡟⠛⣉⣿⣿⣿⠆ +⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⡎⣿⣿⣦⠀⠀⠀⢀⣤⣾⠟⢀⣿⣿⡟⣁⠀⠀⣸⣿⣿⣤⣾⣿⡿⠛⠁⠀ +⠀⠀⠀⠀⣠⣾⣿⡿⠛⠉⢿⣦⠘⣿⣿⡆⠀⢠⣾⣿⠋⠀⣼⣿⣿⣿⠿⠷⢠⣿⣿⣿⠿⢻⣿⣧⠀⠀⠀ +⠀⠀⠀⣴⣿⣿⠋⠀⠀⠀⢸⣿⣇⢹⣿⣷⣰⣿⣿⠃⠀⢠⣿⣿⢃⣀⣤⣤⣾⣿⡟⠀⠀⠀⢻⣿⣆⠀⠀ +⠀⠀⠀⣿⣿⡇⠀⠀⢀⣴⣿⣿⡟⠀⣿⣿⣿⣿⠃⠀⠀⣾⣿⣿⡿⠿⠛⢛⣿⡟⠀⠀⠀⠀⠀⠻⠿⠀⠀ +⠀⠀⠀⠹⣿⣿⣶⣾⣿⣿⣿⠟⠁⠀⠸⢿⣿⠇⠀⠀⠀⠛⠛⠁⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ \ No newline at end of file diff --git a/res/victory.clj b/res/victory.clj new file mode 100644 index 0000000000000000000000000000000000000000..cb07a11eb29d23a9b8fe5edebbfe4c5596c182ea --- /dev/null +++ b/res/victory.clj @@ -0,0 +1,19 @@ + _________ _______ _________ _______ _______ +|\ /|\__ __/( ____ \\__ __/( ___ )( ____ )|\ /| +| ) ( | ) ( | ( \/ ) ( | ( ) || ( )|( \ / ) +| | | | | | | | | | | | | || (____)| \ (_) / +( ( ) ) | | | | | | | | | || __) \ / + \ \_/ / | | | | | | | | | || (\ ( ) ( + \ / ___) (___| (____/\ | | | (___) || ) \ \__ | | + \_/ \_______/(_______/ )_( (_______)|/ \__/ \_/ + + + + + + + + + + + diff --git a/res/won b/res/won new file mode 100644 index 0000000000000000000000000000000000000000..9906ca6f45d9e0568a3701c6d9aa43a070951e81 --- /dev/null +++ b/res/won @@ -0,0 +1,18 @@ +|\ /|\__ __/( ( /| +| ) ( | ) ( | \ ( | +| | _ | | | | | \ | | +| |( )| | | | | (\ \) | +| || || | | | | | \ | +| () () |___) (___| ) \ | +(_______)\_______/|/ )_) + + + + + + + + + + + diff --git a/src/main/java/bitFight/Attack.java b/src/main/java/bitFight/Attack.java index a6d5cc3e8cd4c74978bb9f2a6980bb08e1f6fcf2..d551dfd321d51145a2407649f9350d3b1754da91 100644 --- a/src/main/java/bitFight/Attack.java +++ b/src/main/java/bitFight/Attack.java @@ -14,7 +14,6 @@ public enum Attack implements Action { private String name; private ActionHeight height; private int energyCost; - public static ArrayList<String> attacksNames = new ArrayList<String>(); Attack(int damage, String name, ActionHeight height, int energyCost) { this.damage = damage; @@ -44,8 +43,4 @@ public enum Attack implements Action { public static boolean attackInTime(LocalDateTime timeBeforeAttack, int attackTime) { return (Duration.between(timeBeforeAttack, LocalDateTime.now()).toSeconds() > attackTime); } - - public static String getIndexOfInput(String input) { - return Attack.attacksNames.get(attacksNames.indexOf(input)).toUpperCase(); - } } \ No newline at end of file diff --git a/src/main/java/bitFight/Input.java b/src/main/java/bitFight/Input.java index e30c23caf3e36f3e8f3384c334961d2f077c816d..1b19f6f427d0cd68b5f529b97278c0b4779e9a0d 100644 --- a/src/main/java/bitFight/Input.java +++ b/src/main/java/bitFight/Input.java @@ -27,10 +27,17 @@ public class Input { } - public void newInput(String input) { - while (!validInput()) { + public void newInput() { + BufferedReader in= new BufferedReader( new InputStreamReader(System.in)); + + do { try { - setInput(input); + try { + setInput(in.readLine()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } catch (InvalidInputException e) { try { Display.newPrintln(e.getMessage()); @@ -39,12 +46,16 @@ public class Input { } } } + while (!validInput()); + } public Input() { this.inputRange = new ArrayList<>(); this.inputRange.add("q"); //Commande pour quitter this.inputRange.add("a"); //Commande pour attaquer + for (Attack a : Attack.values()) this.inputRange.add(a.getName()); + for (Defense d : Defense.values()) this.inputRange.add(d.getName()); } public boolean validInput() { diff --git a/src/main/java/bitFight/Level.java b/src/main/java/bitFight/Level.java index 94afafcf5eaa65f4075732ef86a53fb467f0f25a..b129a2f8e8afb9a8950df81469a090e47fa68877 100644 --- a/src/main/java/bitFight/Level.java +++ b/src/main/java/bitFight/Level.java @@ -64,7 +64,8 @@ public class Level{ public void ennemyFaster(Attack attack) { System.out.println("The ennemy attacks before you can !"); player.setCurrentHealth(player.getCurrentHealth() - attack.getDamage() * this.ennemy.getAttackMultiplier()); //Récupère une attaque aléatoire dans l'enum - System.out.println(attack.getName() + "!! You're getting " + attack.getDamage() * this.ennemy.getAttackMultiplier() + " damage!"); + System.out.println(attack.getName() + "!! You're getting " + (int) attack.getDamage() * this.ennemy.getAttackMultiplier() + " of damage!"); + System.out.println(this.player.getName() + "'s life' : " + this.displayPlayerHealth()); } // affiche la jauge de vie @@ -149,10 +150,7 @@ public class Level{ } } - public void victory(){ - System.out.println(" FINAL VICTORY "+'\n'); - System.out.println("You won! "); - } + //Affichage ascii @@ -165,5 +163,43 @@ public class Level{ Image image=new Image("res/mouvement.ini", 16); image.imageGenerator(); } + + public static void gameOver() throws IOException, InterruptedException{ + Image image=new Image("res/game", 9); + image.imageGenerator(); + Thread.sleep(700); + Image image2=new Image("res/over", 8); + image2.imageGenerator(); + Thread.sleep(1250); + Display.clearScreen(); + + } + + public static void victory() throws IOException, InterruptedException{ + Image image=new Image("res/victory.clj", 8); + image.imageGenerator(); + Thread.sleep(1250); + Display.clearScreen(); + Image image2=new Image("res/You", 7); + image2.imageGenerator(); + Thread.sleep(1000); + Image image3=new Image("res/won", 7); + image3.imageGenerator(); + } + + public static void defeat() throws IOException, InterruptedException{ + Image image=new Image("res/Defeat", 8); + image.imageGenerator(); + Thread.sleep(1250); + Display.clearScreen(); + Image image2=new Image("res/You", 7); + image2.imageGenerator(); + Thread.sleep(1000); + Image image3=new Image("res/lose", 7); + image3.imageGenerator(); + } + } + + diff --git a/src/main/java/bitFight/LevelTest.java b/src/main/java/bitFight/LevelTest.java index 861dd9039d323f752bcdc43b2b6422873ca6a736..0cff06e7432c8215371faf494f5e336dfcef1f19 100644 --- a/src/main/java/bitFight/LevelTest.java +++ b/src/main/java/bitFight/LevelTest.java @@ -3,8 +3,10 @@ package bitFight; import java.io.IOException; public class LevelTest { - public static void main(String[] args) throws IOException { - Level.fightScene(); - Level.bigFightScene(); + public static void main(String[] args) throws IOException, InterruptedException { + //Level.fightScene(); + //Level.bigFightScene(); + Level.gameOver(); + Level.defeat(); } } diff --git a/src/main/java/bitFight/Main.java b/src/main/java/bitFight/Main.java index 9ccbf446c465821530d2fb9d6a9eaabfbcac9077..74a651dd045f8d7011025139451bc5c768a63352 100644 --- a/src/main/java/bitFight/Main.java +++ b/src/main/java/bitFight/Main.java @@ -63,54 +63,56 @@ class Main { Input input = new Input(); - input.newInput(in.readLine()); + input.newInput(); Display.goToDialogBox(); - while (!input.getInput().equals("q") && !enemy.isDead() && !player.isDead()) { + if (input.getInput().equals("a")) { - //A garder au début de la boucle, mesure le temps que le joueur à pris d'écrire - LocalDateTime timeBeforeAttack = LocalDateTime.now(); - int attackTime = 5 - (int)(5 * rand.nextDouble()); - - if (input.getInput().equals("a")) { + while (!input.getInput().equals("q") && !enemy.isDead() && !player.isDead()) { + + //A garder au début de la boucle, mesure le temps que le joueur à pris d'écrire + LocalDateTime timeBeforeAttack = LocalDateTime.now(); + int attackTime = 5 - (int)(5 * rand.nextDouble()); + + // arrivée de l'ennemi + level.ennemyShowing(); + level.possibleActions(); - input.newInput(in.readLine()); + input.newInput(); - // Boucle tant que le joueur n'a pas taper de nom d'une attaque valide - while (!actionNames.contains(input.getInput()) || Attack.attackInTime(timeBeforeAttack, attackTime)) { - level.ennemyShowing(); + // Boucle tant que le joueur n'a pas taper de nom d'une attaque valide ou tape trop tard ou tape q + while ((!actionNames.contains(input.getInput()) || !Attack.attackInTime(timeBeforeAttack, attackTime)) && !input.getInput().equals("q")) { //Si le joueur est trop lent, l'ennemi fait une attaque aléatoire - if(Attack.attackInTime(timeBeforeAttack, attackTime)){ + if(!Attack.attackInTime(timeBeforeAttack, attackTime)){ Display.clearDialogBox(); Attack randomEnemyAttack = Attack.values()[(int) rand.nextDouble()*Attack.values().length]; level.ennemyFaster(randomEnemyAttack); timeBeforeAttack = LocalDateTime.now(); - input.newInput(in.readLine()); + input.newInput(); } - + if (!actionNames.contains(input.getInput())){ Display.clearDialogBox(); level.invalidActionChoice(); - input.newInput(in.readLine()); + input.newInput(); System.out.println(actionNames.toString()); System.out.println(input.getInput()); } } - if(!player.isExhausted()){ + if(!player.isExhausted() && !input.getInput().equals("q") ){ Attack attack = Attack.valueOf(actionNames.get(actionNames.indexOf(input.getInput())).toUpperCase()); level.playerHasEnergy(attack); } else {} //TODO ajouter display trop fatigué - + //Display.clearDialogBox(); - + Display.newPrintln(enemy.toString()); - + //Display.clearDialogBox(); - - input.newInput(in.readLine());; + if (enemy.isDead()){ level.ennemyDying(); player.revive(); @@ -118,18 +120,19 @@ class Main { enemy.levelUp(); level.levelGoingUp(); Display.clearDialogBox(); - System.out.println('\n'); - System.out.println(" Congrats! "+'\n'); - System.out.println(" you won your first fight! + \n \t let's see what you can do with your second ennemy... Good luck! \n\t your currrent enemy level is "+level.getEnnemy().getLevel()); - + System.out.println('\n'); + System.out.println(" Congrats! "+'\n'); + System.out.println(" you won your first fight! + \n \t let's see what you can do with your second ennemy... Good luck! \n\t your currrent enemy level is "+level.getEnnemy().getLevel()); + System.out.println(" \n this time your enemy health is "+ (int) level.getEnnemy().getCurrentHealth()+ "\n ... "); - + } } + + } + in.close(); + Save.saveObject("res/gamedata", gamedata); } - - in.close(); - Save.saveObject("res/gamedata", gamedata); - } -} + } + \ No newline at end of file diff --git a/src/main/java/bitFight/Menu.java b/src/main/java/bitFight/Menu.java index 49a5bff66c47f781555b7d4d4203520e8ae1fe76..f3099a4551d85f351ad4ebaab6fe0097f4d27d4b 100644 --- a/src/main/java/bitFight/Menu.java +++ b/src/main/java/bitFight/Menu.java @@ -16,10 +16,10 @@ public class Menu{ public void display() throws IOException, InterruptedException{ Image image=new Image("res/logo.clj", 8); image.imageGenerator(); - Thread.sleep(2000); + Thread.sleep(1000); Image image3=new Image("res/slogan.clj", 8); image3.imageGenerator(); - Thread.sleep(2000); + Thread.sleep(1000); System.out.println('\n'); System.out.println(" Welcome to BitFight, a combat game. Press enter to continue"+'\n'); Image image2= new Image("res/perso-1.txt", 14); @@ -40,17 +40,17 @@ public class Menu{ System.out.println("To fight, type 'a' and press Enter."); System.out.println("To exit the game at any moment, type 'q' and press Enter."); System.out.println('\n'); - Thread.sleep(2000); + Thread.sleep(650); System.out.println(" GAME RULES... "+'\n'); - Thread.sleep(2000); + Thread.sleep(650); System.out.println(" You have 10 seconds to type the attack of your choice against your enemy."); - Thread.sleep(2000); + Thread.sleep(650); System.out.println(" If you're too slow, your enemy will attack and you will loose vitality points"); - Thread.sleep(2000); + Thread.sleep(650); System.out.println(" If you win you will move on to the next level, but if you loose you will be ... "); - Thread.sleep(2000); + Thread.sleep(650); System.out.println(" TERMINATED!"); - Thread.sleep(2000); + Thread.sleep(650); System.out.println('\n'); System.out.println(" Press enter to continue..."); diff --git a/src/test/java/bitFight/AttackTest.java b/src/test/java/bitFight/AttackTest.java index 9d5884ceb7dd8186a7c20d1148dc1359cf5e6a4f..9291acb0143b5e262256144c9eed380abcae11e0 100644 --- a/src/test/java/bitFight/AttackTest.java +++ b/src/test/java/bitFight/AttackTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; public class AttackTest { Player player = new Player("joueur1"); - Enemy ennemy = new Enemy("ennemy", 3); + Enemy ennemy = new Enemy("ennemy", 1); @Test void testGetDamage() { @@ -19,10 +19,11 @@ public class AttackTest { ennemy.setCurrentHealth(100.0); assertEquals("Joueur : " + (int)player.getCurrentHealth(), "Joueur : 100"); assertEquals("Ennemi : " + (int)ennemy.getCurrentHealth(), "Ennemi : 100"); - String attack = Attack.getIndexOfInput("kick"); - ennemy.damage(Attack.valueOf(attack).getDamage()); + ennemy.damage(Attack.PUNCH.getDamage()); + player.exhaust(Attack.PUNCH.getEnergyCost()); assertEquals("Joueur : " + (int)player.getCurrentHealth(), "Joueur : 100"); assertEquals("Ennemi : " + (int)ennemy.getCurrentHealth(), "Ennemi : 90"); + assertEquals("Energie joueur : " + (int)player.getCurrentEnergy(), "Energie joueur : 90"); } }