Пример #1
0
    def activate_action(self, game, player):
        player.draw_cards(2)
        passed_card = {}
        for other_player in game.players:
            cards = yield SelectHandCards(
                game, other_player, _("Which card do you want to pass left?"),
                None, 1, 1)
            card = cards[0]
            passed_card[other_player.left(game)] = card
            other_player.hand.remove(card)
        for other_player in game.players:
            card = passed_card[other_player]
            yield InfoRequest(game, other_player,
                              _("You gained this card from your right:"),
                              [card])
            other_player.hand.append(card)

        if player.hand:
            cards = yield SelectHandCards(
                game,
                player,
                count_lower=0,
                count_upper=1,
                msg=_("Which card do you want to trash?"))
        # trash cards
        if cards:
            for card in cards:
                card.trash(game, player)
            for other_player in game.following_participants(player):
                yield InfoRequest(game, other_player,
                                  _("%s trashes this card:", (player.name, )),
                                  cards)
Пример #2
0
 def activate_action(self, game, player):
     player.draw_cards(2)
     cards = yield SelectHandCards(
         game,
         player,
         count_lower=0,
         count_upper=None,
         msg=_("Which cards do you want to discard?"))
     # discard cards
     if cards is not None:
         for card in cards:
             card.discard(player)
         player.virtual_money += len(cards)
     for other_player in game.following_players(player):
         cards = yield SelectHandCards(
             game,
             other_player,
             count_lower=0,
             count_upper=2,
             msg=_("%s played Vault. Which cards do you want to discard?",
                   (player.name, )))
         if cards is not None:
             for card in cards:
                 card.discard(other_player)
             for info_player in game.participants:
                 if info_player is not other_player:
                     # TODO: info players may only see one of the discarded cards
                     yield InfoRequest(
                         game, info_player,
                         _("%s discards these cards:",
                           (other_player.name, )), cards)
             if len(cards) == 2:
                 other_player.draw_cards(1)
Пример #3
0
 def activate_action(self, game, player):
     player.virtual_money += 1
     player.tokens += 1
     if player.hand:
         cards = yield SelectHandCards(
             game,
             player,
             count_lower=0,
             count_upper=1,
             msg=_("Select a card you want to trash."))
         if cards:
             card = cards[0]
             player.tokens += card.cost / 2
             card.trash(game, player)
             for info_player in game.following_participants(player):
                 yield InfoRequest(game, info_player,
                                   _("%s trashes:", (player.name, )),
                                   [card])
     for other_player in game.following_players(player):
         cards = yield SelectHandCards(
             game,
             other_player,
             count_lower=0,
             count_upper=1,
             msg=_("%s played Bishop. You may trash a card:",
                   (player.name, )))
         if cards:
             for card in cards:
                 card.trash(game, other_player)
                 for info_player in game.following_participants(
                         other_player):
                     yield InfoRequest(
                         game, info_player,
                         _("%s trashes:", (other_player.name, )), cards)
Пример #4
0
 def defends_check(self, game, other_player):
     from domination.gameengine import InfoRequest, SelectHandCards
     already_selected = set()
     while True:
         for c in other_player.aux_cards:
             if hasattr(c, "process_defense"):
                 c.process_defense(game, other_player, self)
         if not any(isinstance(c, ReactionCard) for c in other_player.hand):
             break
         req = SelectHandCards(
             game, other_player, count_lower=0, count_upper=1, cls=ReactionCard,
             msg=_("Do you want to flash a card in response to the attack?"),
             not_selectable=already_selected)
         if not req.fulfillable():
             break
         cards = yield req
         if cards:
             card = cards[0]
             already_selected.add(card)
             # notify other players
             for info_player in game.following_participants(other_player):
                 yield InfoRequest(
                     game, info_player,
                     _("%s reacts with:", (other_player.name, )), [card])
             gen = card.defend_action(game, other_player, self)
             item = None
             while True:
                 try:
                     # this can raise Defended if the attack has been defended
                     item = (yield gen.send(item))
                 except StopIteration:
                     break
         else:
             break
