Skip to content

Commit

Permalink
Blood pact now kills if already bleeding
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <oleherman93@gmail.com>
  • Loading branch information
olehermanse committed Apr 29, 2018
1 parent 574a556 commit 0d05553
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions mrpg/core/creature.py
@@ -1,6 +1,6 @@
from collections import OrderedDict

from mrpg.utils.utils import limit
from mrpg.utils.utils import limit, internal
from mrpg.core.skill_collections import CreatureSkillCollection
from mrpg.core.stats import Stats

Expand All @@ -21,6 +21,7 @@ def init(self, name, level, skill_names=None):
self.use_skill = None
self.effects = []
self.effect_queue = []
self.dead = False

def add_effects(self):
out = []
Expand All @@ -35,6 +36,14 @@ def add_effects(self):
def add_effect(self, effect, source=None):
self.effect_queue.append(effect)

def has_effect(self, effect_name):
effect_name = internal(effect_name)
for e in self.effects:
compare = internal(e.name)
if compare == effect_name:
return True
return False

def calculate_effects(self):
return [effect.calculate() for effect in self.effects]

Expand Down Expand Up @@ -85,6 +94,8 @@ def damage(self, amount, limit_check=False, source=None):
msg = ["{} lost {} hit points".format(self.name, amount)]
if source:
msg[0] += " from {}".format(source)
if self.dead:
msg = [] # Nice to not print extra damage messages when dead
if limit_check:
msg.append(self.limit_check())
return msg
Expand All @@ -102,7 +113,7 @@ def town_heal(self):
self.current["hp"] = self.base["hp"]

def limit_check(self):
if self.current["hp"] <= 0:
if self.current["hp"] <= 0 or self.dead:
self.current["hp"] = 0
return ["{} died".format(self.name)]
if self.current["hp"] > self.base["hp"]:
Expand All @@ -113,7 +124,7 @@ def limit_check(self):
def is_alive(self):
hp = self.current["hp"]
assert hp >= 0
return hp > 0
return hp > 0 and not self.dead

def is_dead(self):
return not self.is_alive()
Expand Down
4 changes: 4 additions & 0 deletions mrpg/core/skills.py
Expand Up @@ -82,8 +82,12 @@ def apply(skill, user, target):
def blood_pact():
def calculate(skill, user, target):
skill.damage = skill.healing = user.base["hp"]
skill.kill = user.has_effect("Bleed")

def apply(skill, user, target):
if skill.kill:
user.dead = True
return ["{} bled out".format(user.name)]
target = user
bleed = Effects.get("Bleed")
bleed.setup(skill, target)
Expand Down

0 comments on commit 0d05553

Please sign in to comment.