Browse Source

Added ability to run away in combat

remotes/origin/fight-engine
fdai7430 2 years ago
parent
commit
6a2c1f96c6
  1. 15
      src/main/java/org/bitbiome/commands/UseCommand.java

15
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();

Loading…
Cancel
Save