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