Class OutfitChangerBehaviour


public class OutfitChangerBehaviour extends MerchantBehaviour
Represents the behaviour of a NPC who is able to sell outfits to a player.
  • Field Details

    • NEVER_WEARS_OFF

      public static final int NEVER_WEARS_OFF
      See Also:
      Constant Field Values
    • resetBeforeChange

      protected boolean resetBeforeChange
      if true, return player to original outfit before setting new temp outfit
  • Constructor Details

    • OutfitChangerBehaviour

      public OutfitChangerBehaviour(Map<String,​Integer> priceList)
      Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.
      Parameters:
      priceList - list of outfit types and their prices
    • OutfitChangerBehaviour

      public OutfitChangerBehaviour(Map<String,​Integer> priceList, boolean reset)
      Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.
      Parameters:
      priceList - List of outfit types and their prices.
      reset - If true, player's original outfit will be restored before setting setting the new one.
    • OutfitChangerBehaviour

      public OutfitChangerBehaviour(Map<String,​Integer> priceList, int endurance, String wearOffMessage, boolean reset)
      Creates a new OutfitChangerBehaviour for outfits that wear off automatically after some time.
      Parameters:
      priceList - List of outfit types and their prices.
      endurance - The time (in turns) the outfit will stay, or NEVER_WEARS_OFF if the outfit should never disappear automatically.
      wearOffMessage - the message that the player should receive after the outfit has worn off, or null if no message should be sent.
      reset - If true, player's original outfit will be restored before setting setting the new one.
    • OutfitChangerBehaviour

      public OutfitChangerBehaviour(Map<String,​Integer> priceList, int endurance, String wearOffMessage)
      Creates a new OutfitChangerBehaviour for outfits that wear off automatically after some time.
      Parameters:
      priceList - list of outfit types and their prices
      endurance - the time (in turns) the outfit will stay, or NEVER_WEARS_OFF if the outfit should never disappear automatically.
      wearOffMessage - the message that the player should receive after the outfit has worn off, or null if no message should be sent.
  • Method Details

    • transactAgreedDeal

      public boolean transactAgreedDeal(ItemParserResult res, EventRaiser seller, Player player)
      Transacts the sale that has been agreed on earlier via setChosenItem() and setAmount().
      Specified by:
      transactAgreedDeal in class TransactionBehaviour
      Parameters:
      seller - The NPC who sells
      player - The player who buys
      res - result of the Behaviour parsing
      Returns:
      true iff the transaction was successful, that is when the player was able to equip the item(s).
    • putOnOutfit

      public void putOnOutfit(Player player, String outfitType)
      Tries to get back the bought/lent outfit and give the player his original outfit back. This will only be successful if the player is wearing an outfit he got here, and if the original outfit has been stored.
      Parameters:
      player - The player.
      outfitType - the outfit to wear
    • wearsOutfitFromHere

      public boolean wearsOutfitFromHere(Player player)
      Checks whether or not the given player is currently wearing an outfit that may have been bought/lent from an NPC with this behaviour.
      Parameters:
      player - The player.
      Returns:
      true iff the player wears an outfit from here.
    • returnToOriginalOutfit

      public boolean returnToOriginalOutfit(Player player)
      Tries to get back the bought/lent outfit and give the player his original outfit back. This will only be successful if the player is wearing an outfit he got here, and if the original outfit has been stored.
      Parameters:
      player - The player.
      Returns:
      true iff returning was successful.
    • onWornOff

      protected void onWornOff(Player player)
      Puts the outfit off, but only if the player hasn't taken it off himself already.
      Parameters:
      player - who wears the outfit
    • getEndurance

      public int getEndurance()
      Outfit expiry period in minutes
      Returns:
      endurance in minutes