예제 #1
0
 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
 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
 /*
  * 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);
     }
   }
 }