From: W. Trevor King Date: Fri, 26 Mar 2010 04:23:18 +0000 (-0400) Subject: Broke Engine.end_of_turn_cards out of Engine.play_turn X-Git-Tag: 0.1~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=66065ddb11b4ee407c7e7a9562b54e20bd8088c1;p=pyrisk.git Broke Engine.end_of_turn_cards out of Engine.play_turn For easier modification if you decide to change the rules in a subclass. --- diff --git a/risk/base.py b/risk/base.py index 9fdda26..847d48c 100644 --- a/risk/base.py +++ b/risk/base.py @@ -527,8 +527,7 @@ class Engine (ID_CmpMixin): for p in self.players])) self.play_cards_and_place_armies(player) captures = self.attack_and_fortify(player) - if captures > 0 and len(self.deck) > 0 and len(self.living_players()) > 1: - self.deal(player, 1) + self.end_of_turn_cards(player, captures) def select_territories(self): for t in self.world.territories(): t.player = None @@ -688,6 +687,11 @@ class Engine (ID_CmpMixin): if len(self.living_players()) > 1: player.report(self.world, self.log) # else the game is over, and killed will hear about this then. + def end_of_turn_cards(self, player, captures): + """Deal end-of-turn reward for any territory captures. + """ + if captures > 0 and len(self.deck) > 0 and len(self.living_players()) > 1: + self.deal(player, 1) def living_players(self): return [p for p in self.players if p.alive == True]