battleman.py: Fixed recharge rolling, added message when roll succeeds

This commit is contained in:
Anna Rose 2012-03-25 13:56:55 -04:00
parent 0afd59aa88
commit 14e5033c2d

View File

@ -198,14 +198,15 @@ class Combatant():
else: else:
print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])) print('{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:]))
# fixme: print message when this succeeds # fixme - this rolls on the same turn the power is used. Need a way to avoid that.
for r in self.recharges: for r in self.recharges.values():
if r['used']: # fixme: this line breaks if r['used']:
# Roll to recharge # Roll to recharge
d = Dice.from_str('1d6') d = Dice.from_str('1d6')
n = d.roll()['total'] n = d.roll()['total']
if n >= r['value']: if n >= r['value']:
r['used'] = False r['used'] = False
print('{} can use {} again!'.format(self, r['name']))
def damage(self, amount): def damage(self, amount):
@ -735,6 +736,7 @@ def do_add_condition(data):
c.add_condition(name, ctype, duration, end_type) c.add_condition(name, ctype, duration, end_type)
# fixme: if you pick someone with no conditions, you get stuck in a loop
def do_remove_condition(data): def do_remove_condition(data):
if len(data) >= 1: if len(data) >= 1:
c = battle.get_combatant(int(data[0])) c = battle.get_combatant(int(data[0]))
@ -752,6 +754,7 @@ def do_remove_condition(data):
c.remove_condition(index) c.remove_condition(index)
# fixme: if you pick someone with no recharges, you get stuck in a loop
def do_use_recharge_power(data): def do_use_recharge_power(data):
if len(data) >= 1: if len(data) >= 1:
c = battle.get_combatant(int(data[0])) c = battle.get_combatant(int(data[0]))