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
Nested ClassesModifier and TypeClassDescriptionstatic classremoves the special outfit after it outwore. -
Field Summary
FieldsFields inherited from class games.stendhal.server.entity.npc.behaviour.impl.MerchantBehaviour
priceCalculatorFields inherited from class games.stendhal.common.grammar.ItemParser
itemNames -
Constructor Summary
ConstructorsConstructorDescriptionOutfitChangerBehaviour(Map<String, Integer> priceList) Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.OutfitChangerBehaviour(Map<String, Integer> priceList, boolean reset) Deprecated.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) Deprecated.OutfitChangerBehaviour(Map<String, Integer> priceList, Float priceFactor, int endurance, String wearOffMessage) Creates a new OutfitChangerBehaviour for outfits that wear off automatically after some time. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if a flag is set.intOutfit expiry period in minutesprotected voidPuts the outfit off, but only if the player hasn't taken it off himself already.voidputOnOutfit(Player player, String outfitType) Tries to get back the bought/lent outfit and give the player his original outfit back.booleanreturnToOriginalOutfit(Player player) Tries to get back the bought/lent outfit and give the player his original outfit back.voidSets a flag to be used by this behaviour.booleantransactAgreedDeal(ItemParserResult res, EventRaiser seller, Player player) Transacts the sale that has been agreed on earlier via setChosenItem() and setAmount().voidUnsets a flag used by this behaviour.protected voidupdatePlayerTransactions(Player player, String merchant, ItemParserResult res) Updates stored information about Player-NPC commerce transactions.booleanwearsOutfitFromHere(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
addConditions, dealtItems, getCharge, getItemNames, getUnitPrice, hasItemMethods inherited from class games.stendhal.server.entity.npc.behaviour.impl.Behaviour
getRejectedTransactionAction, getTransactionConditionMethods inherited from class games.stendhal.common.grammar.ItemParser
getErrormessage, parse
-
Field Details
-
NEVER_WEARS_OFF
public static final int NEVER_WEARS_OFF- See Also:
-
-
Constructor Details
-
OutfitChangerBehaviour
Creates a new OutfitChangerBehaviour for outfits that never wear off automatically.- Parameters:
priceList- list of outfit types and their prices
-
OutfitChangerBehaviour
Deprecated.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
@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- Iftrue, 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
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
-
setFlag
Sets a flag to be used by this behaviour.- Parameters:
flag- New flag to be enabled.
-
unsetFlag
Unsets a flag used by this behaviour.- Parameters:
flag- Flag to be disabled.
-
flagIsSet
Checks if a flag is set.- Returns:
trueif 'flag' found in flags list.
-
transactAgreedDeal
Transacts the sale that has been agreed on earlier via setChosenItem() and setAmount().- Specified by:
transactAgreedDealin 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
-
updatePlayerTransactions
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.
-