bleeding and bandages

This commit is contained in:
jslightham
2019-05-31 23:15:01 -04:00
parent ff32ca6ab5
commit 1232f150c9
7 changed files with 80 additions and 10 deletions

View File

@@ -245,12 +245,28 @@ class Game {
System.out.println(
"Poof! You looked pretty banged up there, so I brought you back to the circle room. Your items are where you died.");
player.setHealth(100.0);
player.setBleeding(false);
try {
currentCombat.getEnemy().setHealth(100.0);
currentCombat = null;
}catch (Exception e) {
}
}
}
}
if(player.getBleeding()) {
player.setHealth(player.getHealth()-2);
System.out.println("You are bleeding. Find, and use bandages to stop bleeding.");
System.out.println("Your health is now " + player.getHealth() + "%");
}
if(player.getHealth() <= 0) {
currentRoom = masterRoomMap.get("CIRCLE_ROOM");
System.out.println(
"Poof! You looked pretty banged up there, so I brought you back to the circle room. Your items are where you died.");
player.setHealth(100.0);
player.setBleeding(false);
}
Command command = parser.getCommand();
finished = processCommand(command);
}
@@ -589,6 +605,8 @@ class Game {
} else {
System.out.println("You do not have that weapon!");
}
}else {
System.out.println("Attack with what?");
}
}
break;
@@ -637,6 +655,36 @@ class Game {
System.out.println("Craft what?");
}
break;
case "use":
if(command.hasItem()) {
Class<?> clazz;
Item object;
try {
clazz = Class.forName(
"com.bayviewglen.zork.Items." + command.getItem().substring(0, 1).toUpperCase().trim()
+ command.getItem().substring(1).trim());
Constructor<?> ctor = clazz.getConstructor();
object = (Item) ctor.newInstance();
if(!object.equals(new Bandage()))
throw new Exception();
boolean hasBandage = false;
for(Item i : player.getInventory()) {
if(i.equals(new Bandage())) {
hasBandage = true;
}
}
if(hasBandage) {
System.out.println("You are no longer bleeding.");
player.setBleeding(false);
}else {
System.out.println("You do not have a bandage!");
}
}catch (Exception e) {
System.out.println("You cannot use that item!");
}
}else {
System.out.println("Use what?");
}
default:
return false;
}