Ejemplo n.º 1
0
 public void sleep(World w) {
   if (hasItem(Item.bed, 1)) {
     w.day = true;
     Sys.print("You have slept in your bed!");
   } else {
     Sys.print("You need a bed to sleep!");
   }
 }
Ejemplo n.º 2
0
 /** Moves the player south by decreasing the y position by 1 */
 public void moveSouth(World w) {
   if (yPos == 7) {
     Sys.print("You are at the edge of the map, you cannot move further south!");
   } else {
     yPos++;
     updatePosition(w);
     Sys.print("You have moved south");
     Sys.print("There is " + tPos.getBiome().getFeatures() + " around");
     if (!(tPos.getMob() == null)) {
       Sys.print("There are also " + tPos.getMob().getName() + " here");
     }
   }
 }
Ejemplo n.º 3
0
 /** Moves the player west by increasing the y position by 1 */
 public void moveWest(World w) {
   if (xPos == 0) {
     Sys.print("You are at the edge of the map, you cannot move further west!");
   } else {
     xPos--;
     updatePosition(w);
     Sys.print("You have moved west");
     Sys.print("There is " + tPos.getBiome().getFeatures() + " around");
     if (!(tPos.getMob() == null)) {
       Sys.print("There are also " + tPos.getMob().getName() + " here");
     }
   }
 }
Ejemplo n.º 4
0
 /**
  * Makes the player eat the specified food
  *
  * @param food - Specified food to eat
  */
 public void eat(Food food) {
   if (hasFood(food, 1)) {
     removeFood(food, 1);
     increaseHealth(food.getHealthRegenAmount());
   } else {
     Sys.print("You don't have any " + food.getName() + " to eat!");
   }
 }
Ejemplo n.º 5
0
 /**
  * Increases the player's health by the specified amount
  *
  * @param amount - Amount to increase by
  */
 public void increaseHealth(int amount) {
   int i = health + amount;
   if (i >= 20) {
     health = maxHealth;
   } else {
     health = i;
   }
   Sys.print("You have " + health + " health points remaining");
 }
Ejemplo n.º 6
0
 /**
  * Decreases the player's health by the specified amount
  *
  * @param amount - Amount to decrease by
  */
 public void decreaseHealth(int amount) {
   int i = health - amount;
   if (i <= 0) {
     health = 0;
   } else {
     health = i;
   }
   Sys.print("You have " + health + " health points remaining");
 }
Ejemplo n.º 7
0
 /**
  * Removes the amount of blocks to its stack
  *
  * @param block - Block to control
  * @param amount - Amount to decrease by
  */
 public void removeBlock(Block block, int amount) {
   block.setStack(block.getStack() - amount);
   Sys.print(amount + " " + block.getName() + " was removed from your inventory!");
 }
Ejemplo n.º 8
0
 /** Method ran when the player dies */
 public void death() {
   Sys.print("Oh no! You died! But it's okay, you can play again if you like!");
   SurvivalistText.init();
 }
Ejemplo n.º 9
0
 /**
  * Adds the amount of items to its stack
  *
  * @param item - Item to control
  * @param amount - Amount to increase by
  */
 public void addItem(Item item, int amount) {
   item.setStack(item.getStack() + amount);
   Sys.print(amount + " " + item.getName() + " was added to your inventory!");
 }
Ejemplo n.º 10
0
 /** Removes the sword owned from the player's inventory */
 public void removeSword() {
   Sys.print("You have lost your " + sword.getName() + "!");
   sword = null;
 }
Ejemplo n.º 11
0
 /**
  * Adds a specified sword to the player's inventory
  *
  * @param s - Specified sword
  */
 public void addSword(Sword s) {
   Sys.print("You have obtained a " + s.getName() + "!");
   sword = s;
 }
Ejemplo n.º 12
0
 /** Removes the shovel owned from the player's inventory */
 public void removeShovel() {
   Sys.print("You have lost your " + shovel.getName() + "!");
   shovel = null;
 }
Ejemplo n.º 13
0
 /**
  * Adds the amount of food to its stack
  *
  * @param food - Food to control
  * @param amount - Amount to increase by
  */
 public void addFood(Food food, int amount) {
   food.setStack(food.getStack() + amount);
   Sys.print(amount + " " + food.getName() + " was added to your inventory!");
 }
Ejemplo n.º 14
0
 /** Removes the pickaxe owned from the player's inventory */
 public void removePick() {
   Sys.print("You have lost your " + pickaxe.getName() + "!");
   pickaxe = null;
 }
Ejemplo n.º 15
0
 /**
  * Adds a specified pickaxe to the player's inventory
  *
  * @param p - Specified pick
  */
 public void addPick(Pickaxe p) {
   Sys.print("You have obtained a " + p.getName() + "!");
   pickaxe = p;
 }
Ejemplo n.º 16
0
 /**
  * Adds a specified hoe to the player's inventory
  *
  * @param h - Specified hoe
  */
 public void addHoe(Hoe h) {
   Sys.print("You have obtained a " + h.getName() + "!");
   hoe = h;
 }
Ejemplo n.º 17
0
 /** Removes the axe owned from the player's inventory */
 public void removeAxe() {
   Sys.print("You have lost your " + axe.getName() + "!");
   axe = null;
 }
Ejemplo n.º 18
0
 /**
  * Adds a specified axe to the player's inventory
  *
  * @param a - Specified axe
  */
 public void addAxe(Axe a) {
   Sys.print("You have obtained a " + a.getName() + "!");
   axe = a;
 }
Ejemplo n.º 19
0
 /**
  * Removes the amount of food to its stack
  *
  * @param food - Food to control
  * @param amount - Amount to decrease by
  */
 public void removeFood(Food food, int amount) {
   food.setStack(food.getStack() - amount);
   Sys.print(amount + " " + food.getName() + " was removed from your inventory!");
 }
Ejemplo n.º 20
0
 /**
  * Adds the amount of blocks to its stack
  *
  * @param block - Block to control
  * @param amount - Amount to increase by
  */
 public void addBlock(Block block, int amount) {
   block.setStack(block.getStack() + amount);
   Sys.print(amount + " " + block.getName() + " was added to your inventory!");
 }
Ejemplo n.º 21
0
 /**
  * Adds a specified shovel to the player's inventory
  *
  * @param s - Specified shovel
  */
 public void addShovel(Shovel s) {
   Sys.print("You have obtained a " + s.getName() + "!");
   shovel = s;
 }
Ejemplo n.º 22
0
 /** Removes the hoe owned from the player's inventory */
 public void removeHoe() {
   Sys.print("You have lost your " + hoe.getName() + "!");
   hoe = null;
 }
Ejemplo n.º 23
0
 /**
  * Removes the amount of items to its stack
  *
  * @param item - Item to control
  * @param amount - Amount to decrease by
  */
 public void removeItem(Item item, int amount) {
   item.setStack(item.getStack() - amount);
   Sys.print(amount + " " + item.getName() + " was removed from your inventory!");
 }