diff --git a/src/main/java/org/bitbiome/commands/UseCommand.java b/src/main/java/org/bitbiome/commands/UseCommand.java index 2fcda38..4361b74 100644 --- a/src/main/java/org/bitbiome/commands/UseCommand.java +++ b/src/main/java/org/bitbiome/commands/UseCommand.java @@ -31,13 +31,19 @@ private boolean combat = false; player.setHp(hp); } //TODO get input from player - do { + COMBAT_LOOP:do { System.out.println("What do you want to do?"); String input = scanner.nextLine(); switch(input) { case "use": use(scanner, engine); break; + case "runaway": + if(runawaySucceeds()) { + combat = false; + break COMBAT_LOOP; + } + break; default: System.out.println("That is not a valid command."); break; @@ -46,6 +52,13 @@ private boolean combat = false; } } + public boolean runawaySucceeds() { + int chance = (int)(Math.random()*100); + if(chance < 50) + return true; + return false; + } + public void use(Scanner scanner, TravelEngine engine) { System.out.println("Which item would you like to use?"); String item = scanner.nextLine();