battleman.py: Avoid getting stuck in input loop when adding conditions or using recharge powers
This commit is contained in:
parent
14e5033c2d
commit
656e46d28e
20
battleman.py
20
battleman.py
|
@ -150,6 +150,10 @@ class Combatant():
|
||||||
|
|
||||||
|
|
||||||
def choose_condition(self):
|
def choose_condition(self):
|
||||||
|
if not len(self.conditions):
|
||||||
|
print '{} has no conditions.'.format(self)
|
||||||
|
return None
|
||||||
|
|
||||||
print self.format_condition_summary()
|
print self.format_condition_summary()
|
||||||
index = input_int('choice')
|
index = input_int('choice')
|
||||||
|
|
||||||
|
@ -296,6 +300,10 @@ class Combatant():
|
||||||
|
|
||||||
|
|
||||||
def choose_recharge_power(self):
|
def choose_recharge_power(self):
|
||||||
|
if not len(self.recharges):
|
||||||
|
print '{} has no rechargable powers.'.format(self)
|
||||||
|
return None
|
||||||
|
|
||||||
print self.format_recharge_summary()
|
print self.format_recharge_summary()
|
||||||
index = input_int('choice')
|
index = input_int('choice')
|
||||||
|
|
||||||
|
@ -749,8 +757,12 @@ def do_remove_condition(data):
|
||||||
if len(data) >= 2:
|
if len(data) >= 2:
|
||||||
index = int(data[1])
|
index = int(data[1])
|
||||||
else:
|
else:
|
||||||
index = c.choose_condition()['index']
|
cond = c.choose_condition()
|
||||||
|
index = None
|
||||||
|
if cond:
|
||||||
|
index = cond['index']
|
||||||
|
|
||||||
|
if index != None:
|
||||||
c.remove_condition(index)
|
c.remove_condition(index)
|
||||||
|
|
||||||
|
|
||||||
|
@ -767,8 +779,12 @@ def do_use_recharge_power(data):
|
||||||
if len(data) >= 2:
|
if len(data) >= 2:
|
||||||
index = int(data[1])
|
index = int(data[1])
|
||||||
else:
|
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)
|
c.use_recharge_power(index)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user