Beispiel #1
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)
Beispiel #2
0
 def activate_action(self, game, player):
     player.draw_cards(3)
     to_be_discarded = []
     for other_player in game.following_players(player):
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         other_player.draw_cards(3)
         drawn, other_player.hand = other_player.hand[
             -3:], other_player.hand[:-3]
         for info_player in game.participants:
             yield InfoRequest(
                 game, info_player,
                 _("%s reveals the top card of his deck:",
                   (other_player.name, )), drawn)
         for card in drawn:
             if isinstance(card, TreasureCard) or isinstance(
                     card, ActionCard):
                 to_be_discarded.append(card)
         for info_player in game.participants:
             yield InfoRequest(game, info_player,
                               _("%s discards:", (other_player.name, )),
                               to_be_discarded)
         other_player.discard_pile.extend(to_be_discarded)
Beispiel #3
0
 def activate_action(self, game, player):
     player.draw_cards(1)
     player.remaining_actions += 1
     for other_player in game.players:
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         other_player.draw_cards(1)
         card = other_player.hand.pop()
         for info_player in game.participants:
             yield InfoRequest(
                 game, info_player,
                 _("%s reveals the top card of his deck:",
                   (other_player.name, )), [card])
         if (yield YesNoQuestion(
                 game, player,
                 _("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_participants(player):
                 yield InfoRequest(
                     game, info_player,
                     _(
                         "%(playername)s discarded %(player2name)s's card:",
                         {
                             "playername": player.name,
                             "player2name": other_player.name
                         }), [card])
         else:
             other_player.deck.append(card)
Beispiel #4
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
            if other_player.draw_cards(1) is None:
                continue
            card = other_player.hand.pop()
            for info_player in game.participants:
                yield InfoRequest(game, info_player,
                                  _("%s trashes:", (other_player.name, )),
                                  [card])

            req = SelectCard(
                game,
                player,
                card_classes=[
                    c for c in game.card_classes.itervalues()
                    if c.cost == card.cost and game.supply.get(c.__name__)
                ],
                msg=_("Select a card that you want to give."),
                show_supply_count=True)
            if not req.fulfillable():
                continue
            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_participants(player):
                yield InfoRequest(game, info_player,
                                  _("%s gains:", (other_player.name, )),
                                  [new_card])
            for val in game.check_empty_pile(card_cls.__name__):
                yield val
Beispiel #5
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)
Beispiel #6
0
    def activate_action(self, game, player):
        player.draw_cards(1)
        player.remaining_actions += 1
        card_cls = yield SelectCard(
            game,
            player,
            card_classes=[
                c for c in game.card_classes.itervalues()
                if c.__name__ in game.supply
            ],
            msg=_("Name a card."),
            show_supply_count=True)

        for info_player in game.following_participants(player):
            yield InfoRequest(game, info_player,
                              _("%s names:", (player.name, )), [card_cls])
        player.draw_cards(1)
        card = player.hand.pop()
        for info_player in game.participants:
            yield InfoRequest(game, info_player,
                              _("%s reveals:", (player.name, )), [card])
        if isinstance(card, card_cls):
            player.hand.append(card)
        else:
            player.deck.append(card)
Beispiel #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
Beispiel #8
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
Beispiel #9
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
Beispiel #10
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[:])
Beispiel #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
Beispiel #12
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
Beispiel #13
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)
Beispiel #14
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)
Beispiel #15
0
    def activate_action(self, game, player):
        for any_player in game.all_players(player):
            any_player.draw_cards(2)
            drawn, any_player.hand = any_player.hand[-2:], any_player.hand[:-2]
            for info_player in game.participants:
                yield InfoRequest(game, info_player,
                                  _("%s reveals:", (any_player.name, )), drawn)

            actions = [("discard", _("Discard the cards")),
                       ("backontop",
                        _("Put the cards back on top of your deck"))]

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

            for info_player in game.following_participants(any_player):
                yield InfoRequest(
                    game, info_player,
                    _(
                        "%(player)s chooses '%(action)s' for %(playertarget)s",
                        {
                            "player": player.name,
                            "playertarget": any_player.name,
                            "action": _(dict(actions)[answer])
                        }), [])

            if answer == "discard":
                any_player.discard_pile.extend(drawn)
            else:
                any_player.deck.extend(drawn)  # XXX "in an order he chooses!"
        player.draw_cards(2)
