Exemplo 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...");
   }
 }
Exemplo n.º 2
0
 public static void restart() {
   GameLog.info("Restarting game");
   start(GameGUI.filePath);
 }