Commits

Alexander Schremmer  committed d0e45a7

Introduce following_participants and make following_players do what it did when we didnt have kibitzers. Cards do not deal with kibitzers anymore, only with participants!

  • Participants
  • Parent commits b5fb5a8

Comments (0)

Files changed (7)

File domination/cards/__init__.py

                 card = cards[0]
                 already_selected.add(card)
                 # notify other players
-                for info_player in game.following_players(other_player):
+                for info_player in game.following_participants(other_player):
                     yield InfoRequest(
                         game, info_player,
                         _("%s reacts with:") % (other_player.name, ), [card])

File domination/cards/alchemy.py

         player.draw_cards(1)
         curse_cards = game.supply["Curse"]
         for other_player in game.following_players(player):
-            if other_player not in game.kibitzers:
-                if curse_cards:
-                    try:
-                        handle_defense(self, game, other_player)
-                    except Defended:
-                        continue
-                    other_player.discard_pile.append(curse_cards.pop())
-                    yield InfoRequest(game, other_player,
-                            _("%s curses you. You gain a curse card.") % (player.name, ), [])
-                    for val in game.check_empty_pile("Curse"):
-                        yield val
+            if curse_cards:
+                try:
+                    handle_defense(self, game, other_player)
+                except Defended:
+                    continue
+                other_player.discard_pile.append(curse_cards.pop())
+                yield InfoRequest(game, other_player,
+                        _("%s curses you. You gain a curse card.") % (player.name, ), [])
+                for val in game.check_empty_pile("Curse"):
+                    yield val
 
 
 class Golem(ActionCard):
                 msg=_("Which card do you want to trash?"))
         if cards:
             card = cards[0]
-            for other_player in game.following_players(player):
+            for other_player in game.following_participants(player):
                 yield InfoRequest(game, other_player,
                         _("%s trashes this card:") % (player.name, ), cards)
             card.trash(game, player)
                 for val in game.check_empty_pile("Duchy"):
                     yield val
                 player.discard_pile.append(new_card)
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player,
                             _("%s gains:") % (other_player.name, ), [new_card])
             if isinstance(card, TreasureCard):
                 for val in game.check_empty_pile("Transmute"):
                     yield val
                 player.discard_pile.append(new_card)
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player,
                             _("%s gains:") % (other_player.name, ), [new_card])
             if isinstance(card, VictoryCard):
                 for val in game.check_empty_pile("Gold"):
                     yield val
                 player.discard_pile.append(new_card)
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player,
                             _("%s gains:") % (other_player.name, ), [new_card])
 

File domination/cards/base.py

                     _("Select a Victory card you want to reveal"), VictoryCard, 1, 1))[0]
                 other_player.deck.append(card)
                 other_player.hand.remove(card)
-                for info_player in game.following_players(other_player):
+                for info_player in game.following_participants(other_player):
                     yield InfoRequest(game, info_player, _("%s reveals a card:") % (other_player.name, ), [card])
             else:
-                for info_player in game.following_players(other_player):
+                for info_player in game.following_participants(other_player):
                     yield InfoRequest(game, info_player, _("%s reveals his hand:") % \
                             (other_player.name, ), other_player.hand)
 
         player.draw_cards(4)
         player.remaining_deals += 1
         for other_player in game.following_players(player):
-            if other_player not in game.kibitzers:
-                other_player.draw_cards(1)
+            other_player.draw_cards(1)
 
 class Feast(ActionCard):
     name = _("Feast")
             msg=_("Select a card that you want to have."), show_supply_count=True)
         new_card = game.supply[card_cls.__name__].pop()
         player.discard_pile.append(new_card)
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s gains:") % (player.name, ), [new_card])
         for val in game.check_empty_pile(card_cls.__name__):
             player.virtual_money += 3
             card = copper_cards[0]
             card.trash(game, player)
-            for info_player in game.following_players(player):
+            for info_player in game.following_participants(player):
                 yield InfoRequest(game, info_player,
                         _("%s trashes:") % (player.name, ), [card])
 
                 _("Do you want to discard %(name)s's card '%(cardname)s'?") %
                 {"cardname": card.name, "name": other_player.name})):
                 other_player.discard_pile.append(card)
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player,
                             _("%(playername)s discarded %(player2name)s's card:") %
                             {"playername": player.name, "player2name": other_player.name},
                 card = [c for c in treasure_cards if isinstance(c, card_cls)][0]
                 trashed.append(card)
                 cards.remove(card)
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player, _("%s trashes:") %
                             (player.name, ), [card])
             other_player.discard_pile.extend(cards)
             if (yield YesNoQuestion(game, player,
                 _("Do you want to have the card '%s'?") % (card.name, ))):
                 player.discard_pile.append(card)
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player, _("%s picks up this card from trash:") %
                             (player.name, ), [card])
             else:
             msg=_("Select a card that you want to have."), show_supply_count=True)
         new_card = game.supply[card_cls.__name__].pop()
         player.discard_pile.append(new_card)
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s gains:") % (player.name, ), [new_card])
         for val in game.check_empty_pile(card_cls.__name__):

