Table of Contents

Class: Living mudlib/living.py

Skeleton Living. A living in the mud is any object that has a heartbeat and various other statistics which cause the object to interact with the player characters.

Base Classes   
core.Container
Methods   
addUnitsOfWork
createContainer
createLiving
destroyContainer
destroyLiving
die
getAdjectiveDescription
getBodyParts
getGender
getLongDescription
getPluralShortDescription
getRaceName
getShortDescription
getStat
getStats
getUnitsOfWork
getUnitsOfWorkForStat
heartbeat
isDead
setBodyParts
setGender
setRace
setStat
setStats
  addUnitsOfWork 
addUnitsOfWork (
        self,
        stat,
        work,
        )

Add units of work to a particular stat of this interactive.

A unit of work indicates that the stat was used to perform an action. During stat recalculation, the units of work performed over a period of time are compared to the required amount for the stat value, and then the stat is adjusted up or down (or not at all) as appropriate.

The stat parameter should be a constant stat from the constants module.

arguments:

stat
(string) see mudlib.stats for constants
work
(int) the amount of work that was done
  createContainer 
createContainer ( self )

Overrides createContainer from Container class.

  createLiving 
createLiving ( self )

This should be overridden by subclasses of Living.

  destroyContainer 
destroyContainer ( self )

see mudlib.core.Container

  destroyLiving 
destroyLiving ( self )

Override this to handle destruction of subclasses of Living.

  die 
die ( self )

Performs the things necessary when this thing dies.

Essentially it replaces the Living with a corpse object. In the case of players, it moves the player back to the start room.

Once a Living dies, there's no coming back....

  getAdjectiveDescription 
getAdjectiveDescription ( self )

Returns a string describing this Living using the adjectives involved and the race.

returns:

(string)

  getBodyParts 
getBodyParts ( self )

Returns a list of the bodyparts this living has.

returns:

(list of strings) see mudlib.constants for body part constants

  getGender 
getGender ( self )

Returns the gender of this Living.

returns:

(int) the gender--see mudlib.constants for constants

  getLongDescription 
getLongDescription ( self )

Returns the long description of this thing.

Note that even though Living is derived from mudlib.core.Container, getLongDescription only shows the long description--not the inventory of what's inside.

returns:

(string) evaluated long description

  getPluralShortDescription 
getPluralShortDescription ( self )

Returns a plural short description of this thing--in the case of a group of dwarves for instance.

returns:

(string) evaluated plural short description

  getRaceName 
getRaceName ( self )

Returns the race name of this Living.

returns:

(string)

  getShortDescription 
getShortDescription ( self )

Returns the short description of this thing.

returns:

(string) evaluated short description

  getStat 
getStat ( self,  stat )

Retrieve the value of a particular stat of this interactive.

The given stat should be one of the constant stats from the mudlib.stats module.

arguments:

stat
(string) see mudlib.stats for constants

returns:

(int) the value for that stat

  getStats 
getStats ( self )

Retrieve the map of this interactive's stats.

returns:

(hash) new stats hashmap

  getUnitsOfWork 
getUnitsOfWork ( self )

Get the mapping of stats to units of work.

A unit of work indicates that the stat was used to perform an action. During stat recalculation, the units of work performed over a period of time are compared to the required amount for the stat value, and then the stat is adjusted up or down (or not at all) as appropriate.

returns:

(hash) the units of work hash

  getUnitsOfWorkForStat 
getUnitsOfWorkForStat ( self,  stat )

Get the units of work for a particular stat.

A unit of work indicates that the stat was used to perform an action. During stat recalculation, the units of work performed over a period of time are compared to the required amount for the stat value, and then the stat is adjusted up or down (or not at all) as appropriate.

The stat parameter should be a constant stat from the constants module.

arguments:

stat
(string) see mudlib.stats for constants
  heartbeat 
heartbeat ( self )

Override this if this living has a heartbeat that has to kick off every 2 seconds.

  isDead 
isDead ( self )

Returns whether this Living is dead or not.

returns:

(int) 1 if dead, 0 if not

  setBodyParts 
setBodyParts ( self,  bodyParts )

Sets the list of the bodyparts this living has.

arguments:

bodyParts
(list of strings) the list of body parts this Living has (see mudlib.constants for body part constants)
  setGender 
setGender ( self,  gender )

Sets the gender of this Living.

arguments:

gender
(int) the gender--see mudlib.constants for constants
  setRace 
setRace ( self,  raceName )

Sets the race of this Living.

TODO: Make this handled by an aliased (world-supplied) factory

arguments:

raceName
(string) the name of the race
  setStat 
setStat (
        self,
        stat,
        newValue,
        )

Sets a particular stat of this interactive.

The given stat should be one of the constant stats from the mudlib.constants module. The new stat value must be between STAT_MIN and STAT_MAX. If it is less than STAT_MIN, then it will be set to STAT_MIN. If it is greater than STAT_MAX, it will be set to STAT_MAX. Both constants can be found in the mudlib.stats module.

arguments:

stat
(string) see mudlib.stats for constants
newValue
(int) the new value for this stat
  setStats 
setStats ( self,  statmap )

Sets this interactives stats to the given map.

Note that the value of each stat must be between STAT_MIN and STAT_MAX, inclusive. If any value is less than STAT_MIN, then it will be set to STAT_MIN. Likewise, if any value is greater than STAT_MAX, then it will be set to STAT_MAX. Both constants can be found in the mudlib.stats module.

arguments:

statmap
(hash) keys are constants and values are ints. consult the mudlib.stats module for more information.

Table of Contents

This document was automatically generated on Thu Jan 24 08:57:43 2002 by HappyDoc version 2.0