Test Case 0

Player Buys Sword From Shopkeeper

This test case outlines the internal plumbing that needs to occur in order to support a player purchasing a sword from a shopkeeper. This is the simplest test that the MUD engine is actually working. This test also needs to function in a multi-player environment. In other words, the sequence of this test case (outlined below) needs to function properly whether or not there are other players in the room attempting to purchase items from the shop keeper.
  1. In the GUI, the player types 'buy sword' and hits the submit button
    1. This causes a new message to be entered in the queue, containing the text 'buy sword' and the player who typed it
  2. In the worker role, the engine creates a PlayerCommand object. It has a source indicating the player who typed it. The verb is set to 'buy' and the args is a 1-item array containing the string sword.
  3. The engine builds a potential target list for this command, using the following logic:
    1. Directly attached command parsers on the player (e.g. mortal commands, wizard commands, etc.
    2. Objects contained inside the player (inventory)
    3. Objects inside the same container as the player (e.g. everybody in the same room)
    4. The container in which the player resides (e.g. the room in which the player is standing)
  4. All objects in the potential target list are given a chance to respond to the command
  5. When the shopkeeper is given a chance to respond, he:
    1. takes the array of args and looks for any items being sold that match the search string sword.
    2. if one and only one item match the search string, the transaction occurs
      1. Shopkeeper calls engine.GetInstance(player canonical name/GUID) to get live instance of player
      2. Shopkeeper calls money deduction method to get money from player
      3. Shopkeeper calls sword.Move(player);
      4. sword.Move(...) triggers the EnteredInventory method of the player
      5. move method returns a bool indicating whether the move was successful (gives target location a chance to reject the move)
  6. shop keeper puts a new message on the player message queue with a call to Say("Thanks"); . This eventually results in a text message on the player's output window showing The shopkeeper says, "Thanks" .

Last edited Sep 5, 2009 at 11:30 PM by DotNetAddict, version 3


No comments yet.