コード例 #1
0
ファイル: global_defs.py プロジェクト: jimmy6727/SampleCode
    def __gt__(self, other):
        return self.value < other.value

    def __ge__(self, other):
        return self.value <= other.value


SUITS_FORCE_UNICODE = False

Strain = Enum("Strain", zip("CDHSN", range(5)))
Strain.__str__ = lambda self: self.name
Strain.__lt__ = lambda self, other: self.value < other.value
Strain.__le__ = lambda self, other: self.value <= other.value
Strain.__gt__ = lambda self, other: self.value > other.value
Strain.__ge__ = lambda self, other: self.value >= other.value

Rank = Enum("Rank", zip("23456789TJQKA", range(2, 15)))
Rank.__str__ = lambda self: self.name
Rank.__index__ = lambda self: self.value - 2
Rank.__lt__ = lambda self, other: self.value < other.value
Rank.__le__ = lambda self, other: self.value <= other.value
Rank.__gt__ = lambda self, other: self.value > other.value
Rank.__ge__ = lambda self, other: self.value >= other.value

Card = namedtuple("Card", ["suit", "rank"])
Card.from_str = lambda s: Card(Suit[s[0]], Rank[s[1]])
Card.__str__ = lambda self: "{0.suit}{0.rank}".format(self)
Card.__format__ = lambda self, fmt: format(str(self), fmt)
FULL_DECK = {
    Card(suit=suit, rank=rank)
コード例 #2
0
 def __ge__(self, other):
     return int(self).__ge__(other) if isinstance(other, int) else Enum.__ge__(self, other)
コード例 #3
0
ファイル: enumerations.py プロジェクト: oysstu/pyxtf
 def __ge__(self, other):
     return int(self).__ge__(other) if isinstance(other, int) else Enum.__ge__(self, other)