2022-03-31 13:29:23 +08:00
|
|
|
---@class Card : Object
|
|
|
|
---@field package Package
|
|
|
|
---@field name string
|
|
|
|
---@field suit number # enum suit
|
|
|
|
---@field number number
|
|
|
|
---@field color number # enum color
|
|
|
|
---@field id number
|
|
|
|
---@field type number # enum type
|
|
|
|
local Card = class("Card")
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-31 13:29:23 +08:00
|
|
|
-- enum Suit
|
|
|
|
fk.createEnum(Card, {
|
|
|
|
"Spade",
|
|
|
|
"Club",
|
|
|
|
"Heart",
|
|
|
|
"Diamond",
|
|
|
|
"NoSuit"
|
|
|
|
})
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-31 13:29:23 +08:00
|
|
|
-- enum Color
|
|
|
|
fk.createEnum(Card, {
|
|
|
|
"Black",
|
|
|
|
"Red",
|
|
|
|
"NoColor"
|
|
|
|
})
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-31 13:29:23 +08:00
|
|
|
-- enum Type
|
|
|
|
fk.createEnum(Card, {
|
|
|
|
"TypeSkill",
|
|
|
|
"TypeBasic",
|
|
|
|
"TypeTrick",
|
|
|
|
"TypeEquip"
|
|
|
|
})
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-31 13:29:23 +08:00
|
|
|
function Card:initialize(name, suit, number, color)
|
|
|
|
self.name = name
|
|
|
|
self.suit = suit or Card.NoSuit
|
|
|
|
self.number = number or 0
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-31 13:29:23 +08:00
|
|
|
if suit == Card.Spade or suit == Card.Club then
|
|
|
|
self.color = Card.Black
|
|
|
|
elseif suit == Card.Heart or suit == Card.Diamond then
|
|
|
|
self.color = Card.Red
|
|
|
|
elseif color ~= nil then
|
|
|
|
self.color = color
|
|
|
|
else
|
|
|
|
self.color = Card.NoColor
|
|
|
|
end
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-31 13:29:23 +08:00
|
|
|
self.package = nil
|
|
|
|
self.id = 0
|
|
|
|
self.type = 0
|
2022-03-25 12:28:07 +08:00
|
|
|
end
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
return Card
|