Beispiel #1
0
class Dealer():
    """
    This class of objects is for a dealer who draws the cards, keeps track
    of the previous card, and determines if the drawn card is hi or lo.

    Attributes:
        deck: instance of Deck class
        current_card: a random card drawn from the deck
        prev_card: the previous card, used to evaluate hi/lo
    """
    def __init__(self):
        """Class constructor. Defines instance attributes.

        Args:
            self (Dealer): An instance of the Dealer class.
        """
        self.deck = Deck()
        self.current_card = self.deck.draw_card()
        self.prev_card = 0

    def draw_card(self):
        """Gets a new card and retains the previous card.

        Args:
            self (Dealer): An instance of the Dealer class.
        """
        self.prev_card = self.current_card
        # TODO: get the deck.function to draw a card
        self.current_card = self.deck.draw_card()

        if not self.deck.deck:
            self.deck.create_deck()

    def determine_result(self):
        """ Determines if the drawn (current) card is higher or lower than
        the previous card.

        Args:
            self (Dealer): An instance of the Dealer class.
        Returns:
            str: if higher, returns 'hi'
                 if lower, returns 'lo'
                 if equal, returns 'equal'
        """
        if self.current_card > self.prev_card:
            result = 'h'
        elif self.current_card < self.prev_card:
            result = 'l'
        elif self.current_card:
            result = 'equal'
        return result
Beispiel #2
0
class Player(object):
    def __init__(self, deck_file: Path, hp: int, name: str):

        self.name = name
        self.deck = Deck(deck_file=deck_file, name="{}_deck".format(name))
        self.health_points = hp

        self.hand = []
        self.lands = []
        self.mana_pool = 0
        self.land_spells = 0
        self.creatures = []
        self.cemetery = []

        self.board = [self.lands, self.creatures]

        self.attacking_creatures = []
        self.blocking_creatures = []

    def draw_card(self, cards_count: int = 1):
        for i in range(cards_count):
            draw_card = self.deck.draw_card()
            draw_card.location = "hand"
            self.hand.append(draw_card)

    def refresh_land_spells(self, lands_turn: int):
        self.land_spells = lands_turn

    def untap_lands(self):
        for land_card in self.lands:
            land_card.status = "ready"

    def untap_creatures(self):
        for creature in self.creatures:
            creature.status = "ready"

    def clear_attacking_creatures(self):
        self.attacking_creatures = []

    def destroy_creatures(self, creatures_list: List[CreatureCard]):
        for creature in creatures_list:
            self.creatures.remove(creature)
            self.cemetery.append(creature)
            creature.location = "cemetery"

    def reset_creatures(self):
        for creature in self.creatures:
            creature.reset()