Beispiel #16
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)
Beispiel #17
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
Beispiel #18
0
    def activate_action(self, game, player):
        player.virtual_money += 2
        player.draw_cards(5)
        drawn, player.hand = player.hand[-5:], player.hand[:-5]
        for info_player in game.following_participants(player):
            yield InfoRequest(game, info_player, _("%s draws:",
                                                   (player.name, )), drawn)
        yield InfoRequest(game, player, _("You draw:", ), drawn)
        actions = [("discard", _("discard all 5 cards")),
                   ("backondeck",
                    _("put the cards back in your specified order"))]

        answer = yield Question(game, player, _("What do you want to do?"),
                                actions)
        if answer == "discard":
            player.discard_pile.extend(drawn)
        else:
            while drawn:
                card_classes = [type(c) for c in drawn]
                card_cls = (yield SelectCard(
                    game,
                    player,
                    _("Which card do you want to put back?"),
                    card_classes=card_classes))
                card = [c for c in drawn if isinstance(c, card_cls)][0]
                drawn.remove(card)
                player.discard_pile.append(card)
Beispiel #19
0
 def activate_action(self, game, player):
     player.draw_cards(5)
     drawn, player.hand = player.hand[-5:], player.hand[:-5]
     for info_player in game.participants:
         yield InfoRequest(
             game, info_player,
             _("%s reveals the top 5 cards of his deck:", (player.name, )),
             drawn)
     card_classes = [type(c) for c in drawn]
     card_cls = yield SelectCard(
         game,
         player.left(game),
         card_classes=card_classes,
         msg=_("Select a card that %(playername)s should discard.",
               {"playername": player.name}),
         show_supply_count=False)
     for info_player in game.participants:
         yield InfoRequest(
             game, info_player,
             _(
                 "%(player2name)s does not allow %(player2name)s's to buy:",
                 {
                     "playername": player.name,
                     "player2name": player.left(game).name
                 }), [card_cls])
Beispiel #20
0
    def action(self, game, player):
        for other_player in game.following_players(player):
            other_player.draw_cards(2)
            drawn, other_player.hand = other_player.hand[
                -2:], other_player.hand[:-2]
            for info_player in game.participants:
                yield InfoRequest(
                    game, info_player,
                    _("%s reveals the top two cards of his deck:",
                      (other_player.name, )), drawn)

            silver_gold_platinum_cards = [
                c for c in drawn if isinstance(c, Silver)
                or isinstance(c, Gold) or isinstance(c, Platinum)
            ]
            if silver_gold_platinum_cards:
                for card in silver_gold_platinum_cards:
                    drawn.remove(card)
                    other_player.discard_pile.append(card)
                for card in drawn:
                    if (yield YesNoQuestion(
                            game, player,
                            _(
                                "Do you want to trash %(name)s's card '%(cardname)s'?",
                                {
                                    "cardname": card.name,
                                    "name": other_player.name
                                }))):
                        player.discard_pile.append(card)
                        for info_player in game.following_participants(player):
                            yield InfoRequest(
                                game, info_player,
                                _(
                                    "%(playername)s trashes %(player2name)s's card:",
                                    {
                                        "playername": player.name,
                                        "player2name": other_player.name
                                    }), [card])
                    else:
                        other_player.discard_pile.append(card)
            else:
                copper_cards = game.supply["Copper"]
                if copper_cards:
                    other_player.discard_pile.append(copper_cards.pop())
                    new_card = copper_cards.pop()
                    for info_player in game.following_participants(
                            other_player):
                        yield InfoRequest(
                            game, info_player,
                            _("%s gains:", (other_player.name, )), [new_card])
                    for val in game.check_empty_pile("Copper"):
                        yield val