Пример #5
0
 def activate_action(self, game, player):
     player.remaining_deals += 1
     player.virtual_money += 2
     for other_player in game.following_players(player):
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         count = len(other_player.hand) - 3
         if count <= 0:
             continue
         cards = yield SelectHandCards(
             game,
             other_player,
             count_lower=count,
             count_upper=count,
             msg=_("%s played Goons. Which cards do you want to discard?",
                   (player.name, )))
         for card in cards:
             card.discard(other_player)
         for info_player in game.following_participants(player):
             # TODO: info players may only see one of the discarded cards
             yield InfoRequest(
                 game, info_player,
                 _("%s discards these cards:", (other_player.name, )),
                 cards)
Пример #6
0
 def activate_action(self, game, player):
     cards = yield SelectHandCards(
         game,
         player,
         cls=TreasureCard,
         count_lower=0,
         count_upper=1,
         msg=
         _("Select a treasure card you want to convert to a potentially better card."
           ))
     if cards:
         card = cards[0]
         new_cards = []
         for i in range(0, 4):
             if game.supply["Silver"]:
                 new_cards.append(game.supply["Silver"].pop())
                 for val in game.check_empty_pile("Silver"):
                     yield val
         card.trash(game, player)
         player.hand.append(new_card)
         for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                               _("%s trashes:", (player.name, )), [card])
             yield InfoRequest(game, info_player,
                               _("%s gains:", (player.name, )), new_cards)
Пример #7
0
 def activate_action(self, game, player):
     cards = yield SelectHandCards(
         game,
         player,
         cls=TreasureCard,
         count_lower=0,
         count_upper=1,
         msg=
         _("Select a treasure card you want to convert to a potentially better card."
           ))
     if cards:
         card = cards[0]
         card_classes = [
             c for c in game.card_classes.itervalues()
             if c.cost <= card.cost + 3 and game.supply.get(c.__name__)
             and issubclass(c, TreasureCard)
         ]
         card_cls = yield SelectCard(
             game,
             player,
             card_classes=card_classes,
             msg=_("Select a treasure card that you want to have."),
             show_supply_count=True)
         card.trash(game, player)
         new_card = game.supply[card_cls.__name__].pop()
         player.hand.append(new_card)
         for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                               _("%s trashes:", (player.name, )), [card])
             yield InfoRequest(game, info_player,
                               _("%s gains:", (player.name, )), [new_card])
         for val in game.check_empty_pile(card_cls.__name__):
             yield val
Пример #8
0
    def activate_action(self, game, player):
        with fetch_card_from_supply(game, Silver) as new_card:
            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])
        player.draw_cards(1)
        drawn, player.hand = player.hand[-1:], player.hand[:-1]
        if (yield YesNoQuestion(
                game, player,
                _("Do you want to keep the card '%s' on your hand?",
                  (drawn[0].name, )))):
            player.hand.extend(drawn)
        else:
            player.discard_pile.extend(drawn)

        while len(player.hand) < 5:
            if player.draw_cards(1) is None:
                break

        #FIXME only cards that are no treasure
        cards = yield SelectHandCards(
            game,
            player,
            count_lower=0,
            count_upper=1,
            not_selectable=[
                c for c in player.hand if isinstance(c, TreasureCard)
            ],
            msg=_("Select a card you want to trash."))
        if cards:
            card = cards[0]
            card.trash(game, player)
