Skip to content
Snippets Groups Projects
Commit 3ebbb919 authored by Mohamed Taarit's avatar Mohamed Taarit
Browse files
parents 7fa9a665 464bf339
No related branches found
No related tags found
No related merge requests found
________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________
Commandes :
a - Attaquer
q - Quitter
________________________________________________________________________________________________________________________
\ No newline at end of file
......@@ -15,6 +15,5 @@ Commandes :
a - Attaquer
q - Quitter
r - Règles
________________________________________________________________________________________________________________________
\ No newline at end of file
# 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
......
______ _______ _______ _______ _______ _________
( __ \ ( ____ \( ____ \( ____ \( ___ )\__ __/
| ( \ )| ( \/| ( \/| ( \/| ( ) | ) (
| | ) || (__ | (__ | (__ | (___) | | |
| | | || __) | __) | __) | ___ | | |
| | ) || ( | ( | ( | ( ) | | |
| (__/ )| (____/\| ) | (____/\| ) ( | | |
(______/ (_______/|/ (_______/|/ \| )_(
\ No newline at end of file
res/You 0 → 100644
|\ /|( ___ )|\ /|
( \ / )| ( ) || ) ( |
\ (_) / | | | || | | |
\ / | | | || | | |
) ( | | | || | | |
| | | (___) || (___) |
\_/ (_______)(_______)
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⡀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⠀⠀⠀⢀⣴⣿⡶⠀⣾⣿⣿⡿⠟⠛⠁
⠀⠀⠀⠀⠀⠀⣀⣀⣄⣀⠀⠀⠀⠀⣶⣶⣦⠀⠀⠀⠀⣼⣿⣿⡇⠀⣠⣿⣿⣿⠇⣸⣿⣿⣧⣤⠀⠀⠀
⠀⠀⢀⣴⣾⣿⡿⠿⠿⠿⠇⠀⠀⣸⣿⣿⣿⡆⠀⠀⢰⣿⣿⣿⣷⣼⣿⣿⣿⡿⢀⣿⣿⡿⠟⠛⠁⠀⠀
⠀⣴⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⢠⣿⣿⣹⣿⣿⣿⣿⣿⣿⡏⢻⣿⣿⢿⣿⣿⠃⣼⣿⣯⣤⣴⣶⣿⡤⠀
⣼⣿⠏⠀⣀⣠⣤⣶⣾⣷⠄⣰⣿⣿⡿⠿⠻⣿⣯⣸⣿⡿⠀⠀⠀⠁⣾⣿⡏⢠⣿⣿⠿⠛⠋⠉⠀⠀⠀
⣿⣿⠲⢿⣿⣿⣿⣿⡿⠋⢰⣿⣿⠋⠀⠀⠀⢻⣿⣿⣿⠇⠀⠀⠀⠀⠙⠛⠀⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀
⠹⢿⣷⣶⣿⣿⠿⠋⠀⠀⠈⠙⠃⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠈⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
\ No newline at end of file
File added
( \ ( ___ )( ____ \( ____ \
| ( | ( ) || ( \/| ( \/
| | | | | || (_____ | (__
| | | | | |(_____ )| __)
| | | | | | ) || (
| (____/\| (___) |/\____) || (____/\
(_______/(_______)\_______)(_______/
\ No newline at end of file
⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣤⣴⣶⣦⣤⡀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⡇⢰⣶⣶⣾⡿⠷⣿⣿⣿⡟⠛⣉⣿⣿⣿⠆
⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⡎⣿⣿⣦⠀⠀⠀⢀⣤⣾⠟⢀⣿⣿⡟⣁⠀⠀⣸⣿⣿⣤⣾⣿⡿⠛⠁⠀
⠀⠀⠀⠀⣠⣾⣿⡿⠛⠉⢿⣦⠘⣿⣿⡆⠀⢠⣾⣿⠋⠀⣼⣿⣿⣿⠿⠷⢠⣿⣿⣿⠿⢻⣿⣧⠀⠀⠀
⠀⠀⠀⣴⣿⣿⠋⠀⠀⠀⢸⣿⣇⢹⣿⣷⣰⣿⣿⠃⠀⢠⣿⣿⢃⣀⣤⣤⣾⣿⡟⠀⠀⠀⢻⣿⣆⠀⠀
⠀⠀⠀⣿⣿⡇⠀⠀⢀⣴⣿⣿⡟⠀⣿⣿⣿⣿⠃⠀⠀⣾⣿⣿⡿⠿⠛⢛⣿⡟⠀⠀⠀⠀⠀⠻⠿⠀⠀
⠀⠀⠀⠹⣿⣿⣶⣾⣿⣿⣿⠟⠁⠀⠸⢿⣿⠇⠀⠀⠀⠛⠛⠁⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
\ No newline at end of file
_________ _______ _________ _______ _______
|\ /|\__ __/( ____ \\__ __/( ___ )( ____ )|\ /|
| ) ( | ) ( | ( \/ ) ( | ( ) || ( )|( \ / )
| | | | | | | | | | | | | || (____)| \ (_) /
( ( ) ) | | | | | | | | | || __) \ /
\ \_/ / | | | | | | | | | || (\ ( ) (
\ / ___) (___| (____/\ | | | (___) || ) \ \__ | |
\_/ \_______/(_______/ )_( (_______)|/ \__/ \_/
res/won 0 → 100644
|\ /|\__ __/( ( /|
| ) ( | ) ( | \ ( |
| | _ | | | | | \ | |
| |( )| | | | | (\ \) |
| || || | | | | | \ |
| () () |___) (___| ) \ |
(_______)\_______/|/ )_)
......@@ -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
......@@ -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() {
......
......@@ -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();
}
}
......@@ -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();
}
}
......@@ -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
......@@ -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...");
......
......@@ -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");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment