Commits

Anonymous committed 1f05ac0

Fix many cards: only get cards from supply when there are any left

Comments (0)

Files changed (4)

domination/cards/cornucopia.py

                 for info_player in game.following_participants(player):
                     yield InfoRequest(game, info_player,
                             _("%(player)s chooses '%(action)s'", {"player": player.name, "action": _(dict(actions)[answer])}), [])
-                new_card = game.supply[card.__name__].pop()
-                if answer == "give":
-                    other_player.discard_pile.append(new_card)
-                    yield InfoRequest(game, info_player,
-                            _("%s gains:", (other_player.name, )), [new_card])
-                if answer == "take":
-                    player.discard_pile.append(new_card)
-                    yield InfoRequest(game, info_player,
-                            _("%s gains:", (player.name, )), [new_card])
-                for val in game.check_empty_pile(card.__name__):
-                    yield val
+                if game.supply[card.__name__]:
+                    new_card = game.supply[card.__name__].pop()
+                    if answer == "give":
+                        other_player.discard_pile.append(new_card)
+                        yield InfoRequest(game, info_player,
+                                _("%s gains:", (other_player.name, )), [new_card])
+                    if answer == "take":
+                        player.discard_pile.append(new_card)
+                        yield InfoRequest(game, info_player,
+                                _("%s gains:", (player.name, )), [new_card])
+                    for val in game.check_empty_pile(card.__name__):
+                        yield val
 
 class Menagerie(ActionCard):
     name = _("Menagerie")

domination/cards/intrigue.py

         for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                     _("%s trashes these cards:", (player.name, )), cards)
-        new_card = game.supply["Silver"].pop()
-        player.hand.append(new_card)
-        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("Silver"):
-            yield val
+        if game.supply["Silver"]:
+            new_card = game.supply["Silver"].pop()
+            player.hand.append(new_card)
+            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("Silver"):
+                yield val
 
 class Tribute(ActionCard):
     name = _("Tribute")

domination/cards/prosperity.py

             for info_player in game.participants:
                 yield InfoRequest(game, info_player, _("%s reveals:",
                         (player.name, )), [card])
-            new_card = game.supply[card.__name__].pop()
-            player.discard_pile.append(new_card)
-            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__):
-                yield val
+            if game.supply[card.__name__]:
+                new_card = game.supply[card.__name__].pop()
+                player.discard_pile.append(new_card)
+                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.__name__):
+                    yield val
 
 class Mountebank(AttackCard):
     name = _("Mountebank")
     desc = _("Trash any number of cards from your hand. Gain a card with cost exactly equal to the the total cost in coins of the trashed cards.")
 
     def activate_action(self, game, player):
+        new_cards = []
         Forge_money = 0
         if player.hand:
             cards = yield SelectHandCards(game, player,
             and c.potioncost == 0],
             msg=_("Select a card that you want to have."), show_supply_count=True)
         if card_cls is not None:
-            new_card = game.supply[card_cls.__name__].pop()
-            player.discard_pile.append(new_card)
-            new_cards = [new_card]
-        else:
-            new_cards = []
+            if game.supply[card_cls.__name__]:
+                new_card = game.supply[card_cls.__name__].pop()
+                player.discard_pile.append(new_card)
+                new_cards = [new_card]
 
         for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,

domination/cards/seaside.py

     def activate_action(self, game, player):
         province_cards = [c for c in player.hand if isinstance(c, Province)]
         if province_cards:
-            new_card = game.supply["Gold"].pop()
-            player.hand.append(new_card)
-            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("Gold"):
-                yield val
+            if game.supply["Gold"]:
+                new_card = game.supply["Gold"].pop()
+                player.hand.append(new_card)
+                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("Gold"):
+                    yield val
         else:
-            new_card = game.supply["Silver"].pop()
-            player.hand.append(new_card)
-            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("Silver"):
-                yield val
+            if game.supply["Silver"]:
+                new_card = game.supply["Silver"].pop()
+                player.hand.append(new_card)
+                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("Silver"):
+                    yield val
 
 
 class FishingVillage(ActionCard, DurationCard):
                             _("%s trashes:", (player.name, )), [card])
             new_cards = []
             for i in range(0, 4):
-                new_cards.append(game.supply["Gold"].pop())
-                for val in game.check_empty_pile("Gold"):
-                    yield val
+                if game.supply["Gold"]:
+                    new_cards.append(game.supply["Gold"].pop())
+                    for val in game.check_empty_pile("Gold"):
+                        yield val
             player.deck.extend(new_cards)
             for info_player in game.participants:
                 yield InfoRequest(game, info_player,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.