Class BuyerBehaviour
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.BuyerBehaviour
- Direct Known Subclasses:
QuestCompletedBuyerBehaviour
Represents the behaviour of a NPC who is able to buy items from a player.
-
Field Summary
Fields inherited from class games.stendhal.server.entity.npc.behaviour.impl.MerchantBehaviour
priceCalculatorFields inherited from class games.stendhal.common.grammar.ItemParser
itemNames -
Constructor Summary
ConstructorsConstructorDescriptionBuyerBehaviour(Map<String, Integer> priceList) Creates a new BuyerBehaviour with price list.BuyerBehaviour(Map<String, Integer> priceList, Float priceFactor) Creates a new BuyerBehaviour with price list & price factor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidpayPlayer(ItemParserResult res, Player player) Gives the money for the deal to the player.booleantransactAgreedDeal(ItemParserResult res, EventRaiser seller, Player player) Transacts the deal that is described in BehaviourResult.protected voidupdatePlayerTransactions(Player player, String merchant, ItemParserResult res) Updates stored information about Player-NPC commerce transactions.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
-
Constructor Details
-
BuyerBehaviour
Creates a new BuyerBehaviour with price list.- Parameters:
priceList- List of item names and their prices.
-
BuyerBehaviour
Creates a new BuyerBehaviour with price list & price factor.- Parameters:
priceList- List of item names and their prices.priceFactor- Skews prices of all items for this merchant.
-
-
Method Details
-
payPlayer
Gives the money for the deal to the player. If the player can't carry the money, puts it on the ground.- Parameters:
res-player- The player who sells
-
transactAgreedDeal
Transacts the deal that is described in BehaviourResult.- Specified by:
transactAgreedDealin classTransactionBehaviour- Parameters:
seller- The NPC who buysplayer- The player who sellsres- result of the Behaviour parsing- Returns:
- true iff the transaction was successful, that is when the player has the item(s).
-
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.
-