battleman.py: Refactored turn begin/end code

This commit is contained in:
Anna Rose 2012-03-22 17:50:50 -04:00
parent e40b485205
commit a59a4f1ea4

View File

@ -75,6 +75,20 @@ class CombatGroup():
return len(self.members) == 1 return len(self.members) == 1
def begin_turn(self):
msg = None
if self.is_solo_group():
msg = '{} has initiative.'.format(self.name)
else:
msg = '{} have initiative.'.format(self.name)
print msg
def end_turn(self):
for c in self.members:
c.end_turn()
class Combatant(): class Combatant():
next_index = 0 next_index = 0
@ -100,8 +114,8 @@ class Combatant():
self.conditions.append(condition) self.conditions.append(condition)
def begin_turn(self): def end_turn(self):
print("{} has initiative.".format(self)) pass # fixme - need to do a lot of stuff with conditions here
def damage(self, amount): def damage(self, amount):
@ -211,8 +225,12 @@ class Battle():
self.current = 0 self.current = 0
self.round = 1 self.round = 1
print '\nInitiative Roster:\n'
for g in self.groups: for g in self.groups:
print '{} ({})'.format(g.name, g.init) print '{} ({})'.format(g.name, g.init)
print ''
self.get_current_group().begin_turn()
# Returns a formatted string with all of the combatants # Returns a formatted string with all of the combatants