Commit 99f69137 authored by nanahira's avatar nanahira

archive

parent 8537695a
......@@ -134,63 +134,19 @@ function cm.RegisterSingleEffect(c,setcd)
return e1
end
function cm.GetValueType(v)
local t=type(v)
if t=="userdata" then
local mt=getmetatable(v)
if mt==Group then return "Group"
elseif mt==Effect then return "Effect"
else return "Card" end
else return t end
end
function cm.CheckGroupRecursive(c,sg,g,f,min,max,ext_params)
sg:AddCard(c)
local res=(#sg>=min and #sg<=max and f(sg,table.unpack(ext_params)))
or (#sg<max and g:IsExists(cm.CheckGroupRecursive,1,sg,sg,g,f,min,max,ext_params))
sg:RemoveCard(c)
return res
return aux.GetValueType(v)
end
function cm.CheckGroup(g,f,cg,min,max,...)
local min=min or 1
local max=max or #g
if min>max then return false end
local ext_params={...}
local sg=Group.CreateGroup()
if cg then sg:Merge(cg) end
if #sg>=min and #sg<=max and f(sg,...) then return true end
return g:IsExists(cm.CheckGroupRecursive,1,sg,sg,g,f,min,max,ext_params)
if cg then Duel.SetSelectedCard(cg) end
return g:CheckSubGroup(g,f,min,max,...)
end
function cm.SelectGroupNew(tp,desc,cancelable,g,f,cg,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local cg=cg or Group.CreateGroup()
sg:Merge(cg)
local ag=g:Filter(cm.CheckGroupRecursive,sg,sg,g,f,min,max,ext_params)
while #sg<max and #ag>0 do
local seg=sg:Clone()
seg:Sub(cg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
local cancel=cancelable and not finish
local dmin=#sg
local dmax=math.min(max,#g)
local tc=nil
repeat
Duel.Hint(HINT_SELECTMSG,tp,desc)
tc=ag:SelectUnselect(sg,tp,finish,cancel,dmin,dmax)
until not tc or ag:IsContains(tc) or seg:IsContains(tc)
if not tc then
if not finish then return end
break
end
if sg:IsContains(tc) then
sg:RemoveCard(tc)
else
sg:AddCard(tc)
end
ag=g:Filter(cm.CheckGroupRecursive,sg,sg,g,f,min,max,ext_params)
end
return sg
if cg then Duel.SetSelectedCard(cg) end
Duel.Hint(tp,HINT_SELECTMSG,desc)
return g:SelectSubGroup(tp,f,cancelable,min,max,...)
end
function cm.SelectGroup(tp,desc,g,f,cg,min,max,...)
return cm.SelectGroupNew(tp,desc,false,g,f,cg,min,max,...)
......@@ -961,6 +917,14 @@ function cm.Nanahira(c)
c:RegisterEffect(e2)
end
function cm.NanahiraPendulum(c)
if not PENDULUM_CHECKLIST then
PENDULUM_CHECKLIST=0
local ge1=Effect.GlobalEffect()
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_PHASE_START+PHASE_DRAW)
ge1:SetOperation(Auxiliary.PendulumReset)
Duel.RegisterEffect(ge1,0)
end
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
......@@ -977,7 +941,6 @@ function cm.NanahiraPendulum(c)
e1:SetCode(EFFECT_SPSUMMON_PROC_G)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1,10000000)
e1:SetCondition(cm.PendConditionNanahira())
e1:SetOperation(cm.PendOperationNanahira())
e1:SetValue(SUMMON_TYPE_PENDULUM)
......@@ -1035,6 +998,7 @@ function cm.PendConditionNanahira()
return function(e,c,og)
if c==nil then return true end
local tp=c:GetControler()
if PENDULUM_CHECKLIST&(0x1<<tp)~=0 then return false end
local rpz=cm.GetPendulumCard(tp,1)
if rpz==nil or c==rpz then return false end
local lscale=c:GetLeftScale()
......@@ -1132,7 +1096,9 @@ function cm.PendOperationNanahira()
else
maxlist[LOCATION_EXTRA]=ect
end
local g=cm.SelectGroup(tp,HINTMSG_SPSUMMON,tg,cm.PendCheckNanahira,nil,1,ft,mft,maxlist)
local g=cm.SelectGroupWithCancel(tp,HINTMSG_SPSUMMON,tg,cm.PendCheckNanahira,nil,1,ft,mft,maxlist)
if not g then return end
PENDULUM_CHECKLIST=PENDULUM_CHECKLIST|(0x1<<tp)
sg:Merge(g)
Duel.HintSelection(Group.FromCards(c))
Duel.HintSelection(Group.FromCards(rpz))
......
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