摸索了两小时还是没办法实现,故上来发问。
想问如何让以下技能"每回合只能发动1次"?
目前的情况是只要回合内符合条件,就无限发动......
技能内容:当手牌=<已损Hp时,可将1张手牌当无中生有使用。
如下:
LuaWangxiang = sgs.CreateViewAsSkill{
name = "LuaWangxiang",
n = 1,
view_filter = function(self, selected, to_select)
if not to_select:isEquipped() then
return true
end
end,
view_as = function(self, cards)
if #cards == 0 then
return nil
elseif #cards == 1 then
local card = cards[1]
local ex_nihilo = sgs.Sanguosha:cloneCard("ex_nihilo", card:getSuit(), card:getNumber())
ex_nihilo:addSubcard(card:getId())
ex_nihilo:setSkillName(self:objectName())
return ex_nihilo
end
end,
enabled_at_play = function(self, player)
local wxhcn = player:getHandcardNum()
local hp = player:getHp()
local losehp = player:getMaxHp() - hp
return ( wxhcn <= losehp )
end,
}
对比其他同样一回合只能发动一次的技能后,
我试着在enabled_at_play最后加上return not player:hasUsed("#LuaWangxiang")
但还是变成无限发动,求救!
想问如何让以下技能"每回合只能发动1次"?
目前的情况是只要回合内符合条件,就无限发动......
技能内容:当手牌=<已损Hp时,可将1张手牌当无中生有使用。
如下:
LuaWangxiang = sgs.CreateViewAsSkill{
name = "LuaWangxiang",
n = 1,
view_filter = function(self, selected, to_select)
if not to_select:isEquipped() then
return true
end
end,
view_as = function(self, cards)
if #cards == 0 then
return nil
elseif #cards == 1 then
local card = cards[1]
local ex_nihilo = sgs.Sanguosha:cloneCard("ex_nihilo", card:getSuit(), card:getNumber())
ex_nihilo:addSubcard(card:getId())
ex_nihilo:setSkillName(self:objectName())
return ex_nihilo
end
end,
enabled_at_play = function(self, player)
local wxhcn = player:getHandcardNum()
local hp = player:getHp()
local losehp = player:getMaxHp() - hp
return ( wxhcn <= losehp )
end,
}
对比其他同样一回合只能发动一次的技能后,
我试着在enabled_at_play最后加上return not player:hasUsed("#LuaWangxiang")
但还是变成无限发动,求救!