Class OutfitChangerBehaviour


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

  • 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

      @Deprecated public OutfitChangerBehaviour(Map<String,Integer> priceList, boolean reset)
      Deprecated.
      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

      @Deprecated public OutfitChangerBehaviour(Map<String,Integer> priceList, int endurance, String wearOffMessage, boolean reset)
      Deprecated.
      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, Float priceFactor, 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.
      priceFactor - Skews prices of all items for this merchant.
      endurance - Turns that outfit will remain on player or NEVER_WEARS_OFF if outfit should be kept indefinitely.
      wearOffMessage - Message that player receives after outfit wears off, or `null` if no message.
    • 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

    • setFlag

      public void setFlag(String flag)
      Sets a flag to be used by this behaviour.
      Parameters:
      flag - New flag to be enabled.
    • unsetFlag

      public void unsetFlag(String flag)
      Unsets a flag used by this behaviour.
      Parameters:
      flag - Flag to be disabled.
    • flagIsSet

      public boolean flagIsSet(String flag)
      Checks if a flag is set.
      Returns:
      true if 'flag' found in flags list.
    • 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
    • updatePlayerTransactions

      protected void updatePlayerTransactions(Player player, String merchant, ItemParserResult res)
      Updates stored information about Player-NPC commerce transactions.
      Parameters:
      player - Player to be updated.
      merchant - Name of merchant involved in transaction.
      res - Information about the transaction.