|
@ -14,14 +14,7 @@ private boolean combat = false; |
|
|
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine engine) { |
|
|
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine engine) { |
|
|
Player player = engine.getPlayer(); |
|
|
Player player = engine.getPlayer(); |
|
|
getEnemies(player.getLocation().getMobList()); |
|
|
getEnemies(player.getLocation().getMobList()); |
|
|
System.out.println("Which item would you like to use?"); |
|
|
|
|
|
String item = scanner.nextLine(); |
|
|
|
|
|
System.out.println("On who? (leave blank for self)"); |
|
|
|
|
|
String target = scanner.nextLine(); |
|
|
|
|
|
if(target.equals("")) |
|
|
|
|
|
System.out.println(getUseMessage(item, engine)); |
|
|
|
|
|
else |
|
|
|
|
|
System.out.println(getUseMessage(item + " on " + target, engine)); |
|
|
|
|
|
|
|
|
use(scanner, engine); |
|
|
while(enemies.size() > 0 && combat) { |
|
|
while(enemies.size() > 0 && combat) { |
|
|
if(player.getHp() <= 0) |
|
|
if(player.getHp() <= 0) |
|
|
System.exit(0); |
|
|
System.exit(0); |
|
@ -41,6 +34,17 @@ private boolean combat = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void use(Scanner scanner, TravelEngine engine) { |
|
|
|
|
|
System.out.println("Which item would you like to use?"); |
|
|
|
|
|
String item = scanner.nextLine(); |
|
|
|
|
|
System.out.println("On who? (leave blank for self)"); |
|
|
|
|
|
String target = scanner.nextLine(); |
|
|
|
|
|
if(target.equals("")) |
|
|
|
|
|
System.out.println(getUseMessage(item, engine)); |
|
|
|
|
|
else |
|
|
|
|
|
System.out.println(getUseMessage(item + " on " + target, engine)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public String getUseMessage(String msg, TravelEngine engine) { |
|
|
public String getUseMessage(String msg, TravelEngine engine) { |
|
|
Player player = engine.getPlayer(); |
|
|
Player player = engine.getPlayer(); |
|
|
String message[] = msg.split(" on "); |
|
|
String message[] = msg.split(" on "); |
|
|