Class OutfitChangerBehaviour
java.lang.Object
games.stendhal.common.grammar.ItemParser
games.stendhal.server.entity.npc.behaviour.impl.Behaviour
games.stendhal.server.entity.npc.behaviour.impl.TransactionBehaviour
games.stendhal.server.entity.npc.behaviour.impl.MerchantBehaviour
games.stendhal.server.entity.npc.behaviour.impl.OutfitChangerBehaviour
Represents the behaviour of a NPC who is able to sell outfits to a player.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
removes the special outfit after it outwore. -
Field Summary
Modifier and TypeFieldDescriptionstatic int
protected boolean
iftrue
, return player to original outfit before setting new temp outfitFields inherited from class games.stendhal.server.entity.npc.behaviour.impl.MerchantBehaviour
priceCalculator
Fields inherited from class games.stendhal.common.grammar.ItemParser
itemNames
-
Constructor Summary
ConstructorDescriptionOutfitChangerBehaviour(Map<String,Integer> priceList)
Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.OutfitChangerBehaviour(Map<String,Integer> priceList, boolean reset)
Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.OutfitChangerBehaviour(Map<String,Integer> priceList, int endurance, String wearOffMessage)
Creates a new OutfitChangerBehaviour for outfits that wear off automatically after some time.OutfitChangerBehaviour(Map<String,Integer> priceList, int endurance, String wearOffMessage, boolean reset)
Creates a new OutfitChangerBehaviour for outfits that wear off automatically after some time. -
Method Summary
Modifier and TypeMethodDescriptionint
Outfit expiry period in minutesprotected void
Puts the outfit off, but only if the player hasn't taken it off himself already.void
putOnOutfit(Player player, String outfitType)
Tries to get back the bought/lent outfit and give the player his original outfit back.boolean
returnToOriginalOutfit(Player player)
Tries to get back the bought/lent outfit and give the player his original outfit back.boolean
transactAgreedDeal(ItemParserResult res, EventRaiser seller, Player player)
Transacts the sale that has been agreed on earlier via setChosenItem() and setAmount().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.Methods inherited from class games.stendhal.server.entity.npc.behaviour.impl.MerchantBehaviour
dealtItems, getCharge, getUnitPrice, hasItem
Methods inherited from class games.stendhal.server.entity.npc.behaviour.impl.Behaviour
getRejectedTransactionAction, getTransactionCondition
Methods inherited from class games.stendhal.common.grammar.ItemParser
getErrormessage, getItemNames, parse
-
Field Details
-
NEVER_WEARS_OFF
public static final int NEVER_WEARS_OFF- See Also:
- Constant Field Values
-
resetBeforeChange
protected boolean resetBeforeChangeiftrue
, return player to original outfit before setting new temp outfit
-
-
Constructor Details
-
OutfitChangerBehaviour
Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.- Parameters:
priceList
- list of outfit types and their prices
-
OutfitChangerBehaviour
Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.- Parameters:
priceList
- List of outfit types and their prices.reset
- Iftrue
, 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
- Iftrue
, 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 pricesendurance
- 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
Transacts the sale that has been agreed on earlier via setChosenItem() and setAmount().- Specified by:
transactAgreedDeal
in classTransactionBehaviour
- Parameters:
seller
- The NPC who sellsplayer
- The player who buysres
- 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
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
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
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
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
-