Package horizons :: Package world :: Package disaster :: Class Disaster
[hide private]
[frames] | no frames]

Class Disaster

source code

util.changelistener.ChangeListener --+    
                                     |    
          util.worldobject.WorldObject --+
                                         |
                                        Disaster

Prototype class for disasters.

Instance Methods [hide private]
 
__init__(self, settlement, manager) source code
 
save(self, db) source code
 
load(self, db, worldid) source code
 
evaluate(self)
Called to evaluate if this disaster is still active
source code
 
expand(self)
Called to make the disaster expand further
source code
 
infect(self, building, load)
Used to expand disaster to this building.
source code
 
recover(self, building)
Inverse of infect().
source code
 
breakout(self)
Picks (a) object(s) to start a breakout.
source code
 
wreak_havoc(self, building)
The implementation to whatever the disaster does to affected objects goes here
source code
 
end(self)
End this class, used for cleanup.
source code
    Inherited from util.worldobject.WorldObject
 
__lt__(self, other) source code
 
remove(self) source code
    Inherited from util.changelistener.ChangeListener
 
_changed(self)
Calls every listener when an object changed
source code
 
add_change_listener(self, listener, call_listener_now=False, no_duplicates=False) source code
 
add_remove_listener(self, listener, no_duplicates=False)
A listener that listens for removal of the object
source code
 
clear_change_listeners(self)
Removes all change listeners
source code
 
discard_change_listener(self, listener)
Remove listener if it's there
source code
 
discard_remove_listener(self, listener) source code
 
has_change_listener(self, listener) source code
 
has_remove_listener(self, listener) source code
 
remove_change_listener(self, listener) source code
 
remove_remove_listener(self, listener) source code
Class Methods [hide private]
 
can_breakout(cls, settlement)
Returns whether or not a disaster can break out in the settlement
source code
    Inherited from util.worldobject.WorldObject
 
get_object_by_id(cls, id)
Returns the worldobject with id id Throws WorldObjectNotFound with the worldid as arg.
source code
 
get_objs(cls) source code
 
reset(cls) source code
Class Variables [hide private]
  log = logging.getLogger("world.disaster")
  TYPE = None
hash(x)
  SEED_CHANCE = 0.5
  EXPANSION_TIME = GAME_SPEED.TICKS_PER_SECOND* 5
  DISASTER_RES = None
hash(x)
Method Details [hide private]

__init__(self, settlement, manager)
(Constructor)

source code 
Parameters:
  • settlement - Settlement instance this disaster operates on
  • manager - The disaster manager that initiated this disaster
Overrides: util.changelistener.ChangeListener.__init__

save(self, db)

source code 
Overrides: util.worldobject.WorldObject.save

load(self, db, worldid)

source code 
Overrides: util.changelistener.ChangeListener.load

infect(self, building, load)

source code 

Used to expand disaster to this building. Usually called by expand and breakout

recover(self, building)

source code 

Inverse of infect(). Is also called when buildings are torn down by the user.

end(self)

source code 

End this class, used for cleanup. Called by the DisasterManager in end_disaster() automatically

Overrides: util.changelistener.ChangeListener.end