コード例 #1
0
ファイル: Map.java プロジェクト: thyme4soup/adventure_game
 public void collect(String name) {
   switch (name) {
     case "stick":
       if (getCurrentTile().contains("tree")) {
         console.print("You break some sticks off of the tree.");
         p.inv.add(new Item("stick"), 2);
         getCurrentTile().removeEntity("tree");
         p.decFood(1);
         p.decWater(1);
       } else {
         console.print("There are no sticks in sight.");
       }
       break;
     case "rock":
       if (getCurrentTile().contains("rock")) {
         console.print("You collect a pile of rocks.");
         p.inv.add(new Item("rock"), 3);
         getCurrentTile().removeEntity("rock");
         p.decFood(2);
         p.decWater(1);
       } else {
         console.print("There are no rocks in sight.");
       }
       break;
     default:
   }
 }
コード例 #2
0
ファイル: Map.java プロジェクト: thyme4soup/adventure_game
 public void pillage() {
   getCurrentTile().removeEntity("village");
   p.maxFood += 3;
   p.maxWater += 3;
   p.maxHealth += 2;
   p.decFood(3);
   p.decWater(3);
   p.razeCount++;
 }
コード例 #3
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);
     }
   }
 }