95 lines
1.8 KiB
Lua
95 lines
1.8 KiB
Lua
---@class Card : Object
|
|
---@field package Package
|
|
---@field name string
|
|
---@field suit Suit
|
|
---@field number integer
|
|
---@field trueName string
|
|
---@field color Color
|
|
---@field id integer
|
|
---@field type CardType
|
|
---@field sub_type CardSubtype
|
|
---@field area CardArea
|
|
local Card = class("Card")
|
|
|
|
---@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.TypeBasic = 1
|
|
Card.TypeTrick = 2
|
|
Card.TypeEquip = 3
|
|
|
|
---@alias CardSubtype integer
|
|
|
|
Card.SubtypeNone = 1
|
|
Card.SubtypeDelayedTrick = 2
|
|
Card.SubtypeWeapon = 3
|
|
Card.SubtypeArmor = 4
|
|
Card.SubtypeDefensiveRide = 5
|
|
Card.SubtypeOffensiveRide = 6
|
|
Card.SubtypeTreasure = 7
|
|
|
|
---@alias CardArea integer
|
|
|
|
Card.Unknown = 0
|
|
Card.PlayerHand = 1
|
|
Card.PlayerEquip = 2
|
|
Card.PlayerJudge = 3
|
|
Card.PlayerSpecial = 4
|
|
Card.Processing = 5
|
|
Card.DrawPile = 6
|
|
Card.DiscardPile = 7
|
|
Card.Void = 8
|
|
|
|
function Card:initialize(name, suit, number, color)
|
|
self.name = name
|
|
self.suit = suit or Card.NoSuit
|
|
self.number = number or 0
|
|
self.trueName = name
|
|
|
|
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
|
|
|
|
self.package = nil
|
|
self.id = 0
|
|
self.type = 0
|
|
self.sub_type = Card.SubTypeNone
|
|
self.skill = nil
|
|
end
|
|
|
|
function Card:getSuitString()
|
|
local suit = self.suit
|
|
if suit == Card.Spade then
|
|
return "spade"
|
|
elseif suit == Card.Heart then
|
|
return "heart"
|
|
elseif suit == Card.Club then
|
|
return "club"
|
|
elseif suit == Card.Diamond then
|
|
return "diamond"
|
|
else
|
|
return "unknown"
|
|
end
|
|
end
|
|
|
|
return Card
|