Saturday, March 27, 2010

Craft guilds

The mudlib provides support for four types of guilds:
  1. occupational guild
  2. layman guild
  3. racial guild
  4. craft guild
This post explains the structure of a craft guild, the services provided and sample code.

In essence a craft guild allows the members to combine a set of objects in their inventory to "produce" another object of some utility to the player. For example potions and buffs.

The example in this post will create an alchemist guild and it will be based on the standard distribution. To create your own sandbox and experiment with the code in this article refer to the Getting Started with LPMud article.

Craft guild services

A craft guild provides the following services:
    1. join services: join and leave the guild
    2. train services: train the special skill of the guild, in our case alchemy
    3. start services: the user can set its start location in a room in the guild
    4. special abilities, for example mix potion or elixir; in our case the guild will mix a potion

Optional a guild could provide an emblem, a shop, a post office or other related services.

Class structure
The classes participating in the guild implementation are shwon in the figure below. The classes in the packages in red are part of the mudlib while the classes in the packages in blue are part of the alchemist guild implementation.

The class diagram is given for reference, helping in understanding the workings of the guild. Click on the image to see a larger version.




Join services
The join/leave services are provided by a game room, joinroom.c , to which 2 actions are added: alcjoin and alcleave.

The diagram below shows what happens when a player joins the craft guild. after the player issues the command, a clone of the craft_shadow class is installed as a shadow for the player if the user is allowed to join the guild. Then the guild emblem and the guild soul and the guild specific player description are added. The guild soul hosts the guild specific abilities.


Train services
The guild allows the player to train the special skills defined by the guild, in this case alchemy. The train services are provided by a game room, train.c. The room inherits the skill trainer behavior from skill_train mudlib component.

Start services
[TODO]

Special abilities
The special ability provided by the alchemist guild is to carve a mortar which knows how to mix a potion. One could argue that the ability itself might be mix potion. In this case, the mortar class is already defined on Genesis and it is a good opportunity to reuse the code.

No comments:

Post a Comment