Ignore:
Timestamp:
09/04/13 20:46:29 (8 years ago)
Author:
David Sharpe
Branch:
default
Phase:
public
Message:

Added health to protagonist.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/protagonist.py

    r230 r246  
    44
    55from nagslang import render
    6 from nagslang.constants import COLLISION_TYPE_PLAYER, ZORDER_MID
     6from nagslang.constants import COLLISION_TYPE_PLAYER, ZORDER_MID, \
     7    WEREWOLF_SOAK_FACTOR, PROTAGONIST_HEALTH_MIN_LEVEL, \
     8    PROTAGONIST_HEALTH_MAX_LEVEL
    79from nagslang.game_object import GameObject, Physicser, make_body
    810from nagslang.mutators import FLIP_H
     
    5052        super(Protagonist, self).__init__(physicser, renderer)
    5153        self.zorder = ZORDER_MID
     54
     55        self.health_level = 100
    5256
    5357        self.go_human()
     
    230234            return
    231235        self.physicser.apply_impulse((dx, dy))
     236
     237    def get_health_level(self):
     238        return self.health_level
     239
     240    def lose_health(self, amount):
     241        if self.in_human_form():
     242            self.health_level -= amount
     243        else:
     244            self.health_level -= amount / WEREWOLF_SOAK_FACTOR
     245        if self.health_level < PROTAGONIST_HEALTH_MIN_LEVEL:
     246            self.health_level = PROTAGONIST_HEALTH_MIN_LEVEL
     247
     248    def gain_health(self, amount):
     249        self.health_level += amount
     250        if self.health_level > PROTAGONIST_HEALTH_MAX_LEVEL:
     251            self.health_level = PROTAGONIST_HEALTH_MAX_LEVEL
Note: See TracChangeset for help on using the changeset viewer.