Card skill name (#95)
重新设计了Card.skillName,并给各种cloneCard补上了skillName - 赋值:card.skillName = 'xxx' - 判断是否: table.contains(card.skillNames, 'xxx') - 判断是否(不推荐): card.skillName == 'xxx'
This commit is contained in:
parent
96363bf84d
commit
615a4884e2
|
@ -15,6 +15,7 @@
|
||||||
---@field public area CardArea @ 卡牌所在区域(例如手牌区,判定区,装备区,牌堆,弃牌堆···)
|
---@field public area CardArea @ 卡牌所在区域(例如手牌区,判定区,装备区,牌堆,弃牌堆···)
|
||||||
---@field public subcards integer[]
|
---@field public subcards integer[]
|
||||||
---@field public skillName string @ for virtual cards
|
---@field public skillName string @ for virtual cards
|
||||||
|
---@field public skillNames string[]
|
||||||
---@field public skill Skill
|
---@field public skill Skill
|
||||||
---@field public special_skills string[] | nil
|
---@field public special_skills string[] | nil
|
||||||
local Card = class("Card")
|
local Card = class("Card")
|
||||||
|
@ -86,7 +87,34 @@ function Card:initialize(name, suit, number, color)
|
||||||
self.sub_type = Card.SubTypeNone
|
self.sub_type = Card.SubTypeNone
|
||||||
self.skill = nil
|
self.skill = nil
|
||||||
self.subcards = {}
|
self.subcards = {}
|
||||||
self.skillName = ""
|
self.skillName = nil -- ""
|
||||||
|
self._skillName = ""
|
||||||
|
self.skillNames = {}
|
||||||
|
|
||||||
|
local mt = table.simpleClone(getmetatable(self))
|
||||||
|
local newidx = mt.__newindex or rawset
|
||||||
|
mt.__newindex = function(t, k, v)
|
||||||
|
if k == "skillName" then
|
||||||
|
table.insertIfNeed(self.skillNames, v)
|
||||||
|
t._skillName = v
|
||||||
|
else
|
||||||
|
return newidx(t, k, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local idx = mt.__index or rawget
|
||||||
|
mt.__index = function(t, k)
|
||||||
|
if k == "skillName" then
|
||||||
|
return t._skillName
|
||||||
|
end
|
||||||
|
if type(idx) == "table" then
|
||||||
|
return idx[k]
|
||||||
|
end
|
||||||
|
if type(idx) == "function" then
|
||||||
|
return idx(t, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
setmetatable(self, mt)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- 克隆特定卡牌并赋予花色与点数。
|
--- 克隆特定卡牌并赋予花色与点数。
|
||||||
|
|
|
@ -331,6 +331,7 @@ local fanSkill = fk.CreateTriggerSkill{
|
||||||
end,
|
end,
|
||||||
on_use = function(_, _, _, _, data)
|
on_use = function(_, _, _, _, data)
|
||||||
local fireSlash = Fk:cloneCard("fire__slash")
|
local fireSlash = Fk:cloneCard("fire__slash")
|
||||||
|
fireSlash.skillName = "fan"
|
||||||
fireSlash:addSubcard(data.card)
|
fireSlash:addSubcard(data.card)
|
||||||
data.card = fireSlash
|
data.card = fireSlash
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -268,6 +268,7 @@ local qingguo = fk.CreateViewAsSkill{
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local c = Fk:cloneCard("jink")
|
local c = Fk:cloneCard("jink")
|
||||||
|
c.skillName = self.name
|
||||||
c:addSubcard(cards[1])
|
c:addSubcard(cards[1])
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -334,6 +335,7 @@ local wusheng = fk.CreateViewAsSkill{
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local c = Fk:cloneCard("slash")
|
local c = Fk:cloneCard("slash")
|
||||||
|
c.skillName = self.name
|
||||||
c:addSubcard(cards[1])
|
c:addSubcard(cards[1])
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -441,6 +443,7 @@ local longdan = fk.CreateViewAsSkill{
|
||||||
elseif _c.name == "jink" then
|
elseif _c.name == "jink" then
|
||||||
c = Fk:cloneCard("slash")
|
c = Fk:cloneCard("slash")
|
||||||
end
|
end
|
||||||
|
c.skillName = self.name
|
||||||
c:addSubcard(cards[1])
|
c:addSubcard(cards[1])
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -538,6 +541,7 @@ local qixi = fk.CreateViewAsSkill{
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local c = Fk:cloneCard("dismantlement")
|
local c = Fk:cloneCard("dismantlement")
|
||||||
|
c.skillName = self.name
|
||||||
c:addSubcard(cards[1])
|
c:addSubcard(cards[1])
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -650,6 +654,7 @@ local guose = fk.CreateViewAsSkill{
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local c = Fk:cloneCard("indulgence")
|
local c = Fk:cloneCard("indulgence")
|
||||||
|
c.skillName = self.name
|
||||||
c:addSubcard(cards[1])
|
c:addSubcard(cards[1])
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -835,6 +840,7 @@ local jijiu = fk.CreateViewAsSkill{
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local c = Fk:cloneCard("peach")
|
local c = Fk:cloneCard("peach")
|
||||||
|
c.skillName = self.name
|
||||||
c:addSubcard(cards[1])
|
c:addSubcard(cards[1])
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -897,6 +903,7 @@ local lijian = fk.CreateActiveSkill{
|
||||||
on_use = function(self, room, use)
|
on_use = function(self, room, use)
|
||||||
room:throwCard(use.cards, self.name, room:getPlayerById(use.from))
|
room:throwCard(use.cards, self.name, room:getPlayerById(use.from))
|
||||||
local duel = Fk:cloneCard("duel")
|
local duel = Fk:cloneCard("duel")
|
||||||
|
duel.skillName = self.name
|
||||||
local new_use = {} ---@type CardUseStruct
|
local new_use = {} ---@type CardUseStruct
|
||||||
new_use.from = use.tos[2]
|
new_use.from = use.tos[2]
|
||||||
new_use.tos = { { use.tos[1] } }
|
new_use.tos = { { use.tos[1] } }
|
||||||
|
|
|
@ -950,6 +950,7 @@ local spearSkill = fk.CreateViewAsSkill{
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local c = Fk:cloneCard("slash")
|
local c = Fk:cloneCard("slash")
|
||||||
|
c.skillName = "spear"
|
||||||
c:addSubcards(cards)
|
c:addSubcards(cards)
|
||||||
return c
|
return c
|
||||||
end,
|
end,
|
||||||
|
@ -1103,6 +1104,7 @@ local eightDiagramSkill = fk.CreateTriggerSkill{
|
||||||
from = player.id,
|
from = player.id,
|
||||||
card = Fk:cloneCard('jink'),
|
card = Fk:cloneCard('jink'),
|
||||||
}
|
}
|
||||||
|
data.result.card.skillName = "eight_diagram"
|
||||||
|
|
||||||
if data.eventData then
|
if data.eventData then
|
||||||
data.result.toCard = data.eventData.toCard
|
data.result.toCard = data.eventData.toCard
|
||||||
|
@ -1110,6 +1112,7 @@ local eightDiagramSkill = fk.CreateTriggerSkill{
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
data.result = Fk:cloneCard('jink')
|
data.result = Fk:cloneCard('jink')
|
||||||
|
data.result.skillName = "eight_diagram"
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue