Commits

Dominic Kexel committed 7d69fd2

Attacks are now simpler, since the engine will now put the attacking player into SP_WAIT per default.

  • Participants
  • Parent commits 420e7c1

Comments (0)

Files changed (13)

File cards/alchemy/familiar.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT
 from cards.common.curse import Curse
-from game.subphaseinfo import SubPhaseInfo
 
 
 class Familiar(Card):
     def action_step(self, game, player):
         game.draw_card(player)
         player.actions += 1
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
-
+        
         game.attack(self, self.attack_handler, expect_answer=False)
 
     def attack_handler(self, game, attacked_player, result):

File cards/base/bureaucrat.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK, VICTORY
-from game.gamestates import SP_WAIT, SP_PICKCARDSFROMHAND
+from game.gamestates import SP_PICKCARDSFROMHAND
 from cards.common.silver import Silver
-from game.subphaseinfo import SubPhaseInfo
 
 
 class Bureaucrat(Card):
 
     def action_step(self, game, player):
         game.take_card_from_pile(player, game.get_pile(Silver), safe=True, to_deck=True)
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
-
         game.attack(self, self.attack_handler, info=
                     "Put a Victory Card on top of your deck", subphase=
                     SP_PICKCARDSFROMHAND)

File cards/base/militia.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT, SP_PICKCARDSFROMHAND
-from game.subphaseinfo import SubPhaseInfo
+from game.gamestates import SP_PICKCARDSFROMHAND
 
 
 class Militia(Card):
 
     def action_step(self, game, player):
         player.money += 2
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
-
         game.attack(self, self.attack_handler, info=
                     "Discard down to three cards", subphase=
                     SP_PICKCARDSFROMHAND)

File cards/base/spy.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT, SP_ASKPLAYER
+from game.gamestates import SP_ASKPLAYER
 from game.subphaseinfo import SubPhaseInfo
 from game.askplayerinfo import AskPlayerInfo
 
         self.revealed = {}
         game.draw_card(player)
         player.actions += 1
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players',
-                            on_restore_callback=self.handler))
-
         (self.revealed)[player.id] = game.reveal_top_card(player)
 
-        game.attack(self, self.attack_handler, expect_answer=False)
+        game.attack(self, self.attack_handler, expect_answer=False, on_restore_callback=self.handler)
 
     def attack_handler(self, game, attacked_player, result):
         (self.revealed)[attacked_player.id] = game.reveal_top_card(attacked_player)

File cards/base/thief.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK, TREASURE
-from game.gamestates import SP_WAIT, SP_ASKPLAYER
+from game.gamestates import SP_ASKPLAYER
 from game.subphaseinfo import SubPhaseInfo
 from game.askplayerinfo import AskPlayerInfo
 
 
     def action_step(self, game, player):
         self.revealed = {}
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players',
-                            on_restore_callback=self.handler))
-
-        game.attack(self, self.attack_handler, expect_answer=False)
+        game.attack(self, self.attack_handler, expect_answer=False, on_restore_callback=self.handler)
 
     def attack_handler(self, game, attacked_player, result):
         (self.revealed)[attacked_player.id] = game.reveal_top_card(attacked_player), game.reveal_top_card(attacked_player)

File cards/base/witch.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT
 from cards.common.curse import Curse
-from game.subphaseinfo import SubPhaseInfo
 
 
 class Witch(Card):
     def action_step(self, game, player):
         for _ in xrange(2):
             game.draw_card(player)
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
-
+            
         game.attack(self, self.attack_handler, expect_answer=False)
 
     def attack_handler(self, game, attacked_player, result):

File cards/cornucopia/followers.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT, SP_PICKCARDSFROMHAND
+from game.gamestates import SP_PICKCARDSFROMHAND
 from cards.common.estate import Estate
-from game.subphaseinfo import SubPhaseInfo
 from cards.common.curse import Curse
 
 
             game.draw_card(player)
             
         game.take_card_from_pile(player, game.get_pile(Estate), safe=True)
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
-
+        
         game.attack(self, self.attack_handler, info=
                     "Discard down to three cards", subphase=
                     SP_PICKCARDSFROMHAND)

File cards/intrigue/minion.py

                 
             for _ in xrange(4):
                 game.draw_card(player)
-            game.attack(self, self.attack_handler, expect_answer=False)
+            game.attack(self, self.attack_handler, expect_answer=False, enter_WAIT=False)
             game.resolved(self)
     
     def attack_handler(self, game, attacked_player, result):

File cards/intrigue/torturer.py

 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
 from cards.common.curse import Curse
-from game.gamestates import SP_WAIT, SP_PICKCARDSFROMHAND, SP_ASKPLAYER
-from game.subphaseinfo import SubPhaseInfo
+from game.gamestates import SP_PICKCARDSFROMHAND, SP_ASKPLAYER
 from game.askplayerinfo import AskPlayerInfo
 
 
 
     def action_step(self, game, player):
         [ game.draw_card(player) for _ in xrange(3) ]
-
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info='Waiting for other players'))
         
         game.attack(self, self.attack_handler, info=AskPlayerInfo("Torturer", 'Choose one:', ('Discard 2 cards', 
                             'Take a Curse card on hand'), self), subphase=SP_ASKPLAYER)

File cards/seaside/cutpurse.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT
 from cards.common.copper import Copper
-from game.subphaseinfo import SubPhaseInfo
 
 
 class Cutpurse(Card):
 
     def action_step(self, game, player):
         player.money += 2
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
         game.attack(self, self.attack_handler, expect_answer=False)
 
     def attack_handler(self, game, attacked_player, result):

File cards/seaside/ghostship.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT, SP_PICKCARDSFROMHAND
-from game.subphaseinfo import SubPhaseInfo
+from game.gamestates import SP_PICKCARDSFROMHAND
 
 
 class Ghostship(Card):
         Card.__init__(self)
 
     def action_step(self, game, player):
-        [ game.draw_card(player) for _ in xrange(2) ]
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
-
+        for _ in xrange(2):
+            game.draw_card(player)
+        
         game.attack(self, self.attack_handler, info=
                     "Discard down to three cards", subphase=
                     SP_PICKCARDSFROMHAND)

File cards/seaside/seahag.py

 
 from cards.card import Card
 from cards.cardtypes import ACTION, ATTACK
-from game.gamestates import SP_WAIT
 from cards.common.curse import Curse
-from game.subphaseinfo import SubPhaseInfo
 
 
 class Seahag(Card):
         Card.__init__(self)
 
     def action_step(self, game, player):
-        game.enter_subphase(SubPhaseInfo(SP_WAIT, card=self, info=
-                            'Waiting for other players'))
         game.attack(self, self.attack_handler, expect_answer=False)
-        game.resolved(self)
 
     def attack_handler(self, game, attacked_player, result):
         card = game.reveal_top_card(attacked_player)

File game/game.py

         return players
     
     def attack(self, card, attack_handler, subphase=None, info=None,
-               expect_answer=True):
+               expect_answer=True, enter_WAIT=True, on_restore_callback=None):
         assert card, "card is none"
         assert attack_handler, "attackhandler is None"
 
+        if enter_WAIT:
+            self.enter_subphase(SubPhaseInfo(SP_WAIT, 
+                                             card, 
+                                             'Waiting for other players',
+                                             on_restore_callback=on_restore_callback))
+
         attacked_players = [p for p in self.players if p != self.active_player]
 
         attack_phase = subphase or SP_WAIT