diff --git a/battleman.py b/battleman.py index c8a09e9..bde0878 100755 --- a/battleman.py +++ b/battleman.py @@ -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,9 +757,13 @@ 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'] - c.remove_condition(index) + if index != None: + c.remove_condition(index) # fixme: if you pick someone with no recharges, you get stuck in a loop @@ -767,9 +779,13 @@ 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'] - c.use_recharge_power(index) + if index != None: + c.use_recharge_power(index) def do_wait(data):