whist_core.cards.card ===================== .. py:module:: whist_core.cards.card .. autoapi-nested-parse:: Card related classes Classes ------- .. autoapisummary:: whist_core.cards.card._CardEnum whist_core.cards.card.Suit whist_core.cards.card.Rank whist_core.cards.card.Card Module Contents --------------- .. py:class:: _CardEnum(_, short_name = None) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: __short_name :value: None .. py:method:: _missing_(value) :classmethod: .. py:property:: ordinal :type: int Get the ordinal. :return: ordinal .. py:property:: long_name :type: str Get the long version of the name. :return: long version of name .. py:property:: short_name :type: str Get the short version of the name. :return: short version of name .. py:method:: __lt__(other) .. py:method:: __str__() .. py:class:: Suit(_, short_name = None) Bases: :py:obj:`_CardEnum` Suits in a playing card deck .. py:attribute:: CLUBS :value: ('clubs', '♣') .. py:attribute:: DIAMONDS :value: ('diamonds', '♦') .. py:attribute:: HEARTS :value: ('hearts', '♥') .. py:attribute:: SPADES :value: ('spades', '♠') .. py:class:: Rank(_, short_name = None) Bases: :py:obj:`_CardEnum` Ranks in a playing card deck .. py:attribute:: NUM_2 :value: '2' .. py:attribute:: NUM_3 :value: '3' .. py:attribute:: NUM_4 :value: '4' .. py:attribute:: NUM_5 :value: '5' .. py:attribute:: NUM_6 :value: '6' .. py:attribute:: NUM_7 :value: '7' .. py:attribute:: NUM_8 :value: '8' .. py:attribute:: NUM_9 :value: '9' .. py:attribute:: NUM_10 :value: '10' .. py:attribute:: J :value: ('jack', 'J') .. py:attribute:: Q :value: ('queen', 'Q') .. py:attribute:: K :value: ('king', 'K') .. py:attribute:: A :value: ('ace', 'A') .. py:class:: Card Bases: :py:obj:`pydantic.BaseModel` A playing card .. py:attribute:: suit :type: Suit .. py:attribute:: rank :type: Rank .. py:method:: all_cards() :staticmethod: Get iterator of all cards. :return: all cards .. py:property:: short_name :type: str Get the short name of this card. :return: short name .. py:property:: name :type: str Get the name of this card. :return: name .. py:method:: dict(*args, **kwargs) Returns the dictionary. See BaseModel for details. .. py:method:: model_dump(*args, **kwargs) Returns the dictionary. See BaseModel for details. .. py:method:: __lt__(other) Checks if the other card is lower than this card. .. py:method:: __str__() Returns string representation of this card.