Example #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!");
   }
 }
Example #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");
     }
   }
 }
Example #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");
     }
   }
 }
Example #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!");
   }
 }
Example #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");
 }
Example #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");
 }
Example #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!");
 }
Example #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();
 }
Example #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!");
 }
Example #10
0
 /** Removes the sword owned from the player's inventory */
 public void removeSword() {
   Sys.print("You have lost your " + sword.getName() + "!");
   sword = null;
 }
Example #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;
 }
Example #12
0
 /** Removes the shovel owned from the player's inventory */
 public void removeShovel() {
   Sys.print("You have lost your " + shovel.getName() + "!");
   shovel = null;
 }
Example #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!");
 }
Example #14
0
 /** Removes the pickaxe owned from the player's inventory */
 public void removePick() {
   Sys.print("You have lost your " + pickaxe.getName() + "!");
   pickaxe = null;
 }
Example #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;
 }
Example #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;
 }
Example #17
0
 /** Removes the axe owned from the player's inventory */
 public void removeAxe() {
   Sys.print("You have lost your " + axe.getName() + "!");
   axe = null;
 }
Example #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;
 }
Example #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!");
 }
Example #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!");
 }
Example #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;
 }
Example #22
0
 /** Removes the hoe owned from the player's inventory */
 public void removeHoe() {
   Sys.print("You have lost your " + hoe.getName() + "!");
   hoe = null;
 }
Example #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!");
 }