Class SellCommand

Object
NormalCommand
SellCommand
All Implemented Interfaces:
Command

public class SellCommand extends NormalCommand
Sells an item to a shopkeeper. Syntax : sell [<amount>] <item> to <character>. For example "sell bucket to Karcas".
Author:
maartenl
See Also:
  • Constructor Details

    • SellCommand

      public SellCommand(String aRegExpr)
  • Method Details

    • run

      public DisplayInterface run(String command, User aUser) throws MudException
      Tries out the sell command. There are a couple of requirements that need to be met, before a successful sale takes place.
      1. command struct. should be "sell [<amount>] <item> to <character>", for example: "sell gold ring to Karcas".
      2. keeper buying the item should
        1. exist,
        2. be in the same room and
        3. have a god==4 to indicate a "keeper" and
        4. has enough money
      3. the customer should have the item
      4. the item is not being wielded
      5. the item is not being worn
      6. the item itself should NOT have a attribute called "notsellable".
      7. the item should not contain any items
      A best effort is tried, this means the following sequence of events:
      1. the item is transferred into the inventory of the keeper
      2. money is transferred into the inventory of the customer
      3. continue with next item
      Specified by:
      run in interface Command
      Specified by:
      run in class NormalCommand
      Parameters:
      command - the command entered.
      aUser - the character doing the selling.
      Returns:
      a simple displayinterface, in our case the room.
      Throws:
      MudException - if something goes wrong.