コード例 #1
0
ファイル: Map.java プロジェクト: thyme4soup/adventure_game
 /*
  * THIS METHOD IS FOR USE WITH THE INTERACTION CLASS.
  * USE ITEM FROM THE PLAYER'S INVENTORY ON ENVIRONMENT.
  */
 public void use(String itemName) {
   Item item = new Item(itemName);
   if (!p.inv.contains(item.name)) console.print("You don't have a " + itemName + ".");
   else {
     Interaction in = Interaction.getInteraction(item, getCurrentTile().entities);
     if (in == null) console.print("Nothing to use the " + item.name + " with.");
     else {
       Interaction.interact(in, getCurrentTile(), p.inv);
       console.print(in.msg);
       p.decFood(1);
       p.decWater(1);
     }
   }
 }