Ejemplo n.º 1
0
 public void useItem(String itemName) {
   boolean itemInInventory = isInInventory(itemName);
   boolean itemInRoom = GameMap.getCurrentRoom().itemExistsInRoom(itemName);
   if (!itemInInventory && itemInRoom) {
     Item takenFromRoom = GameMap.getCurrentRoom().takeItemFromRoom(itemName);
     GameGUI.player.addToInventory(takenFromRoom);
     itemInInventory = true;
   }
   if (itemInInventory) {
     Item item = ItemLibrary.get(itemName);
     if (item instanceof Weapon) {
       equipItem(item);
     } else if (item instanceof ConsumableHealth) {
       GameGUI.addToConsole("Consuming " + item.getName() + "...");
       GameMap.getCurrentRoom().combat.healPlayerWith(item);
       GameGUI.updateGUI();
     } else if (item instanceof KeyItem) {
       GameLog.warning("THIS IS A KEY ITEM!");
     } else {
       GameLog.severe("MAJOR ISSUES!");
     }
   } else {
     GameGUI.addToConsole("I'm not sure how I would use that...");
   }
 }
Ejemplo n.º 2
0
 public void discardItem(String itemName) {
   discardItem(ItemLibrary.get(itemName));
 }
Ejemplo n.º 3
0
 public boolean isInInventory(String itemName) {
   return isInInventory(ItemLibrary.get(itemName));
 }
Ejemplo n.º 4
0
 public static boolean isItem(String itemName) {
   if (ItemLibrary.get(itemName) instanceof Item) return true;
   return false;
 }