Beispiel #21
0
    def activate_action(self, game, player):
        player.remaining_actions += 1
        actions = [("money", _("+2 Money")),
                   ("cards",
                    _("Discard hand and draw 4 cards, "
                      "attack other players"))]
        answer = yield Question(game, player, _("What do you want to do?"),
                                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 == "money":
            player.virtual_money += 2
        else:
            original_hand = player.hand[:]
            for card in original_hand:
                card.discard(player)
            player.draw_cards(4)
            for info_player in game.following_participants(player):
                yield InfoRequest(
                    game, info_player,
                    _("%s discards this hand and draws 4 cards:",
                      (player.name, )), original_hand)

            for other_player in game.following_players(player):
                if len(other_player.hand) < 5:
                    continue
                try:
                    handle_defense(self, game, other_player)
                except Defended:
                    continue
                original_hand = other_player.hand[:]
                for card in original_hand:
                    card.discard(other_player)
                other_player.draw_cards(4)
                yield InfoRequest(game, other_player,
                                  _("You discard your hand and draw 4 cards."),
                                  [])
                for info_player in game.following_participants(other_player):
                    yield InfoRequest(
                        game, info_player,
                        _("%s discards this hand and draws 4 cards:",
                          (other_player.name, )), original_hand)
Beispiel #22
0
    def activate_action(self, game, player):
        player.remaining_actions += 1
        for other_player in game.players:
            try:
                handle_defense(self, game, other_player)
            except Defended:
                continue
            other_player.draw_cards(1)
            card = other_player.hand.pop()
            for info_player in game.participants:
                yield InfoRequest(
                    game, info_player,
                    _("%s reveals the top card of his deck:",
                      (other_player.name, )), [card])
            if (yield YesNoQuestion(
                    game, player,
                    _("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_participants(player):
                    yield InfoRequest(
                        game, info_player,
                        _(
                            "%(playername)s discarded %(player2name)s's card:",
                            {
                                "playername": player.name,
                                "player2name": other_player.name
                            }), [card])
            else:
                other_player.deck.append(card)

        shuffled = 0
        while True:
            ret = player.draw_cards(1)
            if ret is None:  # no cards left
                break
            shuffled += ret
            if shuffled == 2:  # we shuffled our discard_pile 2 times, abort
                break
            card = player.hand.pop()
            for info_player in game.participants:
                yield InfoRequest(game, info_player,
                                  _("%s reveals:", (player.name, )), [card])
            player.hand.append(card)
            if not isinstance(card, ActionCard):
                break
Beispiel #23
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
         found_cards = []
         to_be_discarded = []
         shuffled = 0
         while True:
             ret = other_player.draw_cards(1)
             if ret is None: # no cards left
                 break
             shuffled += ret
             if shuffled == 2: # we shuffled our discard_pile 2 times, abort
                 break
             card = other_player.hand.pop()
             if isinstance(card, VictoryCard) or isinstance(card, Curse):
                 found_cards.append(card)
                 break
             else:
                 to_be_discarded.append(card)
         for info_player in game.participants:
             yield InfoRequest(game, info_player, _("%s reveals:", (other_player.name, )), to_be_discarded+found_cards)
         other_player.discard_pile.extend(to_be_discarded)
         other_player.deck.extend(found_cards)
Beispiel #24
0
    def activate_action(self, game, player):
        # copied from Feast
        card_cls = yield SelectCard(
            game,
            player,
            card_classes=[
                c for c in game.card_classes.itervalues() if c.cost <= 4
                and game.supply.get(c.__name__) and c.potioncost == 0
            ],
            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_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 issubclass(card_cls, ActionCard):
            player.remaining_actions += 1
        if issubclass(card_cls, TreasureCard):
            player.virtual_money += 1
        if issubclass(card_cls, VictoryCard):
            player.draw_cards(1)
Beispiel #25
0
 def activate_action(self, game, player):
     player.remaining_actions += 1
     others_revealed = False
     player_revealed = False
     for other_player in game.all_players(player):
         province_cards = [c for c in other_player.hand if isinstance(c, Province)]
         if province_cards:
             card = province_cards[0]
             reply = (yield YesNoQuestion(game, other_player,
                 _("Do you want to reveal a Province card from your hand?")))
             if reply:
                 if other_player is player:
                     player_revealed = True
                     card.discard(player)
                     card_cls = (yield SelectCard(game, player, _("Which prize card do you want to gain?"),
                         [type(c) for c in game.tournament_cards] + [Duchy]))
                     if card_cls is Duchy:
                         with fetch_card_from_supply(game, card_cls) as new_card:
                             card = new_card
                     else:
                         card = [c for c in game.tournament_cards if isinstance(c, card_cls)][0]
                         game.tournament_cards.remove(card)
                     player.deck.append(card)
                 else:
                     others_revealed = True
                 for info_player in game.following_participants(other_player):
                     yield InfoRequest(game, info_player, _("%s reveals a card:", (other_player.name, )), [card])
     if not others_revealed:
         player.virtual_money += 1
         player.draw_cards(1)
Beispiel #26
0
    def activate_action(self, game, player):
        choices = [("card", _("+1 Card")), ("action", _("+1 Action")),
                   ("buy", _("+1 Buy")), ("money", _("+1 Money"))]
        while True:
            choice = yield MultipleChoice(game, player, _("Choose two:"),
                                          choices, 2, 2)
            if len(choice) == 2:
                break

        for info_player in game.following_participants(player):
            chosen = ", ".join(_(dict(choices)[c]) for c in choice)
            yield InfoRequest(
                game, info_player,
                _("%(player)s chooses '%(action)s'", {
                    "player": player.name,
                    "action": chosen
                }), [])

        for item in choice:
            if item == "card":
                player.draw_cards(1)
            elif item == "action":
                player.remaining_actions += 1
            elif item == "buy":
                player.remaining_deals += 1
            elif item == "money":
                player.virtual_money += 1
Beispiel #27
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)
Beispiel #28
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)
Beispiel #29
0
 def activate_action(self, game, player):
     player.remaining_actions += 1
     player.draw_cards(1)
     player.draw_cards(4)
     player.hand, new_cards = player.hand[:-4], player.hand[-4:]
     for info_player in game.participants:
         yield InfoRequest(game, info_player,
                           _("%s reveals:", (player.name, )), new_cards)
     copper_and_potions = [
         c for c in new_cards if isinstance(c, (Copper, Potion))
     ]
     remaining_cards = [
         c for c in new_cards if not isinstance(c, (Copper, Potion))
     ]
     player.hand.extend(copper_and_potions)
     while remaining_cards:
         card_classes = [type(c) for c in remaining_cards]
         card_cls = (yield SelectCard(
             game,
             player,
             _("Which card do you want to put onto your deck next?"),
             card_classes=card_classes))
         card = [c for c in remaining_cards if isinstance(c, card_cls)][0]
         remaining_cards.remove(card)
         player.deck.append(card)
Beispiel #30
0
    def activate_action(self, game, player):
        if not hasattr(player, "seaside_nativevillage_set_aside_cards"):
            player.seaside_nativevillage_set_aside_cards = []
        player.remaining_actions += 2
        actions = [("setaside", _("Set aside a card on the Native Village")),
                   ("return",
                    _("Put all cards from the Native Village into your hand."))
                   ]

        answer = yield Question(game, player, _("What do you want to do?"),
                                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 == "setaside":
            player.draw_cards(1)
            drawn, player.hand = player.hand[-1:], player.hand[:-1]
            player.seaside_nativevillage_set_aside_cards.extend(drawn)
        elif answer == "return":
            if getattr(player, "seaside_nativevillage_set_aside_cards", None):
                player.hand.extend(
                    player.seaside_nativevillage_set_aside_cards)
                player.seaside_nativevillage_set_aside_cards = []