Select Git revision
-
Mohamed Taarit authoredMohamed Taarit authored
Main.java 2.61 KiB
package bitFight;
import java.sql.Date;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Random;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random rand = new Random();
LocalDateTime timeBeforeAttack = LocalDateTime.now();
int attackTime = 8 - (int)(5 * rand.nextDouble()); //A garder au début de la boucle
Input input = new Input();
input.setInput(in.nextLine());
Enemy JoueurEnnemi = new Enemy(2);
System.out.println(JoueurEnnemi.getCurrentHealth());
while (!input.getInput().equals("q") && !JoueurEnnemi.isDead()) {
System.out.println("départ");
if(!input.validInput()){
System.out.println("Error input invalid");
input.setInput(in.nextLine());
}
System.out.println("input valide");
if (input.getInput().toUpperCase().equals("PUNCH")) {
JoueurEnnemi.damage(Attack.PUNCH.getDamage());
System.out.println("Ennemi" + " health : " + (int) JoueurEnnemi.getCurrentHealth());
input.setInput(in.nextLine());
}else if(input.getInput().toUpperCase().equals("KICK")) {
JoueurEnnemi.damage(Attack.KICK.getDamage());
System.out.println("Ennemi" + " health : " + (int) JoueurEnnemi.getCurrentHealth());
input.setInput(in.nextLine());
}else if (input.getInput().toUpperCase().equals("SUPERMAN PUNCH")) {
JoueurEnnemi.damage(Attack.SUPERMANPUNCH.getDamage());
System.out.println("Ennemi" + " health : " + (int) JoueurEnnemi.getCurrentHealth());
input.setInput(in.nextLine());
}else if (input.getInput().toUpperCase().equals("DOUBLE KICK")) {
JoueurEnnemi.damage(Attack.DOUBLEKICK.getDamage());
System.out.println("Ennemi" + " health : " + (int) JoueurEnnemi.getCurrentHealth());
input.setInput(in.nextLine());
}else{
System.out.println("cette attaque n'est pas disponible :( \n les attaques disponible sont : \n \t punch , kick , double kikck , superman punch . ");
}
if(Duration.between(timeBeforeAttack, LocalDateTime.now()).toSeconds() > attackTime){
//TODO, code pour joueur qui vient de se faire attaquer, FIN DE BOUCLE
System.out.println("?? ");
}
}
// C'est mon commentaire
in.close();
}
}