battleman.py: Avoid getting stuck in input loop when adding conditions or using recharge powers

This commit is contained in:
Anna Rose 2012-03-25 14:08:15 -04:00
parent 14e5033c2d
commit 656e46d28e

View File

@ -150,6 +150,10 @@ class Combatant():
def choose_condition(self):
if not len(self.conditions):
print '{} has no conditions.'.format(self)
return None
print self.format_condition_summary()
index = input_int('choice')
@ -296,6 +300,10 @@ class Combatant():
def choose_recharge_power(self):
if not len(self.recharges):
print '{} has no rechargable powers.'.format(self)
return None
print self.format_recharge_summary()
index = input_int('choice')
@ -749,8 +757,12 @@ def do_remove_condition(data):
if len(data) >= 2:
index = int(data[1])
else:
index = c.choose_condition()['index']
cond = c.choose_condition()
index = None
if cond:
index = cond['index']
if index != None:
c.remove_condition(index)
@ -767,8 +779,12 @@ def do_use_recharge_power(data):
if len(data) >= 2:
index = int(data[1])
else:
index = c.choose_recharge_power()['index']
r = c.choose_recharge_power()
index = None
if r:
index = r['index']
if index != None:
c.use_recharge_power(index)