Select Git revision
LevelDisplay.java
-
Charlie Darques authoredCharlie Darques authored
LevelDisplay.java 1.14 KiB
package bitFight;
import java.util.Scanner;
public class LevelDisplay {
private int levelNb = 1;
private String levelText = "New level : prepare to fight!";
public int getLevelNb() {
return levelNb;
}
public void display() {
System.out.println("Niveau " + this.levelNb);
System.out.println(this.levelText);
}
public boolean validate() {
Scanner sc = new Scanner(System.in);
String c = sc.nextLine();
if (c == null) {
sc.close();
return false;
}
sc.close();
return true;
}
public void ennemyShowing(Enemy ennemy) {
System.out.println("An ennemy just appeared : " + ennemy.toString());
}
public void ennemyDying() {
System.out.println("The ennemy is dead!");
}
public void fighting(Player p, Enemy ennemy) {
System.out.println(p.getName() + "'s life : " + p.getCurrentHealth());
this.ennemyShowing(ennemy);
System.out.println("Press any key to attack and press enter");
this.validate();
if (this.validate()) {
this.ennemyDying();
}
}
}