Class MerchantBehaviour
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
- Direct Known Subclasses:
BuyerBehaviour
,OutfitChangerBehaviour
,SellerBehaviour
Represents the behaviour of a NPC who is able to either sell items to a
player, or buy items from a player.
-
Field Summary
Fields inherited from class games.stendhal.common.grammar.ItemParser
itemNames
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns a set of the names of all items that the NPC deals with.int
getCharge(ItemParserResult res, Player player)
Returns the price of the desired amount of the chosen item.int
getUnitPrice(String item)
Returns the price of one unit of a given item.boolean
Checks whether the NPC deals with the specified item.Methods inherited from class games.stendhal.server.entity.npc.behaviour.impl.TransactionBehaviour
transactAgreedDeal
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
-
priceCalculator
-
-
Constructor Details
-
MerchantBehaviour
public MerchantBehaviour() -
MerchantBehaviour
-
-
Method Details
-
dealtItems
Returns a set of the names of all items that the NPC deals with.- Returns:
- the dealt items
-
hasItem
Checks whether the NPC deals with the specified item.- Parameters:
item
- the name of the item- Returns:
- true iff the NPC deals with the item
-
getUnitPrice
Returns the price of one unit of a given item.- Parameters:
item
- the name of the item- Returns:
- the unit price
-
getCharge
Returns the price of the desired amount of the chosen item.- Parameters:
res
-player
- The player who considers buying/selling- Returns:
- The price; 0 if no item was chosen or if the amount is 0.
-