mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 03:32:34 +08:00
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 subcards integer[]
|
||||
---@field public skillName string @ for virtual cards
|
||||
---@field public skillNames string[]
|
||||
---@field public skill Skill
|
||||
---@field public special_skills string[] | nil
|
||||
local Card = class("Card")
|
||||
|
@ -86,7 +87,34 @@ function Card:initialize(name, suit, number, color)
|
|||
self.sub_type = Card.SubTypeNone
|
||||
self.skill = nil
|
||||
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
|
||||
|
||||
--- 克隆特定卡牌并赋予花色与点数。
|
||||
|
|
|
@ -331,6 +331,7 @@ local fanSkill = fk.CreateTriggerSkill{
|
|||
end,
|
||||
on_use = function(_, _, _, _, data)
|
||||
local fireSlash = Fk:cloneCard("fire__slash")
|
||||
fireSlash.skillName = "fan"
|
||||
fireSlash:addSubcard(data.card)
|
||||
data.card = fireSlash
|
||||
end,
|
||||
|
|
|
@ -268,6 +268,7 @@ local qingguo = fk.CreateViewAsSkill{
|
|||
return nil
|
||||
end
|
||||
local c = Fk:cloneCard("jink")
|
||||
c.skillName = self.name
|
||||
c:addSubcard(cards[1])
|
||||
return c
|
||||
end,
|
||||
|
@ -334,6 +335,7 @@ local wusheng = fk.CreateViewAsSkill{
|
|||
return nil
|
||||
end
|
||||
local c = Fk:cloneCard("slash")
|
||||
c.skillName = self.name
|
||||
c:addSubcard(cards[1])
|
||||
return c
|
||||
end,
|
||||
|
@ -441,6 +443,7 @@ local longdan = fk.CreateViewAsSkill{
|
|||
elseif _c.name == "jink" then
|
||||
c = Fk:cloneCard("slash")
|
||||
end
|
||||
c.skillName = self.name
|
||||
c:addSubcard(cards[1])
|
||||
return c
|
||||
end,
|
||||
|
@ -538,6 +541,7 @@ local qixi = fk.CreateViewAsSkill{
|
|||
return nil
|
||||
end
|
||||
local c = Fk:cloneCard("dismantlement")
|
||||
c.skillName = self.name
|
||||
c:addSubcard(cards[1])
|
||||
return c
|
||||
end,
|
||||
|
@ -650,6 +654,7 @@ local guose = fk.CreateViewAsSkill{
|
|||
return nil
|
||||
end
|
||||
local c = Fk:cloneCard("indulgence")
|
||||
c.skillName = self.name
|
||||
c:addSubcard(cards[1])
|
||||
return c
|
||||
end,
|
||||
|
@ -835,6 +840,7 @@ local jijiu = fk.CreateViewAsSkill{
|
|||
return nil
|
||||
end
|
||||
local c = Fk:cloneCard("peach")
|
||||
c.skillName = self.name
|
||||
c:addSubcard(cards[1])
|
||||
return c
|
||||
end,
|
||||
|
@ -897,6 +903,7 @@ local lijian = fk.CreateActiveSkill{
|
|||
on_use = function(self, room, use)
|
||||
room:throwCard(use.cards, self.name, room:getPlayerById(use.from))
|
||||
local duel = Fk:cloneCard("duel")
|
||||
duel.skillName = self.name
|
||||
local new_use = {} ---@type CardUseStruct
|
||||
new_use.from = use.tos[2]
|
||||
new_use.tos = { { use.tos[1] } }
|
||||
|
|
|
@ -950,6 +950,7 @@ local spearSkill = fk.CreateViewAsSkill{
|
|||
return nil
|
||||
end
|
||||
local c = Fk:cloneCard("slash")
|
||||
c.skillName = "spear"
|
||||
c:addSubcards(cards)
|
||||
return c
|
||||
end,
|
||||
|
@ -1103,6 +1104,7 @@ local eightDiagramSkill = fk.CreateTriggerSkill{
|
|||
from = player.id,
|
||||
card = Fk:cloneCard('jink'),
|
||||
}
|
||||
data.result.card.skillName = "eight_diagram"
|
||||
|
||||
if data.eventData then
|
||||
data.result.toCard = data.eventData.toCard
|
||||
|
@ -1110,6 +1112,7 @@ local eightDiagramSkill = fk.CreateTriggerSkill{
|
|||
end
|
||||
else
|
||||
data.result = Fk:cloneCard('jink')
|
||||
data.result.skillName = "eight_diagram"
|
||||
end
|
||||
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue
Block a user