Beispiel #1
0
    def activate_action(self, game, player):
        player.remaining_actions += 1
        player.draw_cards(3)
        drawn, player.hand = player.hand[-3:], player.hand[:-3]
        yield InfoRequest(game, player, _("You draw:", ), drawn)

        card_classes = [type(c) for c in drawn]
        card_cls = (yield SelectCard(game,
                                     player,
                                     _("Which card do you want to trash?"),
                                     card_classes=card_classes))
        card = [c for c in drawn if isinstance(c, card_cls)][0]
        drawn.remove(card)
        game.trash_pile.append(card)
        for info_player in game.participants:
            yield InfoRequest(game, info_player,
                              _("%s trashes:", (player.name, )), [card])

        card_classes = [type(c) for c in drawn]
        card_cls = (yield SelectCard(game,
                                     player,
                                     _("Which card do you want to discard?"),
                                     card_classes=card_classes))
        card = [c for c in drawn if isinstance(c, card_cls)][0]
        drawn.remove(card)
        player.discard_pile.append(card)
        for info_player in game.participants:
            yield InfoRequest(game, info_player,
                              _("%s discards:", (player.name, )), [card])

        card_classes = [type(c) for c in drawn]
        card_cls = (yield SelectCard(
            game,
            player,
            _("Which card do you want to put back on deck?"),
            card_classes=card_classes))
        card = [c for c in drawn if isinstance(c, card_cls)][0]
        drawn.remove(card)
        player.deck.append(card)
Beispiel #2
0
 def activate_action(self, game, player):
     money = len(set(card.__name__ for card in player.aux_cards))
     card_cls = yield SelectCard(game, player, card_classes=[c for c in
         game.card_classes.itervalues() if c.cost <= money 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
Beispiel #3
0
 def activate_action(self, game, player):
     trashed = []
     for other_player in game.following_players(player):
         try:
             handle_defense(self, game, other_player)
         except Defended:
             continue
         cards = []
         other_player.draw_cards(2)
         cards.append(other_player.hand.pop())
         cards.append(other_player.hand.pop())
         for info_player in game.participants:
             yield InfoRequest(
                 game, info_player,
                 _("%s reveals the top 2 cards of his deck:",
                   (other_player.name, )), cards[:])
         treasure_cards = [c for c in cards if isinstance(c, TreasureCard)]
         treasure_card_classes = list(set([type(c)
                                           for c in treasure_cards]))
         if treasure_cards:
             card_cls = (yield SelectCard(
                 game,
                 player,
                 _("Which card of the player %s do you want to trash?",
                   (other_player.name, )),
                 card_classes=treasure_card_classes))
             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_participants(player):
                 yield InfoRequest(game, info_player,
                                   _("%s trashes:", (player.name, )),
                                   [card])
         other_player.discard_pile.extend(cards)
     for card in trashed:
         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_participants(player):
                 yield InfoRequest(
                     game, info_player,
                     _("%s picks up this card from trash:",
                       (player.name, )), [card])
         else:
             game.trash_pile.append(card)
Beispiel #4
0
 def gainedthis(self, game, player):
     cards = [
         card for card in player.aux_cards
         if isinstance(card, TreasureCard)
     ]
     for card in cards:
         player.aux_cards.remove(card)
     while cards:
         card_classes = [type(c) for c in cards]
         card_cls = (yield SelectCard(
             game,
             player,
             _("Which card do you want to put on top next?"),
             card_classes=card_classes))
         card = [c for c in cards if isinstance(c, card_cls)][0]
         cards.remove(card)
         player.deck.append(card)
Beispiel #5
0
    def activate_action(self, game, player):
        for other_player in game.following_participants(player):
            revealed_cards = []
            try:
                handle_defense(self, game, other_player)
            except Defended:
                continue
            cost = None
            while cost is None or cost < 3:
                if other_player.draw_cards(1) is None:
                    break
                card = other_player.hand.pop()
                revealed_cards.append(card)
                cost = card.cost
            for info_player in game.participants:
                yield InfoRequest(
                    game, info_player,
                    _("%s reveals these cards:", (other_player.name, )),
                    revealed_cards)
            # last card in revealed cards is the one costing 3 or more
            # except if the deck is empty
            if revealed_cards and revealed_cards[-1].cost >= 3:
                game.trash_pile.append(revealed_cards[-1])

                # gain a card, XXX missing cancel
                card_cls = yield SelectCard(
                    game,
                    other_player,
                    card_classes=[
                        c for c in game.card_classes.itervalues()
                        if c.cost <= revealed_cards[-1].cost -
                        2 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()
                other_player.discard_pile.append(new_card)
                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(card_cls.__name__):
                    yield val
            # We put nearly all cards together onto the discard pile
            other_player.discard_pile.extend(revealed_cards[:-1])
Beispiel #6
0
 def activate_action(self, game, player):
     player.virtual_money += 2
     card_cls = yield SelectCard(
         game,
         player,
         card_classes=[
             c for c in game.card_classes.values()
             if game.supply.get(c.__name__)
         ],
         msg=_("Select a pile to put the Embargo token on."),
         show_supply_count=True)
     for info_player in game.following_participants(player):
         yield InfoRequest(
             game, info_player,
             _("%s puts an Embargo token on top of:", (player.name, )),
             [card_cls])
     game.embargo_markers[card_cls.__name__] = game.embargo_markers.get(
         card_cls.__name__, 0) + 1
Beispiel #7
0
    def on_gain_card(cls, game, player, card):
        if not isinstance(card, BorderVillage):
            return

        card_classes = [
            c for c in game.card_classes.itervalues()
            if c.cost < cls.cost and game.supply.get(c.__name__)
        ]
        card_cls = yield SelectCard(
            game,
            player,
            card_classes=card_classes,
            msg=_("Select a card that you want to have."),
            show_supply_count=True)
        with fetch_card_from_supply(game, card_cls) 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])
Beispiel #8
0
    def activate_action(self, game, player):
        player.remaining_actions += 1
        player.draw_cards(1)

        if not player.hand:
            return
        cards = yield SelectHandCards(
            game,
            player,
            count_lower=0,
            count_upper=1,
            msg=_("Select a card you want to trash."))
        if cards:
            card = cards[0]
            selectable_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
            ]
            new_card = None
            if selectable_card_classes:
                card_cls = yield SelectCard(
                    game,
                    player,
                    card_classes=selectable_card_classes,
                    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)
            card.trash(game, player)

            for info_player in game.following_participants(player):
                yield InfoRequest(game, info_player,
                                  _("%s trashes:", (player.name, )), [card])
                if new_card:
                    yield InfoRequest(game, info_player,
                                      _("%s gains:", (player.name, )),
                                      [new_card])
            if new_card:
                for val in game.check_empty_pile(card_cls.__name__):
                    yield val
Beispiel #9
0
    def activate_action(self, game, player):
        action_cards_found = 0
        shuffled = 0
        found_cards = []
        to_be_discarded = []
        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])
            if isinstance(card, ActionCard) and not isinstance(card, Golem):
                found_cards.append(card)
                action_cards_found += 1
                if action_cards_found == 2:
                    break
            else:
                to_be_discarded.append(card)
        player.discard_pile.extend(to_be_discarded)
        while found_cards:
            card_classes = [type(c) for c in found_cards]
            card_cls = (yield
                        SelectCard(game,
                                   player,
                                   _("Which card do you want to play next?"),
                                   card_classes=card_classes))
            card = [c for c in found_cards if isinstance(c, card_cls)][0]
            found_cards.remove(card)

            player.aux_cards.append(card)
            gen = game.play_action_card(player, card)
            generator_forward(gen)
            if card.trash_after_playing:
                player.aux_cards.remove(card)
                game.trash_pile.append(card)
Beispiel #10
0
    def activate_action(self, game, player):
        if len(player.right(game).cards_gained) > 1:
            card_classes = [
                c for c in player.right(game).cards_gained
                if c.cost <= 6 and game.supply.get(c.__name__)
            ]
            card_cls = yield SelectCard(
                game,
                player,
                card_classes=card_classes,
                msg=_("Select a card that you want to have."),
                show_supply_count=True)
        else:
            card_cls = type(player.right(game).cards_gained[0])
        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
Beispiel #11
0
    def activate_action(self, game, player):
        player.remaining_actions += 2
        card_classes = [
            c for c in game.card_classes.itervalues()
            if c.cost <= 5 and c.potioncost == 0
            and game.supply.get(c.__name__) and issubclass(c, ActionCard)
        ]
        card_cls = yield SelectCard(
            game,
            player,
            card_classes=card_classes,
            msg=_("Select a action card that you want to have."),
            show_supply_count=True)
        if card_cls:
            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
Beispiel #12
0
 def activate_action(self, game, player):
     player.remaining_deals += 1
     card_cls = yield SelectCard(
         game,
         player.left(game),
         card_classes=[
             c for c in game.card_classes.itervalues()
             if game.supply.get(c.__name__)
         ],
         msg=_("Select a card that %(playername)s cannot buy this turn.",
               {"playername": player.name}),
         show_supply_count=True)
     player.prosperity_contraband_cards = getattr(
         player, "prosperity_contraband_cards", []).append(card_cls)
     for info_player in game.following_participants(player):
         yield InfoRequest(
             game, info_player,
             _(
                 "%(player2name)s does not allow %(playername)s to buy:", {
                     "playername": player.name,
                     "player2name": player.left(game).name
                 }), [card_cls])
Beispiel #13
0
    def activate_action(self, game, player):
        player.remaining_actions += 1
        player.draw_cards(4)
        drawn, player.hand = player.hand[-4:], player.hand[:-4]

        for info_player in game.participants:
            yield InfoRequest(
                game, info_player,
                _("%s reveals the top 4 cards of his"
                  " deck:", (player.name, )), drawn)
        victory_cards = [c for c in drawn if isinstance(c, VictoryCard)]
        player.hand.extend(victory_cards)
        drawn = [c for c in drawn if not isinstance(c, VictoryCard)]
        while drawn:
            drawn_classes = [type(c) for c in drawn]
            card_cls = (yield SelectCard(
                game,
                player,
                _("Which card do you want to put onto the deck next?"),
                card_classes=drawn_classes))
            card = [c for c in drawn if isinstance(c, card_cls)][0]
            drawn.remove(card)
            player.deck.append(card)
Beispiel #14
0
    def activate_action(self, game, player):
        new_cards = []
        Forge_money = 0
        if player.hand:
            cards = yield SelectHandCards(
                game, player, msg=_("Which cards do you want to trash?"))
        else:
            return
        # trash cards
        if cards:
            for card in cards:
                Forge_money += card.cost
                card.trash(game, player)
        card_cls = yield SelectCard(
            game,
            player,
            card_classes=[
                c for c in game.card_classes.itervalues()
                if c.cost == Forge_money and game.supply.get(c.__name__)
                and c.potioncost == 0
            ],
            msg=_("Select a card that you want to have."),
            show_supply_count=True)
        if card_cls is not None:
            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,
                              _("%s trashes:", (player.name, )), cards or [])
            yield InfoRequest(game, info_player, _("%s gains:",
                                                   (player.name, )), new_cards)
        if card_cls:
            for val in game.check_empty_pile(card_cls.__name__):
                yield val