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)
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)
def on_buy_card(cls, game, player, card): for i in xrange(game.embargo_markers.get(card.__name__, 0)): with fetch_card_from_supply(game, Curse) as new_card: player.discard_pile.append(new_card) for info_player in game.participants: yield InfoRequest( game, info_player, _("%s gains a Curse card.", (player.name, )), [])
def on_buy_card(cls, game, player, card): for c in player.aux_cards: if isinstance(c, Talisman): if not isinstance(card, VictoryCard) and card.cost <= 4: with fetch_card_from_supply(game, type(card)) as new_card: player.discard_pile.append(new_card) for info_player in game.participants: yield InfoRequest( game, info_player, _( "%s gains another card (because of Talisman):", (player.name, )), [new_card])
def activate_action(self, game, player): if not player.hand: return cards = yield SelectHandCards( game, player, count_lower=1, count_upper=1, msg=_("Which card do you want to trash?")) if cards: card = cards[0] for info_player in game.following_participants(player): yield InfoRequest(game, info_player, _("%s trashes this card:", (player.name, )), cards) card.trash(game, player) if isinstance(card, ActionCard): with fetch_card_from_supply(game, Duchy) 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]) if isinstance(card, TreasureCard): with fetch_card_from_supply(game, Transmute) 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]) if isinstance(card, VictoryCard): with fetch_card_from_supply(game, Gold) 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])
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 original_hand = other_player.hand[:] curse_discarded = False new_cards = [] for card in original_hand: if isinstance(card, CurseCard): for info_player in game.participants: yield InfoRequest( game, info_player, _("%(playername)s discards a curse:", {"playername": player.name}), [card]) card.discard(other_player) curse_discarded = True break if not curse_discarded: with fetch_card_from_supply(game, Curse) as new_card: new_cards.append(new_card) with fetch_card_from_supply(game, Copper) as new_card: new_cards.append(new_card) for info_player in game.participants: yield InfoRequest( game, info_player, _( "%(playername)s played Mountebank: %(player2name)s's gains:", { "playername": player.name, "player2name": other_player.name }), new_cards) for val in game.check_empty_pile("Curse"): yield val other_player.discard_pile.extend(new_cards)
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)), [])
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])