From ddbc14871abadec02174cbd29c513d7d08fd161e Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Wed, 21 Mar 2012 23:03:49 -0400 Subject: [PATCH] battleman.py: added some extra info in list view --- battleman.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/battleman.py b/battleman.py index 152ee9f..8209359 100755 --- a/battleman.py +++ b/battleman.py @@ -90,7 +90,6 @@ class Combatant(): def add_condition(self, name, cond_type, duration): condition = {} condition['name'] = name - condition['type'] = cond_type condition['duration'] = duration self.conditions.append(condition) @@ -99,6 +98,16 @@ class Combatant(): print("{} has initiative.".format(self)) + def get_health_summary(self): + bloodied = '' + if self.hp <= self.max_hp / 2: + bloodied = ', bloodied' + if len(self.conditions): + bloodied = bloodied + ', ' + + return '{} hp{}{}'.format(self.hp, bloodied, ', '.join([x.name for x in self.conditions])) + + def __str__(self): return "{} ({hp} hp)".format(self.name, hp=self.hp) @@ -161,13 +170,14 @@ class Battle(): else: print('{}:'.format(g.name)) for c in g.members: - print('\t{}: {}'.format(c.index, c.name)) + print('\t{}: {} ({})'.format(c.index, c.name, c.get_health_summary())) def next_combatant(self): print('Sorry, this is still a stub function.') g = self.get_current_group() +