battleman.py: Code cleanup
This commit is contained in:
parent
029907edf2
commit
a89acda1ac
38
battleman.py
38
battleman.py
|
@ -132,7 +132,7 @@ class Combatant():
|
|||
condition['end_type'] = end_type
|
||||
condition['index'] = self.next_condition_index
|
||||
if cond_type == 'timed' and duration == None:
|
||||
print('Error: specified a timed condition with no duration.')
|
||||
print 'Error: specified a timed condition with no duration.'
|
||||
return
|
||||
self.conditions[self.next_condition_index] = condition
|
||||
self.next_condition_index += 1
|
||||
|
@ -145,7 +145,7 @@ class Combatant():
|
|||
return None
|
||||
|
||||
c = self.conditions.pop(index)
|
||||
print('{} is no longer affected by {}.'.format(self, c['name']))
|
||||
print '{} is no longer affected by {}.'.format(self, c['name'])
|
||||
|
||||
return c
|
||||
|
||||
|
@ -177,7 +177,7 @@ class Combatant():
|
|||
if c['duration'] <= 0:
|
||||
self.remove_condition(c['index'])
|
||||
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:])
|
||||
|
||||
|
||||
def end_turn(self):
|
||||
|
@ -185,7 +185,7 @@ class Combatant():
|
|||
if c['cond_type'] == 's':
|
||||
r = None
|
||||
if self.pc:
|
||||
print('{}: save against {}.'.format(self, c['name']))
|
||||
print '{}: save against {}.'.format(self, c['name'])
|
||||
r = input_int('saving throw')
|
||||
else:
|
||||
save_die = Dice.from_str('1d20')
|
||||
|
@ -193,15 +193,15 @@ class Combatant():
|
|||
|
||||
if r >= 10:
|
||||
self.remove_condition(c['index'])
|
||||
print('{} successfully saved against {}.'.format(self, c['name']))
|
||||
print '{} successfully saved against {}.'.format(self, c['name'])
|
||||
else:
|
||||
print('{} failed a save against {}.'.format(self, c['name']))
|
||||
print '{} failed a save against {}.'.format(self, c['name'])
|
||||
|
||||
elif c['cond_type'] == 't' and c['end_type'] == 'e':
|
||||
if c['duration'] <= 0:
|
||||
self.remove_condition(c['index'])
|
||||
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:])
|
||||
|
||||
for r in self.recharges.values():
|
||||
if r['used']:
|
||||
|
@ -214,7 +214,7 @@ class Combatant():
|
|||
n = d.roll()['total']
|
||||
if n >= r['value']:
|
||||
r['used'] = False
|
||||
print('{} can use {} again!'.format(self, r['name']))
|
||||
print '{} can use {} again!'.format(self, r['name'])
|
||||
|
||||
|
||||
def damage(self, amount):
|
||||
|
@ -231,9 +231,9 @@ class Combatant():
|
|||
print '{} took {} points of damage.'.format(self, amount)
|
||||
|
||||
if self.is_down():
|
||||
print('{} is down!'.format(self))
|
||||
print '{} is down!'.format(self)
|
||||
elif self.is_bloodied() and not was_bloodied:
|
||||
print('{} is bloodied!'.format(self))
|
||||
print '{} is bloodied!'.format(self)
|
||||
|
||||
|
||||
def heal(self, amount):
|
||||
|
@ -250,14 +250,14 @@ class Combatant():
|
|||
self.hp += amount_healed
|
||||
|
||||
if was_down:
|
||||
print('{} regains consciousness.'.format(self))
|
||||
print '{} regains consciousness.'.format(self)
|
||||
|
||||
print('{} regained {} hit points.'.format(self, amount_healed))
|
||||
print '{} regained {} hit points.'.format(self, amount_healed)
|
||||
|
||||
if was_bloodied and not self.is_bloodied():
|
||||
print('{} is no longer bloodied.'.format(self))
|
||||
print '{} is no longer bloodied.'.format(self)
|
||||
elif was_bloodied and self.is_bloodied():
|
||||
print('{} is still bloodied.'.format(self))
|
||||
print '{} is still bloodied.'.format(self)
|
||||
|
||||
|
||||
def add_temp_hp(self, amount):
|
||||
|
@ -451,7 +451,7 @@ class Battle():
|
|||
|
||||
def begin(self):
|
||||
if self.is_started():
|
||||
print("Error: battle is already running")
|
||||
print "Error: battle is already running"
|
||||
|
||||
for g in self.groups:
|
||||
if g.is_solo_group() and g.members[0].pc:
|
||||
|
@ -532,7 +532,7 @@ class Battle():
|
|||
for c in self.combatant_hash.values():
|
||||
c.tick_conditions()
|
||||
|
||||
print('Beginning round {}'.format(self.round))
|
||||
print 'Beginning round {}'.format(self.round)
|
||||
|
||||
|
||||
def validate_started(self):
|
||||
|
@ -563,7 +563,7 @@ def main():
|
|||
|
||||
# fixme - change input behavior. If an action has a sensible default, do that when no args are passed - require args to change default behavior
|
||||
def do_prompt():
|
||||
print('')
|
||||
print ''
|
||||
(comm, rdata) = input_str('', default='?', show_default=False, prompt_str='>').partition(' ')[::2]
|
||||
data = rdata.split(' ')
|
||||
|
||||
|
@ -634,7 +634,7 @@ q - quit""")
|
|||
def do_add_combatants(data):
|
||||
ngroups = input_int('number of groups')
|
||||
for i in range(1, ngroups+1):
|
||||
print("Adding group {}".format(i))
|
||||
print "Adding group {}".format(i)
|
||||
battle.add_group(CombatGroup.from_input())
|
||||
|
||||
|
||||
|
@ -801,7 +801,7 @@ def do_unwait(data):
|
|||
|
||||
|
||||
def do_stub():
|
||||
print("Sorry, this is a stub function")
|
||||
print "Sorry, this is a stub function"
|
||||
|
||||
|
||||
def input_str(prompt, default=None, show_default=False, prompt_str=':'):
|
||||
|
|
Loading…
Reference in New Issue
Block a user