Class BuyCommand
Object
NormalCommand
BuyCommand
- All Implemented Interfaces:
Command
Buys an item from a shopkeeper. Syntax : buy [<amount>] <item>
from <character>. For example "buy bucket to Karcas".
- Author:
- maartenl
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTries out the buy command.Methods inherited from class NormalCommand
getAdminService, getChatService, getEventsService, getGuildService, getHelpService, getItemService, getLogService, getPersonService, getRegExpr, parseCommand, parseCommand, setCallback
-
Constructor Details
-
BuyCommand
-
-
Method Details
-
run
Tries out the buy command. There are a couple of requirements that need to be met, before a successful sale takes place.- command struct. should be "buy [<amount>] <item> from <character>", for example: "sell gold ring to Karcas".
- shopkeeper selling the item should
- exist,
- be in the same room and
- have a god==4 to indicate a "shopkeeper" and
- has the item for sale
- the customer should have the money
- the item itself should NOT have a attribute called "notbuyable".
- the item should not contain any items
- the item is transferred into the inventory of the user
- money is transferred into the inventory of the shopkeeper
- continue with next item
- Specified by:
run
in interfaceCommand
- Specified by:
run
in classNormalCommand
- Parameters:
command
- the command entered.aUser
- the character doing the buying.- Returns:
- a simple displayinterface, in our case the room.
- Throws:
MudException
- if something goes wrong.
-