Skip to content
Snippets Groups Projects
Commit ac934cef authored by Gabriel Mille's avatar Gabriel Mille
Browse files

correction input / main

parent c13b6c91
No related branches found
No related tags found
No related merge requests found
...@@ -27,10 +27,17 @@ public class Input { ...@@ -27,10 +27,17 @@ public class Input {
} }
public void newInput(String input) { public void newInput() {
BufferedReader in= new BufferedReader( new InputStreamReader(System.in));
do { do {
try { try {
setInput(input); try {
setInput(in.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (InvalidInputException e) { } catch (InvalidInputException e) {
try { try {
Display.newPrintln(e.getMessage()); Display.newPrintln(e.getMessage());
......
...@@ -63,9 +63,11 @@ class Main { ...@@ -63,9 +63,11 @@ class Main {
Input input = new Input(); Input input = new Input();
input.newInput(in.readLine()); input.newInput();
Display.goToDialogBox(); Display.goToDialogBox();
if (input.getInput().equals("a")) {
while (!input.getInput().equals("q") && !enemy.isDead() && !player.isDead()) { 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 //A garder au début de la boucle, mesure le temps que le joueur à pris d'écrire
...@@ -76,7 +78,7 @@ class Main { ...@@ -76,7 +78,7 @@ class Main {
level.ennemyShowing(); level.ennemyShowing();
level.possibleActions(); level.possibleActions();
input.newInput(in.readLine()); input.newInput();
// Boucle tant que le joueur n'a pas taper de nom d'une attaque valide ou tape trop tard ou tape q // 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")) { while ((!actionNames.contains(input.getInput()) || !Attack.attackInTime(timeBeforeAttack, attackTime)) && !input.getInput().equals("q")) {
...@@ -86,13 +88,13 @@ class Main { ...@@ -86,13 +88,13 @@ class Main {
Attack randomEnemyAttack = Attack.values()[(int) rand.nextDouble()*Attack.values().length]; Attack randomEnemyAttack = Attack.values()[(int) rand.nextDouble()*Attack.values().length];
level.ennemyFaster(randomEnemyAttack); level.ennemyFaster(randomEnemyAttack);
timeBeforeAttack = LocalDateTime.now(); timeBeforeAttack = LocalDateTime.now();
input.newInput(in.readLine()); input.newInput();
} }
if (!actionNames.contains(input.getInput())){ if (!actionNames.contains(input.getInput())){
Display.clearDialogBox(); Display.clearDialogBox();
level.invalidActionChoice(); level.invalidActionChoice();
input.newInput(in.readLine()); input.newInput();
System.out.println(actionNames.toString()); System.out.println(actionNames.toString());
System.out.println(input.getInput()); System.out.println(input.getInput());
} }
...@@ -128,7 +130,9 @@ class Main { ...@@ -128,7 +130,9 @@ class Main {
} }
}
in.close(); in.close();
Save.saveObject("res/gamedata", gamedata); Save.saveObject("res/gamedata", gamedata);
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment