2022-03-25 04:28:07 +00:00
|
|
|
local SUITS = {
|
|
|
|
"Spade",
|
|
|
|
"Club",
|
|
|
|
"Diamond",
|
|
|
|
"Heart",
|
|
|
|
"NonSuit",
|
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
CardSuit = Util:createEnum(SUITS)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
local COLOR = {
|
|
|
|
"Red",
|
|
|
|
"Black",
|
|
|
|
"NonColor",
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
CardColor = Util:createEnum(COLOR)
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
local Card = class("Card")
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
function Card:initialize(name, suit, cardNumber)
|
|
|
|
self.name = name
|
|
|
|
self.suit = suit
|
|
|
|
self.cardNumber = cardNumber
|
2022-01-24 02:23:08 +00:00
|
|
|
end
|
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
function Card:getColor()
|
|
|
|
if self.suit == CardSuit.Spade or self.suit == CardSuit.Club then
|
|
|
|
return CardColor.Red
|
|
|
|
elseif self.suit == CardSuit.Diamond or self.suit == CardSuit.Heart then
|
|
|
|
return CardColor.Black
|
|
|
|
else
|
|
|
|
return CardColor.NonColor
|
|
|
|
end
|
|
|
|
end
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
return Card
|