In the Python version of The Land of Gack, there is no explicit NamedObject class. However, the classes Person, Place, and Thing are all still kinds of named objects, in that they all have the name attribute.
The classes fall into this inheritence hierarchy:
Person
AutoPerson
WitchWizardPlaceThing
ScrollRegistryThe following sections describe the attributes and methods of each class. Keep in mind that when a method is called, the self argument is normally not explicit. For example, consider the Person class's say method, which is documented as having the form say(self, text). This is the form you will find where the method is defined. But in the ordinary case where you want some person, p, to say something, you would use p.say(text). Only if you want to ignore what particular kind of person p is (such as that he is a Wizard) and have him say the text the normal-person way, you would use Person.say(p, text).
Each instance of the Person class or any of its subclasses has the following attributes:
name, a stringplace, a Place objectpossessions, a list of Thing objectsThe Person class also defines the following methods:
say(self, text)lookAround(self)listPossessions(self)read(self, scroll)haveFit(self)moveTo(self, newPlace)go(self, direction)take(self, thing)lose(self, thing)greet(self, people)otherPeopleAtSamePlace(self), which returns a list of Person objectsBeyond the inherited attributes, each instance of AutoPerson or any of its subclasses has the following attributes:
threshold, an integerrestlessness, an integerAlso, the AutoPerson class itself has a class attribute, AutoPerson.registry, which is the instance of the Registry class that holds all the AutoPerson instances that have not been removed from action.
The AutoPerson class also defines the following methods, beyond those that are inherited:
maybeAct(self)act(self)Beyond the inherited attributes, each instance of the Witch class has the following attribute:
pond, a Place objectThe Witch class defines the following methods, beyond those that are inherited:
curse(self, person)turnIntoFrog(self, person)Additionally, the Witch class provides an overriding definition for the act method.
Beyond the inherited attributes, each instance of the Wizard class has the following attribute:
chamber, a Place objectInstances of the Wizard class have only the inherited method names; however, this class provides an overriding definition for the act method.
Each instance of the Place class has the following attributes:
name, a stringneighborMap, a dictionary with strings (direction names) as keys and Place objects as valuescontents, a list of Person and Thing objectsThe Person class also defines the following methods:
exits(self), which returns a list of stringsneighbors(self), which returns a list of Place objectsneighborTowards(self, direction), which returns a Place objectaddNewNeighbor(self, direction, newNeighbor)gain(self, newItem)lose(self, item)Each instance of the Thing class or any subclass has the following attributes:
name, a stringowner, a Person objectThe Thing class does not define any methods.
The Scroll class does not add any atributes beyond those that are inherited. It adds one method:
beRead(self)Each instance of the Registry class has the following attribute:
list, a list of AutoPerson objectsThe Registry class also defines the following methods:
add(self, person)remove(self, person)trigger(self)triggerTimes(self, n)