2022-03-31 13:29:23 +08:00
|
|
|
---@class Card : Object
|
|
|
|
---@field package Package
|
|
|
|
---@field name string
|
2022-04-01 20:51:01 +08:00
|
|
|
---@field suit Suit
|
|
|
|
---@field number integer
|
|
|
|
---@field color Color
|
|
|
|
---@field id integer
|
|
|
|
---@field type CardType
|
2022-03-31 13:29:23 +08:00
|
|
|
local Card = class("Card")
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-04-01 20:51:01 +08:00
|
|
|
---@alias Suit integer
|
|
|
|
|
|
|
|
Card.Spade = 1
|
|
|
|
Card.Club = 2
|
|
|
|
Card.Heart = 3
|
|
|
|
Card.Diamond = 4
|
|
|
|
Card.NoSuit = 5
|
|
|
|
|
|
|
|
---@alias Color integer
|
|
|
|
|
|
|
|
Card.Black = 1
|
|
|
|
Card.Red = 2
|
|
|
|
Card.NoColor = 3
|
|
|
|
|
|
|
|
---@alias CardType integer
|
|
|
|
|
|
|
|
Card.TypeSkill = 1
|
|
|
|
Card.TypeBasic = 2
|
|
|
|
Card.TypeTrick = 3
|
|
|
|
Card.TypeEquip = 4
|
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
|