Commit 3715d672 authored by Yildius's avatar Yildius

color -> suit

parent 63eceb22
......@@ -153,7 +153,7 @@ class Hand:
else:
isFlush = True
for i in range(4):
if self.__cards[0].color != self.__cards[i + 1].color:
if self.__cards[0].suit != self.__cards[i + 1].suit:
isFlush = False
if isFlush:
self.__handName = HandName.FLUSH
......
......@@ -18,7 +18,7 @@
from enum import Enum
class Color(Enum):
class Suit(Enum):
HEARTS = 1
SPADES = 2
DIAMONDS = 3
......@@ -26,22 +26,22 @@ class Color(Enum):
class Card:
def __init__(self, color, value):
def __init__(self, Suit, value):
## The card must be instanciated with its suit and value, which won't
# change.
assert value >= 2 and value <= 14
self.__color = color
self.__suit = suit
self.__value = value
self.__json = {}
if self.__color == Color.HEARTS : self.__json["Suit"] = "Hearts"
elif self.__color == Color.SPADES : self.__json["Suit"] = "Spades"
elif self.__color == Color.DIAMONDS : self.__json["Suit"] = "Diamonds"
elif self.__color == Color.CLUBS : self.__json["Suit"] = "Clubs"
if self.__suit == Suit.HEARTS : self.__json["Suit"] = "Hearts"
elif self.__suit == Suit.SPADES : self.__json["Suit"] = "Spades"
elif self.__suit == Suit.DIAMONDS : self.__json["Suit"] = "Diamonds"
elif self.__suit == Suit.CLUBS : self.__json["Suit"] = "Clubs"
self.__json["Rank"] = self.__value
@property
def color(self):
return self.__color
def suit(self):
return self.__suit
@property
def value(self):
......@@ -53,7 +53,7 @@ class Card:
def cardStr(self):
# Debug print
return '({0}:{1})'.format(self.__value, self.__color)
return '({0}:{1})'.format(self.__value, self.__suit)
def valueStr(self):
# Returns the value of a card as astring, for json export.
......@@ -75,4 +75,4 @@ class Card:
def sameAs(self, card):
# Check if both cards are exactly the same (suit and value)
return self.__color == card.color and self.__value == card.value
return self.__suit == card.suit and self.__value == card.value
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment