diff --git a/battleman.py b/battleman.py index 8612c83..a94416d 100755 --- a/battleman.py +++ b/battleman.py @@ -178,7 +178,7 @@ class Battle(): self.combatant_hash = {} self.groups = [] self.current = None - self.round = -1 + self.round = None def __str__(self): @@ -264,8 +264,21 @@ class Battle(): def next_combatant(self): - print('Sorry, this is still a stub function.') + if not self.validate_started(): + return + g = self.get_current_group() + g.end_turn() + + self.current += 1 + + if self.current >= len(self.groups): + self.current = 0 + self.round += 1 + print('Beginning round {}'.format(self.round)) + + g = self.get_current_group() + g.begin_turn() def deal_damage(self, index, amount): @@ -273,6 +286,13 @@ class Battle(): c.damage(amount) + def validate_started(self): + if not self.is_started(): + print('Error: you can only run this command after starting the battle') + return False + return True + + battle = Battle() def main(): @@ -331,12 +351,8 @@ def do_prompt(): def do_damage(): - if not battle.is_started(): - print('Error: you can only run this command after starting the battle') - return - print battle.list_combatants() - index = input_int('choose combatant', battle.get_current_group().members[0].index) + index = input_int('choose combatant') amount = input_int('damage') battle.deal_damage(index, amount)