adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] inventory news


From: Thorsten Riess
Subject: [Adonthell-devel] inventory news
Date: Fri, 26 Apr 2002 01:19:46 +0200

Hi!

Finally I did some improvements on the items/inventory system. Right 
now, it looks as follows (view with fixed font):

-----------------------           ----------------------------------
| character_base      |           | inventory_base                 | <--
| ~~~~~~~~~~~~~~~~~~~ |           | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |   |
| inventory_base *inv-|---------> | map<string,item_base *> items--|-- |
|                     | <---------|-character_base * owner         | | |
|                     |           | map<item_base *,u_int16> amount| | |
-----------------------           ---------------------------------- | |
              ^                                                      | |
              |                                                      | |
              |                                                      | |
              |            ----------------------------------------- < |
              |            |    item_base                          |   |
              |            | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |   |
              |            | u_int16 abilities                     |   |
              |            | string std_type                       |   |
              |            | vector<string> types                  |   |
              -------------|-character_base * owner                |   |
                           | inventory_base * inv------------------|----
                           | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
                           | equip (character_base * c)            |
                           | combine (item_base * i)               |
                           | use ()                                |
                           | drop ()                               |
                           | pickup (character_base * c)           |
                           | enchant ()                            |
                           | sell (character_base * c, u_int16 p)  |
                           | eat ( character_base * c )            |
                           -----------------------------------------

Where an inventory_base instance is created in the character_base's 
constructor (and is deleted in the destructor).
inventory_base has also member functions for adding/removing items and 
transfering them to another inventory. I decided to handle the money as 
a special item rather than via the inventory class itself.
The item_base class consists of the following:
 - it can store (string, value) pairs since it is derived from the
   storage class
 - abilities: specifies what can be done with the item (use, eat, etc.)
 - types: is a list of types (picking up Kai's suggestion) the item
          belongs to (a torch can be a weapon and a lightsource)
          The names of the types are the names of the corresponding
          Python-files that are used for the action methods
 - action-functions: these functions call the Python file that
                     corresponds to the item's standard type

Well, this is basically an improved version of Kai's items from the 
road-to-0.4 branch, but still lacking a decent load/save routine (I am 
working on that). Tell me what you think!
Ciao, Thorsten.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]