Пример #9
0
 def boughtthis(self, game, player):
     cards = yield SelectHandCards(
         game,
         player,
         count_lower=0,
         count_upper=1,
         msg=
         _("Select a card you want to convert to a 2 Money more expensive Card."
           ))
     if cards:
         card = cards[0]
         card_classes = [
             c for c in game.card_classes.itervalues()
             if c.cost == card.cost + 2 and game.supply.get(c.__name__)
         ]
         card_cls = yield SelectCard(
             game,
             player,
             card_classes=card_classes,
             msg=_("Select a treasure card that you want to have."),
             show_supply_count=True)
         card.trash(game, player)
         new_card = game.supply[card_cls.__name__].pop()
         player.hand.append(new_card)
         for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                               _("%s trashes:", (player.name, )), [card])
             yield InfoRequest(game, info_player,
                               _("%s gains:", (player.name, )), [new_card])
         for val in game.check_empty_pile(card_cls.__name__):
             yield val
Пример #10
0
 def activate_action(self, game, player):
     player.draw_cards(3)
     player.remaining_deals += 1
     for other_player in game.following_players(player):
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         other_player.draw_cards(1)
         if len(other_player.hand) < 4:
             continue
         count = len(other_player.hand) - 3
         if count <= 0:
             continue
         cards = yield SelectHandCards(
             game,
             other_player,
             count_lower=count,
             count_upper=count,
             msg=_(
                 "%s played Margrave, you need to discard your hand down to three cards. Which cards do you want to discard?",
                 (player.name, )))
         for card in cards:
             card.discard(other_player)
         for info_player in game.participants:
             if info_player is not other_player:
                 # TODO: info players may only see one of the discarded cards
                 yield InfoRequest(
                     game, info_player,
                     _("%s discards these cards:", (other_player.name, )),
                     cards)
Пример #11
0
 def activate_action(self, game, player):
     if player.hand:
         cards = yield SelectHandCards(
             game,
             player,
             count_lower=2,
             count_upper=2,
             msg=_("Which cards do you want to trash?"))
     else:
         return
     # trash cards
     for card in cards:
         card.trash(game, player)
     for info_player in game.following_participants(player):
         yield InfoRequest(game, info_player,
                           _("%s trashes these cards:", (player.name, )),
                           cards)
     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
Пример #12
0
    def activate_action(self, game, player):
        cards = yield SelectHandCards(
            game,
            player,
            cls=TreasureCard,
            count_lower=0,
            count_upper=1,
            msg=_("Select a treasure card you want to trash."))
        if cards:
            card = cards[0]
            card.trash(game, player)
            for info_player in game.following_participants(player):
                yield InfoRequest(game, info_player,
                                  _("%s trashes:", (player.name, )), [card])
            actions = [("cards_action", _("+2 Cards +1 Action")),
                       ("moneys_buy", _("+2 Money +1 Buy"))]

            answer = yield Question(game, player,
                                    _("What do you want to get?"), actions)

            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])
                    }), [])

            if answer == "cards_action":
                player.draw_cards(2)
                player.remaining_actions += 1
            else:
                player.virtual_money += 2
                player.remaining_deals += 1
