Package horizons :: Package component :: Module healthcomponent :: Class HealthComponent
[hide private]
[frames] | no frames]

Class HealthComponent

source code

Component --+
            |
           HealthComponent

Class that handles the health component

Instance Methods [hide private]
 
__init__(self, maxhealth)
Used for initialization code that does not require any other components.
source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
_add_listeners(self) source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
deal_damage(self, weapon_id, damage) source code
 
check_if_alive(self, caller=None) source code
 
redraw_health(self, caller=None) source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
remove(self)
Removes component and reference to instance
source code
Class Methods [hide private]
    Inherited from Component
 
get_instance(cls, arguments=None)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  log = logging.getLogger("component.health")
  NAME = 'health'
hash(x)
    Inherited from Component
  DEPENDENCIES = []
Properties [hide private]
    Inherited from Component
  session
Method Details [hide private]

__init__(self, maxhealth)
(Constructor)

source code 

Used for initialization code that does not require any other components. This is always called first, on construction and on load.

Overrides: Component.__init__
(inherited documentation)

initialize(self)

source code 

This is called by the ComponentHolder after it set the instance. Use this to initialize any needed infrastructure. When this is called, it is guaranteed that all other components this one has a dependency on have been added, but initalize may not have been called on them, only __init__. It is only called after construction, not on load().

Overrides: Component.initialize
(inherited documentation)

save(self, db)

source code 

Will do nothing, but will be always called in componentholder code, even if not implemented.

Overrides: Component.save
(inherited documentation)

load(self, db, worldid)

source code 

This does on load what __init() and initalize() together do on constructions at runtime. Has to set up everything that is not setup in __init__(). Note that on loading __init__() is called with the data needed by the component through get_instance(), but initialize() is not, so any work needed for loading as well should be moved to a separate method and called here.

Overrides: Component.load
(inherited documentation)