예제 #1
0
    def buy_card_from_store(self, index, purchasing_player: Player,
                            other_players):
        card_to_buy: Card = self.__card_store[index]
        card_cost = card_to_buy.cost
        if purchasing_player.has_instance_of_card(AlienMetabolism()):
            card_cost = card_to_buy.cost - 1
        if purchasing_player.energy < card_cost:
            raise InsufficientFundsException(constants.INSUFFICIENT_FUNDS_MSG)
        else:
            purchasing_player.update_energy_by(-card_cost)
            if purchasing_player.has_instance_of_card(DedicatedNewsTeam()):
                DedicatedNewsTeam().special_effect(purchasing_player, None)
            if isinstance(card_to_buy, DiscardCard):
                print("{} is a discard card".format(card_to_buy.name))

                # if the card is DropFromHighAltitude, we have to prompt player, and then consumers.py will handle
                # triggering the immediate_effect
                if not isinstance(card_to_buy, DropFromHighAltitude):
                    card_to_buy.immediate_effect(purchasing_player,
                                                 other_players)
                self.discard(card_to_buy)
            elif isinstance(card_to_buy, KeepCard):
                card_to_buy.immediate_effect(purchasing_player, other_players)
            else:
                print("UNEXPECTED CARD TYPE!!!")
                raise UnexpectedCardTypeException
            self.__card_store.remove(card_to_buy)
            self.__fill_card_store()
        return card_to_buy
예제 #2
0
 def sweep_store(self, player_invoking_sweep: Player):
     if player_invoking_sweep.energy < constants.SWEEP_CARD_STORE_COST:
         raise Exception(constants.INSUFFICIENT_FUNDS_TO_SWEEP_MSG)
     else:
         player_invoking_sweep.update_energy_by(
             -constants.SWEEP_CARD_STORE_COST)
         for _ in range(3):
             self.discard(self.store.pop())
         self.__fill_card_store()