File domination/cards/intrigue.py

             player.virtual_money += 4
             card = estate_cards[0]
             card.discard(player)
-            for info_player in game.following_players(player):
+            for info_player in game.following_participants(player):
                 yield InfoRequest(game, info_player,
                         _("%s discards:") % (player.name, ), [card])
         else:
             msg=_("Select a card that you want to have."), show_supply_count=True)
         new_card = game.supply[card_cls.__name__].pop()
         player.discard_pile.append(new_card)
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s gains:") % (player.name, ), [new_card])
         for val in game.check_empty_pile(card_cls.__name__):
         if cards:
             for card in cards:
                 card.trash(game, player)
-            for other_player in game.following_players(player):
+            for other_player in game.following_participants(player):
                 yield InfoRequest(game, other_player,
                         _("%s trashes this card:") % (player.name, ), cards)
 
         answer = yield Question(game, player, _("What do you want to do?"),
                                 actions)
 
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s chooses '%s'") % (player.name, _(dict(actions)[answer])), [])
 
             for card in original_hand:
                 card.discard(player)
             player.draw_cards(4)
-            for info_player in game.following_players(player):
+            for info_player in game.following_participants(player):
                 yield InfoRequest(
                     game, info_player,
                     _("%s discards this hand and draws 4 cards:") %
                 yield InfoRequest(
                     game, other_player,
                     _("You discard your hand and draw 4 cards."), [])
-                for info_player in game.following_players(other_player):
+                for info_player in game.following_participants(other_player):
                     yield InfoRequest(
                         game, info_player,
                         _("%s discards this hand and draws 4 cards:") %
         answer = yield Question(game, player, _("What do you want to get?"),
                                 actions)
 
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s chooses '%s'") % (player.name, _(dict(actions)[answer])), [])
 
             if len(choice) == 2:
                 break
 
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             chosen = ", ".join(_(dict(choices)[c]) for c in choice)
             yield InfoRequest(game, info_player,
                     _("%s chooses '%s'") % (player.name, chosen), [])
     def activate_action(self, game, player):
         player.remaining_actions += 2
 
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player, _("%s reveals his hand:") % \
                     (player.name, ), player.hand[:])
 
             card_cls = yield req
             new_card = game.supply[card_cls.__name__].pop()
             other_player.discard_pile.append(new_card)
-            for info_player in game.following_players(player):
+            for info_player in game.following_participants(player):
                 yield InfoRequest(game, info_player,
                         _("%s gains:") % (other_player.name, ), [new_card])
             for val in game.check_empty_pile(card_cls.__name__):
         answer = yield Question(game, player, _("What do you want to do?"),
                                 actions)
 
-        for info_player in game.following_players(player):
+        for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s chooses '%s'") % (player.name, _(dict(actions)[answer])), [])
 

File domination/cards/seaside.py

                             yield InfoRequest(game, other_player,
                                 _("%s discards these cards:") % (other_player.name, ), cards)
             else:
-                for info_player in game.following_players(player):
+                for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player, _("%s reveals his hand:") % \
                             (other_player.name, ), other_player.hand[:])
 
     def activate_action(self, game, player):
         player.draw_cards(2)
         for other_player in game.following_players(player):
-            if other_player not in game.kibitzers:
-                try:
-                    handle_defense(self, game, other_player)
-                except Defended:
-                    continue
-                if len(other_player.hand) < 4:
-                    continue
-                count = len(other_player.hand) - 3
-                cards = yield SelectHandCards(game, other_player, count_lower=count, count_upper=count,
-                        msg=_("%s played Ghost Ship. Which cards do you want to put on the top of your deck?") % (player.name, ))
-                for card in cards:
-                    card.backondeck(game, other_player)
+            try:
+                handle_defense(self, game, other_player)
+            except Defended:
+                continue
+            if len(other_player.hand) < 4:
+                continue
+            count = len(other_player.hand) - 3
+            cards = yield SelectHandCards(game, other_player, count_lower=count, count_upper=count,
+                    msg=_("%s played Ghost Ship. Which cards do you want to put on the top of your deck?") % (player.name, ))
+            for card in cards:
+                card.backondeck(game, other_player)
 
-#http://www.boardgamegeek.com/image/586408/dominion-seaside?size=large
 
 class Haven(ActionCard, DurationCard):
     name = _("Haven")

File domination/gameengine.py

         raise EndOfGameException
 
     def following_players(self, current_player):
+        """ Returns all other players in the correct order.
+        """
+        players = self.players
+        return players[players.index(current_player) + 1:] + \
+                players[:players.index(current_player)]
+
+    def following_participants(self, current_player):
         """ Returns all other players in the correct order and adds
         the kibitzers."""
-        players = self.players
-        return players[players.index(current_player) + 1:] + \
-                players[:players.index(current_player)] + self.kibitzers
+        return self.following_players(current_player) + self.kibitzers
 
     def check_empty_pile(self, key):
         if not self.supply[key]:

File domination/macros.py

 
 @macro
 def handle_defense(self, game, player):
-    from domination.gameengine import Defended
-    if player in game.kibitzers:
-        raise Defended
     gen = self.defends_check(game, player)
     item = None
     while True: