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

尝试了一下用车神的方法写lua奇策

只看楼主收藏回复

@开不了车 车神的帖子在这里8L http://tieba.baidu.com/p/2291561675
车神提出的方法大体上是这样的:
当你需要将所有手牌作为一张牌时,可以先将使用一张没有subcard的牌,然后再想办法将全部手牌加入这张牌的subcard。依照车神的思路我尝试写了一下奇策技能(没写无懈可击部分因为比较懒)。
嗯,代码放在2L好了


IP属地:江苏1楼2013-04-29 21:27回复
    luaqicecard = sgs.CreateSkillCard
    {
    name = "luaqicecard",
    target_fixed = true,
    will_throw = false,
    on_use = function(self,room,source,targets)
    local choice = room:askForChoice(source,self:objectName(),"snatch+dismantlement+collateral+ex_nihilo+duel+fire_attack+amazing_grace+savage_assault+archery_attack+god_salvation+iron_chain")
    room:setPlayerFlag(source,"luaqice"..choice)
    if room:askForUseCard(source,"@@luaqice","@luaqice") then
    --room:loseHp(source)
    room:setPlayerFlag(source,"luaqicecardused")
    end
    room:setPlayerFlag(source,"-luaqice"..choice)
    end
    }
    function trickjudging(player)
    local choice = nil
    local from = {"snatch","dismantlement","collateral","ex_nihilo","duel","fire_attack","amazing_grace","savage_assault","archery_attack","god_salvation","iron_chain"}
    for _,i in pairs(from) do
    if player:hasFlag("luaqice"..i) then
    choice = i
    break
    end
    end
    return choice
    end
    luaqicevs = sgs.CreateViewAsSkill
    {
    name = "luaqice",
    n = 0,
    view_as = function(self,cards)
    local player = sgs.Self
    local choice = trickjudging(player)
    local card
    if not choice then
    card = luaqicecard:clone()
    else
    card = sgs.Sanguosha:cloneCard(choice,sgs.Card_NoSuit,0)
    card:setSkillName(self:objectName())
    end
    return card
    end,
    enabled_at_play = function()
    return not sgs.Self:hasFlag("luaqicecardused")
    end,
    enabled_at_response = function(pattern)
    return pattern == "@@luaqice"
    end
    }
    luaqice = sgs.CreateTriggerSkill
    {
    name = "luaqice",
    events = {sgs.EventPhaseChanging,sgs.CardUsed},
    view_as_skill = luaqicevs,
    on_trigger = function(self,event,player,data)
    local room = player:getRoom()
    if event == sgs.EventPhaseChanging then
    local change = data:toPhaseChange()
    if change.from == sgs.Player_Play then
    if player:hasFlag("luaqicecardused") then
    room:setPlayerFlag(player,"-luaqicecardused")
    end
    end
    end
    if event == sgs.CardUsed then
    if player:hasFlag("luaqiceusing") then return false end
    local use = data:toCardUse()
    if use.card:getSkillName() == self:objectName() then
    room:setPlayerFlag(player,"luaqiceusing")
    for _,id in sgs.qlist(player:handCards()) do
    use.card:addSubcard(id)
    end
    room:useCard(use)
    room:setPlayerFlag(player,"-luaqiceusing")
    return true
    end
    end
    end
    }


    IP属地:江苏2楼2013-04-29 21:29
    回复
      不错。不过这样使用的锦囊指定目标的时候为无色的,可以不受帷幕之类的影响


      IP属地:上海3楼2013-04-29 21:34
      收起回复
        flag那部分似乎可以考虑用property


        IP属地:上海5楼2013-04-29 21:43
        收起回复