enemy drop loot on death
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Enemy Name: Henry Pellatt
|
||||
Description: The owner of the Castle
|
||||
Starting Room: Circle Room
|
||||
Damage Given: 25
|
||||
Damage Given: 25
|
||||
Loot: Crowbar
|
||||
@@ -2,7 +2,7 @@ Room name: Circle Room
|
||||
Room Description: You are in a circular room. The windows to the east are covered with boards that<br>let in just enough light to see. You spot a man in a tailored suit moving some crates around.
|
||||
Locked: false
|
||||
Boarded: false
|
||||
Items: Lightbulb,Candlestick
|
||||
Items: Lightbulb,Candlestick,Sword
|
||||
Riddler: "Hello there. My name is Kevin and I am Sir Pellatt's butler. I understand that my master<comma><br>Sir Pellatt has wrongfully imprisoned you. If you answer my riddle<comma> I can give you something to<br>help you with your escape - nothing comes for free you know!", "What goes moo?", "Cows", Lockpick
|
||||
Exit Rooms: W-Apple Hallway
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ public class Enemy extends Entity{
|
||||
private String name;
|
||||
private String description;
|
||||
private String room;
|
||||
private String loot;
|
||||
private boolean blinded;
|
||||
|
||||
public Enemy(){
|
||||
@@ -54,4 +55,10 @@ public class Enemy extends Entity{
|
||||
public void setBlinded(boolean blinded) {
|
||||
this.blinded = blinded;
|
||||
}
|
||||
public void setLoot(String loot) {
|
||||
this.loot = loot;
|
||||
}
|
||||
public String getLoot() {
|
||||
return loot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,9 @@ class Game {
|
||||
// Read the Damage Given
|
||||
int damageGiven = Integer.parseInt(enemyScanner.nextLine().split(":")[1].trim());
|
||||
e.setDamageGiven(damageGiven);
|
||||
// Read the Loot
|
||||
String loot = enemyScanner.nextLine().split(":")[1].trim();
|
||||
e.setLoot(loot);
|
||||
}
|
||||
}catch(Exception ex) {
|
||||
}
|
||||
@@ -224,7 +227,18 @@ class Game {
|
||||
while (!finished) {
|
||||
if(currentCombat != null) {
|
||||
if(currentCombat.getEnemy().getHealth() <= 0.0) {
|
||||
System.out.println("You destroyed " + currentCombat.getEnemy().getName());
|
||||
System.out.print("You destroyed " + currentCombat.getEnemy().getName() + "! ");
|
||||
System.out.println(currentCombat.getEnemy().getName() + " seems to have dropped a " + currentCombat.getEnemy().getLoot());
|
||||
Class<?> clazz;
|
||||
Item object = null;
|
||||
try {
|
||||
clazz = Class.forName("com.bayviewglen.zork.Items." + currentCombat.getEnemy().getLoot().substring(0, 1).toUpperCase().trim() + currentCombat.getEnemy().getLoot().substring(1).trim());
|
||||
Constructor<?> ctor = clazz.getConstructor();
|
||||
object = (Item) ctor.newInstance();
|
||||
}catch (Exception e) {
|
||||
|
||||
}
|
||||
currentRoom.addItem(object);
|
||||
masterEnemyMap.values().remove(currentRoom.getRoomName());
|
||||
currentCombat = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user