Commit 05768e53 authored by 花桃白音's avatar 花桃白音

fix tgkwc fear add costself

parent bab0ffee
Pipeline #30905 passed with stages
in 30 minutes and 56 seconds
--炼金工作室-测试卡 --手冲魔女-菲雅
local m=4212320 local m=4212320
local cm=_G["c"..m] local cm=_G["c"..m]
--増援
function cm.initial_effect(c) function cm.initial_effect(c)
--Activate --Activate
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
...@@ -9,12 +8,24 @@ function cm.initial_effect(c) ...@@ -9,12 +8,24 @@ function cm.initial_effect(c)
e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetRange(LOCATION_HAND) e1:SetRange(LOCATION_HAND)
e1:SetCode(EVENT_FREE_CHAIN) e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,cm) e1:SetCountLimit(1,m)
e1:SetCost(cm.discost) e1:SetCost(cm.discost)
e1:SetTarget(cm.target) e1:SetTarget(cm.target)
e1:SetOperation(cm.activate) e1:SetOperation(cm.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE)
end
function cm.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp,eg,ep,ev,re,r,rp)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
cm.cache={} cm.cache={}
function cm.filter(c,e,tp,eg,ep,ev,re,r,rp) function cm.filter(c,e,tp,eg,ep,ev,re,r,rp)
return c:IsAbleToHand() and cm.CheckDiscard(c,e,tp,eg,ep,ev,re,r,rp)and not (c:IsCode(e:GetHandler():GetCode())) return c:IsAbleToHand() and cm.CheckDiscard(c,e,tp,eg,ep,ev,re,r,rp)and not (c:IsCode(e:GetHandler():GetCode()))
...@@ -30,7 +41,12 @@ function cm.CheckDiscard(c,e,tp,eg,ep,ev,re,r,rp) ...@@ -30,7 +41,12 @@ function cm.CheckDiscard(c,e,tp,eg,ep,ev,re,r,rp)
end end
return temp(tc,te,f) return temp(tc,te,f)
end end
local tempc=cm.IgnoreActionCheck(Duel.CreateToken,c:GetControler(),code) local tempc=(function(tp,code)
Duel.DisableActionCheck(true)
local sret = Duel.CreateToken(tp,code)
Duel.DisableActionCheck(false)
return sret
end)(c:GetControler(),code)
Card.RegisterEffect=temp Card.RegisterEffect=temp
local found=false local found=false
for _,te in ipairs(eset) do for _,te in ipairs(eset) do
...@@ -42,22 +58,29 @@ function cm.CheckDiscard(c,e,tp,eg,ep,ev,re,r,rp) ...@@ -42,22 +58,29 @@ function cm.CheckDiscard(c,e,tp,eg,ep,ev,re,r,rp)
if e==te then return tempc end if e==te then return tempc end
return temp_(e) return temp_(e)
end end
mt.IsDiscardable=function(tc,...) if mt then
mt.IsDiscardable=function(tc,...)
if tempc==tc then found=true end if tempc==tc then found=true end
return Card.IsDiscardable(tc,...) return Card.IsDiscardable(tc,...)
end end
pcall(function() pcall(function()
cost(te,tp,eg,ep,ev,re,r,rp,0) cost(te,tp,eg,ep,ev,re,r,rp,0)
end) end)
mt.IsDiscardable=nil mt.IsDiscardable=nil
end
Effect.GetHandler=temp_ Effect.GetHandler=temp_
end end
end end
cm.cache[code]=(found and 1 or 0) cm.cache[code]=(found and 1 or 0)
return found return found
end end
function cm.IgnoreActionCheck(f,...)
Duel.DisableActionCheck(true) function cm.discost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsDiscardable() end
Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD)
end
--[[
local cr=coroutine.create(f) local cr=coroutine.create(f)
local ret={} local ret={}
while coroutine.status(cr)~="dead" do while coroutine.status(cr)~="dead" do
...@@ -65,24 +88,4 @@ function cm.IgnoreActionCheck(f,...) ...@@ -65,24 +88,4 @@ function cm.IgnoreActionCheck(f,...)
for i=2,#sret do for i=2,#sret do
table.insert(ret,sret[i]) table.insert(ret,sret[i])
end end
end end]]
Duel.DisableActionCheck(false) \ No newline at end of file
return table.unpack(ret)
end
function cm.discost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsDiscardable() end
Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD)
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE)
end
function cm.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp,eg,ep,ev,re,r,rp)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment