太阳神三国杀lua吧 关注:2,638贴子:73,386
  • 2回复贴,共1

【回归的节奏】一个可以模拟奇策的技能卡

只看楼主收藏回复

源码的奇策使用的是GuhuoDialog,除非用啦啦版的,要不然Lua实现不了的说,不过这种方法确实可以冒充。
先选择角色,然后选择可供使用的Card。。。。。
未考虑卡片包的禁止。
local objectNames_list = {}
for id = 0,(sgs.Sanguosha:getCardCount() - 1),1 do
local card = sgs.Sanguosha:getEngineCard(id)
if card:isKindOf("TrickCard") and not card:isKindOf("DelayedTrick") then
if not table.contains(objectNames_list,card:objectName()) then
table.insert(objectNames_list,card:objectName())
end
end
end
local boolTable2string = function(tables)
local stringtable = {}
for _,bool in ipairs(tables)do
if bool then
table.insert(stringtable,"true")
else
table.insert(stringtable,"false")
end
end
return table.concat(stringtable,"+")
end
local targetFixedCardObjectNameLlist = {}
local notTargetFixedCardObjectNameLlist = {}
for _,name in ipairs(objectNames_list) do
local card = sgs.Sanguosha:cloneCard(name)
card:deleteLater()
if card:targetFixed() then
table.insert(targetFixedCardObjectNameLlist,name)
else
table.insert(notTargetFixedCardObjectNameLlist,name)
end
end
table.removeOne(targetFixedCardObjectNameLlist,"nullification")
LuaQiceCard = sgs.CreateSkillCard{
name = "LuaQiceCard",
target_fixed = false,
will_throw = true,
filter = function(self, targets, to_select)
local qtargets = sgs.PlayerList()
for _, p in ipairs(targets) do
qtargets:append(p)
end
local LuaQiceCardCase = {}
for _,name in ipairs(notTargetFixedCardObjectNameLlist) do
local card = sgs.Sanguosha:cloneCard(name)
card:deleteLater()
card:setSkillName(self:getSkillName())
card:addSubcard(self)
table.insert(LuaQiceCardCase,card:targetFilter(qtargets,to_select,sgs.Self))
end
return (table.contains(LuaQiceCardCase,true)) or #targets == 0
end,
feasible = function(self, targets)
local LuaQiceCardCase = {}
local qtargets = sgs.PlayerList()
for _, p in ipairs(targets) do
qtargets:append(p)
end
for _,name in ipairs(notTargetFixedCardObjectNameLlist) do
local card = sgs.Sanguosha:cloneCard(name)
card:deleteLater()
card:setSkillName(self:getSkillName())
card:addSubcard(self)
table.insert(LuaQiceCardCase,card:targetsFeasible(qtargets,sgs.Self))
end
self:setUserString(boolTable2string(LuaQiceCardCase))
return (table.contains(LuaQiceCardCase,true)) or #targets == 0
end,
on_validate = function(self,carduse)
local source = carduse.from
local room = source:getRoom()
if carduse.to:length() > 0 then
local choose_list = {}
for i,bool in ipairs(self:getUserString():split("+")) do
if bool == "true" then
local Card_objectName = notTargetFixedCardObjectNameLlist[i]
local c = sgs.Sanguosha:cloneCard(Card_objectName)
c:setSkillName(self:getSkillName())
c:addSubcard(self)
c:deleteLater()
if not c:isAvailable(source) then continue end
local emptylist = sgs.PlayerList()
local judge_list = {}
for _,p in sgs.qlist(carduse.to)do
if c:targetFilter(emptylist, p, source) then
table.insert(judge_list,true)
else
table.insert(judge_list,false)
end
emptylist:append(p)
end
if not table.contains(judge_list,false) then
table.insert(choose_list,Card_objectName)
else
continue
end
end
end
table.insert(choose_list,"cancel")
local choice = room:askForChoice(source,self:getSkillName(),table.concat(choose_list,"+"))
if choice ~= "cancel" then
local aCard = sgs.Sanguosha:cloneCard(choice)
aCard:setSkillName(self:getSkillName())
aCard:addSubcard(self)
return aCard
end
else
local choose_list = {}
for _,name in ipairs (targetFixedCardObjectNameLlist)do
local c = sgs.Sanguosha:cloneCard(name)
c:setSkillName(self:getSkillName())
c:addSubcard(self)
c:deleteLater()
if c:isAvailable(source) then
table.insert(choose_list,name)
end
end
table.insert(choose_list,"cancel")
local choice = room:askForChoice(source,self:getSkillName(),table.concat(choose_list,"+"))
if choice ~= "cancel" then
local aCard = sgs.Sanguosha:cloneCard(choice)
aCard:setSkillName(self:getSkillName())
aCard:addSubcard(self)
return aCard
end
end
return nil
end,
}


1楼2014-03-14 17:11回复
    。。。其实可以用validate的


    IP属地:浙江来自iPhone客户端2楼2014-03-15 08:48
    回复
      围观学习


      IP属地:爱尔兰来自iPhone客户端3楼2014-03-15 08:57
      回复