The Incomplete Works of Josh English

Writings and Ramblings about almost anything...

Overview

There are five basic classes in the PBMShell:

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:

life500
How many times can it be used when generated
maxlife1000
How many times can it be used at all. Items can be recharged or restored, depending on how you look at it
wear0
Boolean value, does it wear out. By default this is 0 and the life amd maxlife values don’t matter.
unique0
Boolean value. If 0 then the item is a general type that can be owned by any individual, group, node, player, or game. The attachedto attribute is not used. If 1 then the item is unique, and attachedto is used. Only one Individual,Group,Node, or Player can own it.
classitem
This is usually treated as the .__class__ name. It is used internally by the game manager to make sure items get created properly. Don’t define this ofr your items, the Item class takes care of this one automatically.

Making 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.