battleman.py: Code cleanup and output format cleanup for combatant info printing.

This commit is contained in:
Anna Rose 2012-03-25 14:26:24 -04:00
parent a89acda1ac
commit 2cd5120ec0

View File

@ -339,7 +339,7 @@ sw: {sw}
conditions:
{conditions}
recharge powers:
{recharge}""".format(index=self.index, name=self.name, hp=self.hp, max_hp=self.max_hp, temp_hp=self.temp_hp, surge=self.surges, ap=self.ap, sw=self.sw, conditions=self.format_condition_summary(), recharge=self.format_recharge_summary(), separator='='*len(self.name))
{recharge}""".format(index=self.index, name=self.name, hp=self.hp, max_hp=self.max_hp, temp_hp=self.temp_hp, surge=self.surges, ap=self.ap, sw=self.sw, conditions=self.format_condition_summary(' '), recharge=self.format_recharge_summary(' '), separator='='*len(self.name))
def format_health_summary(self):
@ -356,7 +356,7 @@ recharge powers:
return '{} hp{}{}{}'.format(self.hp, temp_info, bloodied, ', '.join([x['name'] for x in self.conditions.values()]))
def format_condition_summary(self):
def format_condition_summary(self, initial=''):
summary = ''
for (index, c) in self.conditions.items():
type_string = ''
@ -364,14 +364,14 @@ recharge powers:
type_string = 'Save Ends'
elif c['cond_type'] == 't':
type_string = '{} Round{}'.format(c['duration'], 's'[ c['duration']==1: ] )
summary = summary + '{}: {} ({})\n'.format(index, c['name'], type_string)
summary = summary + '{}{}: {} ({})\n'.format(initial, index, c['name'], type_string)
return summary.rstrip()
def format_recharge_summary(self):
def format_recharge_summary(self, initial):
summary = ''
for (index, r) in self.recharges.items():
summary = summary + '{}: {} (Recharge: {}, Available: {})\n'.format(index, r['name'], r['value'], ['Yes', 'No'][ r['used'] ])
summary = summary + '{}{}: {} (Recharge: {}, Available: {})\n'.format(initial, index, r['name'], r['value'], ['Yes', 'No'][ r['used'] ])
return summary.rstrip()
@ -491,16 +491,13 @@ class Battle():
if self.validate_started():
return self.validate_started()
ret = ''
g = self.groups[self.current]
if g.is_solo_group():
ret = '{}\n'.format(g.members[0].format_full_info())
return '{}'.format(g.members[0].format_full_info())
else:
ret = ret + '{}'.format(g.name)
ret = '{}\n'.format(g.name)
for c in g.members:
ret = ret + ' {}\n'.format(c)
return ret.rstrip()