battleman.py: added some extra info in list view

This commit is contained in:
Anna Rose 2012-03-21 23:03:49 -04:00
parent 60df5f6bd0
commit ddbc14871a

View File

@ -90,7 +90,6 @@ class Combatant():
def add_condition(self, name, cond_type, duration): def add_condition(self, name, cond_type, duration):
condition = {} condition = {}
condition['name'] = name condition['name'] = name
condition['type'] = cond_type
condition['duration'] = duration condition['duration'] = duration
self.conditions.append(condition) self.conditions.append(condition)
@ -99,6 +98,16 @@ class Combatant():
print("{} has initiative.".format(self)) 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): def __str__(self):
return "{} ({hp} hp)".format(self.name, hp=self.hp) return "{} ({hp} hp)".format(self.name, hp=self.hp)
@ -161,7 +170,7 @@ class Battle():
else: else:
print('{}:'.format(g.name)) print('{}:'.format(g.name))
for c in g.members: 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): def next_combatant(self):
@ -171,6 +180,7 @@ class Battle():
battle = Battle() battle = Battle()
def main(): def main():