Пример #13
0
 def activate_action(self, game, player):
     silver_cards = game.supply["Silver"]
     if silver_cards:
         player.deck.append(silver_cards.pop())
         for val in game.check_empty_pile("Silver"):
             yield val
     for other_player in game.following_players(player):
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         victory_cards = [
             c for c in other_player.hand if isinstance(c, VictoryCard)
         ]
         if victory_cards:
             card = (yield SelectHandCards(
                 game, other_player,
                 _("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_participants(other_player):
                 yield InfoRequest(
                     game, info_player,
                     _("%s reveals a card:", (other_player.name, )), [card])
         else:
             for info_player in game.following_participants(other_player):
                 yield InfoRequest(
                     game, info_player,
                     _("%s reveals his hand:", (other_player.name, )),
                     other_player.hand)
Пример #14
0
    def activate_action(self, game, player):
        player.draw_cards(2)
        curse_cards = game.supply["Curse"]
        for other_player in game.following_players(player):
            try:
                handle_defense(self, game, other_player)
            except Defended:
                continue
            if curse_cards:
                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

            count = len(other_player.hand) - 3
            if count <= 0:
                continue
            cards = yield SelectHandCards(game, other_player, count_lower=count, count_upper=count,
                    msg=_("%s played Followers. Which cards do you want to discard?", (player.name, )))
            for card in cards:
                card.discard(other_player)
            for info_player in game.participants:
                if info_player is not other_player:
                    # TODO: info players may only see one of the discarded cards
                    yield InfoRequest(game, info_player,
                            _("%s discards these cards:", (other_player.name, )), cards)
Пример #15
0
    def activate_action(self, game, player):
        for i in range(0,2):
            cards = yield SelectHandCards(game, player,
                        count_lower=1, count_upper=1,
                        msg=_("Select a card you want to trash."))
            if cards:
                card = cards[0]
                card_classes = [c for c in game.card_classes.itervalues()
                                if c.cost == card.cost + 1 and
                                game.supply.get(c.__name__) and
                                c.potioncost == card.potioncost]

                card.trash(game, player)
                if card_classes:
                    card_cls = yield SelectCard(game, player, card_classes=card_classes,
                        msg=_("Select a treasure card that you want to have."), show_supply_count=True)
                    new_card = game.supply[card_cls.__name__].pop()
                    player.hand.append(new_card)
                    for info_player in game.following_participants(player):
                        yield InfoRequest(game, info_player,
                                _("%s trashes:", (player.name, )), [card])
                        yield InfoRequest(game, info_player,
                                _("%s gains:", (player.name, )), [new_card])
                    for val in game.check_empty_pile(card_cls.__name__):
                        yield val
Пример #16
0
 def activate_action(self, game, player):
     if player.hand:
         cards = yield SelectHandCards(
             game,
             player,
             count_lower=1,
             count_upper=1,
             msg=_("Which card do you want to Ambassador?"))
         card = cards[0]
         samecards = [c for c in player.hand if isinstance(c, type(card))]
         if len(samecards) >= 2:
             for info_player in game.participants:
                 yield InfoRequest(game, info_player,
                                   _("%s reveals:", (player.name, )),
                                   [samecards[0]])
             for i in range(2):
                 player.hand.remove(samecards[i])
                 game.supply[samecards[i].__name__].append(samecards[i])
             new_cards = game.supply[samecards[0].__name__]
             for other_player in game.following_players(player):
                 try:
                     handle_defense(self, game, other_player)
                 except Defended:
                     continue
                 if new_cards:
                     newcard = new_cards.pop()
                     yield InfoRequest(
                         game, other_player,
                         _("%s ambassadors you. You gain a card:",
                           (player.name, )), [newcard])
                     other_player.discard_pile.append(newcard)
                     for val in game.check_empty_pile(
                             samecards[0].__name__):
                         yield val
Пример #17
0
 def activate_action(self, game, player):
     player.virtual_money += 2
     for other_player in game.following_players(player):
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         copper_cards = [
             c for c in other_player.hand if isinstance(c, Copper)
         ]
         if copper_cards:
             cards = yield SelectHandCards(
                 game,
                 other_player,
                 count_lower=1,
                 count_upper=1,
                 msg=_(
                     "%s played Cutpurse. Which Copper do you want to discard?",
                     (player.name, )),
                 cls=Copper)
             for card in cards:
                 card.discard(other_player)
                 for info_player in game.following_participants(
                         other_player):
                     yield InfoRequest(
                         game, info_player,
                         _("%s discards these cards:",
                           (other_player.name, )), cards)
         else:
             for info_player in game.following_participants(player):
                 yield InfoRequest(
                     game, info_player,
                     _("%s reveals his hand:", (other_player.name, )),
                     other_player.hand[:])
Пример #18
0
 def activate_action(self, game, player):
     player.draw_cards(3)
     cards = yield SelectHandCards(
         game,
         player,
         count_upper=1,
         msg=_("Select a card to put on your deck."))
     if cards:
         card = cards[0]
         player.deck.append(card)
         player.hand.remove(card)
Пример #19
0
 def activate_action(self, game, player):
     player.virtual_money += 3
     cards = yield SelectHandCards(
         game,
         player,
         count_lower=1,
         count_upper=1,
         msg=_("Which card do you want to put on top of your deck?"))
     if cards:
         card = cards[0]
         player.deck.append(card)
         player.hand.remove(card)
Пример #20
0
 def defend_action(self, game, player, card):
     player.draw_cards(2)
     cards = yield SelectHandCards(
         game,
         player,
         count_lower=2,
         count_upper=2,
         msg=_("Which cards do you want to put on your deck?"))
     if not cards:
         return
     for card in cards:
         card.backondeck(game, player)
Пример #21
0
 def activate_action(self, game, player):
     cards = yield SelectHandCards(
         game, player, msg=_("Which cards do you want to discard?"))
     if not cards:
         return
     player.virtual_money += len(cards)
     for card in cards:
         card.discard(player)
     for info_player in game.following_participants(player):
         yield InfoRequest(game, info_player,
                           _("%s discards these cards:", (player.name, )),
                           cards)
Пример #22
0
 def activate_action(self, game, player):
     player.draw_cards(2)
     cards = yield SelectHandCards(game, player, count_lower=2, count_upper=2,
             msg=_("Which two cards do you want to discard?"))
     # discard cards
     if cards is not None:
         for card in cards:
             card.discard(player)
         for info_player in game.participants:
             if info_player is not player:
                 yield InfoRequest(game, info_player,
                         _("%s discards these cards:", (player.name, )), cards)
Пример #23
0
 def handle_discard_action(p):
     cards = yield SelectHandCards(
         game,
         player,
         cls=TreasureCard,
         count_lower=0,
         count_upper=1,
         msg=_(
             "Which treasure do you want to put on top of your deck?"))
     if cards:
         card = cards[0]
         player.deck.append(card)
         player.hand.remove(card)
Пример #24
0
 def activate_action(self, game, player):
     if not hasattr(player, "seaside_haven_set_aside_cards"):
         player.seaside_haven_set_aside_cards = []
     player.remaining_actions += 1
     player.draw_cards(1)
     if player.hand:
         cards = yield SelectHandCards(
             game,
             player,
             count_lower=1,
             count_upper=1,
             msg=_("Which card do you want to set aside?"))
         if cards:
             card = cards[0]
             player.hand.remove(card)
             player.seaside_haven_set_aside_cards.append(card)
Пример #25
0
 def activate_action(self, game, player):
     cards = yield SelectHandCards(
         game,
         player,
         count_lower=1,
         count_upper=1,
         msg=_(
             "Select a card you want to trash for a better and a worse card."
         ))
     new_cards = []
     if cards:
         card = cards[0]
         card_classes = [
             c for c in game.card_classes.itervalues()
             if c.cost == card.cost + 1 and game.supply.get(c.__name__)
         ]
         if card_classes:
             card_cls = yield SelectCard(
                 game,
                 player,
                 card_classes=card_classes,
                 msg=_("Select a card that you want to have."),
                 show_supply_count=True)
             new_cards.append(game.supply[card_cls.__name__].pop())
             for val in game.check_empty_pile(card_cls.__name__):
                 yield val
         card_classes = [
             c for c in game.card_classes.itervalues()
             if c.cost == card.cost - 1 and game.supply.get(c.__name__)
         ]
         if card_classes:
             card_cls = yield SelectCard(
                 game,
                 player,
                 card_classes=card_classes,
                 msg=_("Select a card that you want to have."),
                 show_supply_count=True)
             new_cards.append(game.supply[card_cls.__name__].pop())
             for val in game.check_empty_pile(card_cls.__name__):
                 yield val
         card.trash(game, player)
         player.deck.extend(new_cards)
         for info_player in game.following_participants(player):
             yield InfoRequest(game, info_player,
                               _("%s trashes:", (player.name, )), [card])
             yield InfoRequest(game, info_player,
                               _("%s gains:", (player.name, )), new_cards)
Пример #26
0
    def activate_action(self, game, player):
        player.draw_cards(3)
        for other_player in game.following_players(player):
            try:
                handle_defense(self, game, other_player)
            except Defended:
                continue
            choices = [("discard", _("discard 2 cards")),
                       ("curse", _("gain a Curse"))]
            choice = yield Question(game, other_player,
                                    _("What do you want to do?"), choices)

            for info_player in game.following_participants(player):
                yield InfoRequest(
                    game, info_player,
                    _("%(player)s choose to '%(action)s'", {
                        "player": other_player.name,
                        "action": choice
                    }), [])

            if choice == "discard":
                cards = yield SelectHandCards(
                    game,
                    other_player,
                    count_lower=2,
                    count_upper=2,
                    msg=_(
                        "%s played Torturer, you chose to discard two cards. Which cards do you want to discard?",
                        (player.name, )))
                for card in cards:
                    card.discard(other_player)
                for info_player in game.participants:
                    if info_player is not other_player:
                        # TODO: info players may only see one of the discarded cards
                        yield InfoRequest(
                            game, info_player,
                            _("%s discards these cards:",
                              (other_player.name, )), cards)
            elif choice == "curse":
                with fetch_card_from_supply(game, Curse) as new_card:
                    other_player.discard_pile.append(new_card)
                for info_player in game.following_participants(other_player):
                    yield InfoRequest(
                        game, info_player,
                        _("%s tortures %s. He gains a curse card.",
                          (player.name, other_player.name)), [])
Пример #27
0
 def activate_action(self, game, player):
     player.draw_cards(1)
     player.remaining_actions += 1
     cards = yield SelectHandCards(game, player, count_lower=0, count_upper=2,
             msg=_("Which cards do you want to discard?"))
     # discard cards
     if cards is not None:
         cardcount = len(cards)
         for card in cards:
             card.discard(player)
         for info_player in game.participants:
             if info_player is not player:
                 yield InfoRequest(game, info_player, _("%s discards these cards:", (player.name, )), cards)
         if cardcount >= 1:
             player.remaining_actions += 1
         if cardcount >= 2:
             player.remaining_deals += 1
Пример #28
0
 def activate_action(self, game, player):
     player.remaining_actions += 1
     player.draw_cards(3)
     cards = yield SelectHandCards(
         game,
         player,
         count_lower=3,
         count_upper=3,
         msg=_("Which 3 cards do you want to discard?"))
     # discard cards
     if cards is not None:
         for card in cards:
             card.discard(player)
         for info_player in game.following_participants(player):
             yield InfoRequest(
                 game, info_player,
                 _("%s discards these cards:", (player.name, )), cards)
Пример #29
0
 def activate_action(self, game, player):
     if not hasattr(player, "seaside_island_set_aside_cards"):
         player.seaside_island_set_aside_cards = []
     island_cards = [c for c in player.aux_cards if isinstance(c, Island)]
     player.seaside_island_set_aside_cards.append(island_cards[0])
     player.aux_cards.remove(island_cards[0])
     if player.hand:
         cards = yield SelectHandCards(
             game,
             player,
             count_lower=1,
             count_upper=1,
             msg=_("Which card do you want to set aside?"))
         if cards:
             card = cards[0]
             player.hand.remove(card)
             player.seaside_island_set_aside_cards.append(card)
Пример #30
0
    def activate_action(self, game, player):
        player.remaining_deals += 1
        player.virtual_money += 1  #FIXME
        if not player.hand:
            return
        cards = yield SelectHandCards(
            game,
            player,
            count_lower=1,
            count_upper=1,
            msg=_("Select a card you want to trash."))
        if cards:
            card = cards[0]
            card.trash(game, player)

            for info_player in game.following_participants(player):
                yield InfoRequest(game, info_player,
                                  _("%s trashes:", (player.name, )), [card])