Overview
There are five basic classes in the PBMShell:
- Item
- Individual
- Group
- Player
- Game
There are subclasses to the Item, Individual, and Group classes. The PBMShell package declares a few of these already, and the sample game, Swarming with Dwarfs, has more examples of how to subclass these and add flavor the game. There is also an attributes class that is called by itemsand individuals.
This is horribly out of date
Items
The Item class is used for objects in a game, whatever gets used or collected is an Item. There are standard subclasses for items that you should use. The Item class works like a dictionary object and you can refer to an Items attributes as you would a dictionary:
>>>from pbmitem import * >>>myThing=Item() >>>print myThing['life'] 500
All Item objects get the following key, value pairs by default:
life500Making a special weapon
Whether it’s a magic sword or a Definit-Kil Cannon, you can create special weapons and defenses by subclassing Offense and Treasure items:
class MagicWeapon(Offense,Treasure):
mwdata = {
'name':'Magic Weapon',
'class':'magweapon',
'code':'mw000'
}
def __init__(self,d={}):
self.data.update(self.mwdata)
Offense.__init__(self,d)
Treasure.__init__(self,d)
sword = MagicWeapon({'name':'Obsidian Prick','code':'obprick','effect':'fst'})
Of course you can also make a unique weapon just by adding the key, value pair ‹unique’:1 to the items dictionary, you will also need to add a unique code and an effect code.