From 66065ddb11b4ee407c7e7a9562b54e20bd8088c1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 26 Mar 2010 00:23:18 -0400 Subject: [PATCH] Broke Engine.end_of_turn_cards out of Engine.play_turn For easier modification if you decide to change the rules in a subclass. --- risk/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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] -- 2.26.2