battleman.py: added some extra info in list view
This commit is contained in:
parent
60df5f6bd0
commit
ddbc14871a
14
battleman.py
14
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,7 +170,7 @@ 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):
|
||||
|
@ -171,6 +180,7 @@ class Battle():
|
|||
|
||||
|
||||
|
||||
|
||||
battle = Battle()
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Reference in New Issue
Block a user