Commit c231efb9 authored by POLYMER's avatar POLYMER

fix

parent 0b0c3e21
...@@ -71,6 +71,66 @@ function cm.hspgcheck(lv,tp) ...@@ -71,6 +71,66 @@ function cm.hspgcheck(lv,tp)
return cm.fselect(g,lv,tp) --g:CheckSubGroup(cm.fselect,1,#g,lv,tp) return cm.fselect(g,lv,tp) --g:CheckSubGroup(cm.fselect,1,#g,lv,tp)
end end
end end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then
for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end
end
if #sg<max then cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params) end
end
sg:RemoveCard(c)
eg:Sub(eg:Filter(cm.slfilter,nil,c))
end
end
function cm.slfilter(c,sc)
return cm.lvplus(c)==cm.lvplus(sc)
end
function cm.SelectSubGroup(g,tp,f,cancelable,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
Auxiliary.SubGroupCaptured=Group.CreateGroup()
cm.CheckGroupRecursiveCapture(true,sg,g,f,min,max,ext_params)
local cg=Auxiliary.SubGroupCaptured:Clone()
Auxiliary.SubGroupCaptured:Clear()
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
end
function cm.acop(e,tp,eg,ep,ev,re,r,rp) function cm.acop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_DECK,0,1,1,nil,tp) local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_DECK,0,1,1,nil,tp)
...@@ -143,7 +203,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -143,7 +203,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
tc=tg:Select(tp,1,1,nil):GetFirst() tc=tg:Select(tp,1,1,nil):GetFirst()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp) aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp)
rg=mg:SelectSubGroup(tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp) rg=cm.SelectSubGroup(mg,tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
end end
Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil)) Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil))
......
...@@ -67,6 +67,66 @@ function cm.hspgcheck(lv,tp) ...@@ -67,6 +67,66 @@ function cm.hspgcheck(lv,tp)
return cm.fselect(g,lv,tp) return cm.fselect(g,lv,tp)
end end
end end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then
for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end
end
if #sg<max then cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params) end
end
sg:RemoveCard(c)
eg:Sub(eg:Filter(cm.slfilter,nil,c))
end
end
function cm.slfilter(c,sc)
return cm.lvplus(c)==cm.lvplus(sc)
end
function cm.SelectSubGroup(g,tp,f,cancelable,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
Auxiliary.SubGroupCaptured=Group.CreateGroup()
cm.CheckGroupRecursiveCapture(true,sg,g,f,min,max,ext_params)
local cg=Auxiliary.SubGroupCaptured:Clone()
Auxiliary.SubGroupCaptured:Clear()
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
end
function cm.sctg(e,tp,eg,ep,ev,re,r,rp,chk) function cm.sctg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
...@@ -124,7 +184,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -124,7 +184,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
tc=tg:Select(tp,1,1,nil):GetFirst() tc=tg:Select(tp,1,1,nil):GetFirst()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp) aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp)
rg=mg:SelectSubGroup(tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp) rg=cm.SelectSubGroup(mg,tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
end end
Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil)) Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil))
......
...@@ -101,6 +101,66 @@ function cm.hspgcheck(lv,tp) ...@@ -101,6 +101,66 @@ function cm.hspgcheck(lv,tp)
return cm.fselect(g,lv,tp) return cm.fselect(g,lv,tp)
end end
end end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then
for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end
end
if #sg<max then cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params) end
end
sg:RemoveCard(c)
eg:Sub(eg:Filter(cm.slfilter,nil,c))
end
end
function cm.slfilter(c,sc)
return cm.lvplus(c)==cm.lvplus(sc)
end
function cm.SelectSubGroup(g,tp,f,cancelable,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
Auxiliary.SubGroupCaptured=Group.CreateGroup()
cm.CheckGroupRecursiveCapture(true,sg,g,f,min,max,ext_params)
local cg=Auxiliary.SubGroupCaptured:Clone()
Auxiliary.SubGroupCaptured:Clear()
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
end
function cm.pccost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.pccost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return not c:IsPublic() end if chk==0 then return not c:IsPublic() end
...@@ -180,7 +240,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -180,7 +240,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
tc=tg:Select(tp,1,1,nil):GetFirst() tc=tg:Select(tp,1,1,nil):GetFirst()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp) aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp)
rg=mg:SelectSubGroup(tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp) rg=cm.SelectSubGroup(mg,tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
end end
Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil)) Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil))
......
...@@ -85,6 +85,66 @@ function cm.hspgcheck(lv,tp) ...@@ -85,6 +85,66 @@ function cm.hspgcheck(lv,tp)
return cm.fselect(g,lv,tp) return cm.fselect(g,lv,tp)
end end
end end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then
for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end
end
if #sg<max then cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params) end
end
sg:RemoveCard(c)
eg:Sub(eg:Filter(cm.slfilter,nil,c))
end
end
function cm.slfilter(c,sc)
return cm.lvplus(c)==cm.lvplus(sc)
end
function cm.SelectSubGroup(g,tp,f,cancelable,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
Auxiliary.SubGroupCaptured=Group.CreateGroup()
cm.CheckGroupRecursiveCapture(true,sg,g,f,min,max,ext_params)
local cg=Auxiliary.SubGroupCaptured:Clone()
Auxiliary.SubGroupCaptured:Clear()
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
end
function cm.chcost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.chcost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return not c:IsPublic() end if chk==0 then return not c:IsPublic() end
...@@ -158,7 +218,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -158,7 +218,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
tc=tg:Select(tp,1,1,nil):GetFirst() tc=tg:Select(tp,1,1,nil):GetFirst()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp) aux.GCheckAdditional=cm.hspgcheck(cm.lvplus(tc),tp)
rg=mg:SelectSubGroup(tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp) rg=cm.SelectSubGroup(mg,tp,cm.hspcheck,true,1,#mg,cm.lvplus(tc),tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
end end
Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil)) Duel.ConfirmCards(1-tp,rg:Filter(Card.IsFacedown,nil))
......
...@@ -84,7 +84,7 @@ function cm.fselect(g,ng,goal,tp) ...@@ -84,7 +84,7 @@ function cm.fselect(g,ng,goal,tp)
return true return true
end end
aux.GCheckAdditional=cm.hspgcheck2(g,g:GetSum(cm.lvplus)-goal,tp) aux.GCheckAdditional=cm.hspgcheck2(g,g:GetSum(cm.lvplus)-goal,tp)
local tc=ng:CheckSubGroup(cm.fselect3,1,#ng,g,g:GetSum(cm.lvplus)-goal,tp) local tc=cm.CheckSubGroup(ng,cm.fselect3,1,#ng,g,g:GetSum(cm.lvplus)-goal,tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
return tc return tc
end end
...@@ -103,6 +103,89 @@ function cm.hspgcheck2(ng,goal,tp) ...@@ -103,6 +103,89 @@ function cm.hspgcheck2(ng,goal,tp)
return cm.fselect3(g,ng,goal,tp) return cm.fselect3(g,ng,goal,tp)
end end
end end
function cm.CheckSubGroup(g,f,min,max,...)
local min=min or 1
local max=max or #g
if min>max then return false end
local ext_params={...}
local sg=Duel.GrabSelectedCard()
if #sg>max or #(g+sg)<min then return false end
if #sg==max and (not f(sg,...) or Auxiliary.GCheckAdditional and not Auxiliary.GCheckAdditional(sg,nil,g,f,min,max,ext_params)) then return false end
if #sg>=min and #sg<=max and f(sg,...) and (not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,nil,g,f,min,max,ext_params)) then return true end
return cm.CheckGroupRecursive(sg,g,f,min,max,ext_params)
end
function cm.CheckGroupRecursive(sg,g,f,min,max,ext_params)
local eg=g:Clone()
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) or (#sg<max and cm.CheckGroupRecursive(sg,eg,f,min,max,ext_params)) then return true end
end
sg:RemoveCard(c)
eg:RemoveCard(c)
end
return false
end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then
for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end
end
if #sg<max then cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params) end
end
sg:RemoveCard(c)
eg:Sub(eg:Filter(cm.slfilter,nil,c))
end
end
function cm.slfilter(c,sc)
return cm.lvplus(c)==cm.lvplus(sc)
end
function cm.SelectSubGroup(g,tp,f,cancelable,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
Auxiliary.SubGroupCaptured=Group.CreateGroup()
cm.CheckGroupRecursiveCapture(true,sg,g,f,min,max,ext_params)
local cg=Auxiliary.SubGroupCaptured:Clone()
Auxiliary.SubGroupCaptured:Clear()
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
end
function cm.accost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.accost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return not c:IsPublic() end if chk==0 then return not c:IsPublic() end
...@@ -135,7 +218,7 @@ function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -135,7 +218,7 @@ function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local tg=Group.CreateGroup() local tg=Group.CreateGroup()
for sc in aux.Next(sg) do for sc in aux.Next(sg) do
--aux.GCheckAdditional=cm.hspgcheck --aux.GCheckAdditional=cm.hspgcheck
local tc=trg:CheckSubGroup(cm.fselect,1,#trg,ng,cm.lvplus(sc),tp) local tc=cm.CheckSubGroup(trg,cm.fselect,1,#trg,ng,cm.lvplus(sc),tp)
--aux.GCheckAdditional=nil --aux.GCheckAdditional=nil
if tc then return true end if tc then return true end
end end
...@@ -153,7 +236,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -153,7 +236,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
local tg=Group.CreateGroup() local tg=Group.CreateGroup()
for sc in aux.Next(sg) do for sc in aux.Next(sg) do
--aux.GCheckAdditional=cm.hspgcheck --aux.GCheckAdditional=cm.hspgcheck
local tc=trg:CheckSubGroup(cm.fselect,1,#trg,ng,cm.lvplus(sc),tp) local tc=cm.CheckSubGroup(trg,cm.fselect,1,#trg,ng,cm.lvplus(sc),tp)
--aux.GCheckAdditional=nil --aux.GCheckAdditional=nil
if tc then tg:AddCard(sc) end if tc then tg:AddCard(sc) end
end end
...@@ -170,7 +253,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -170,7 +253,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
if rg and #rg>0 and rg:GetSum(cm.lvplus)>cm.lvplus(tc) then if rg and #rg>0 and rg:GetSum(cm.lvplus)>cm.lvplus(tc) then
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(m,7)) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(m,7))
aux.GCheckAdditional=cm.hspgcheck2(rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp) aux.GCheckAdditional=cm.hspgcheck2(rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp)
rg2=ng:SelectSubGroup(tp,cm.fselect3,true,1,#ng,rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp) rg2=cm.SelectSubGroup(ng,tp,cm.fselect3,true,1,#ng,rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
if rg2 and #rg2>0 then if rg2 and #rg2>0 then
res=true res=true
......
...@@ -87,7 +87,7 @@ function cm.fselect(g,ng,goal,tp) ...@@ -87,7 +87,7 @@ function cm.fselect(g,ng,goal,tp)
return true return true
end end
aux.GCheckAdditional=cm.hspgcheck2(g,g:GetSum(cm.lvplus)-goal,tp) aux.GCheckAdditional=cm.hspgcheck2(g,g:GetSum(cm.lvplus)-goal,tp)
local tc=ng:CheckSubGroup(cm.fselect3,1,#ng,g,g:GetSum(cm.lvplus)-goal,tp) local tc=cm.CheckSubGroup(ng,cm.fselect3,1,#ng,g,g:GetSum(cm.lvplus)-goal,tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
return tc return tc
end end
...@@ -106,6 +106,89 @@ function cm.hspgcheck2(ng,goal,tp) ...@@ -106,6 +106,89 @@ function cm.hspgcheck2(ng,goal,tp)
return cm.fselect3(g,ng,goal,tp) return cm.fselect3(g,ng,goal,tp)
end end
end end
function cm.CheckSubGroup(g,f,min,max,...)
local min=min or 1
local max=max or #g
if min>max then return false end
local ext_params={...}
local sg=Duel.GrabSelectedCard()
if #sg>max or #(g+sg)<min then return false end
if #sg==max and (not f(sg,...) or Auxiliary.GCheckAdditional and not Auxiliary.GCheckAdditional(sg,nil,g,f,min,max,ext_params)) then return false end
if #sg>=min and #sg<=max and f(sg,...) and (not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,nil,g,f,min,max,ext_params)) then return true end
return cm.CheckGroupRecursive(sg,g,f,min,max,ext_params)
end
function cm.CheckGroupRecursive(sg,g,f,min,max,ext_params)
local eg=g:Clone()
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) or (#sg<max and cm.CheckGroupRecursive(sg,eg,f,min,max,ext_params)) then return true end
end
sg:RemoveCard(c)
eg:RemoveCard(c)
end
return false
end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do
sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then
for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end
end
if #sg<max then cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params) end
end
sg:RemoveCard(c)
eg:Sub(eg:Filter(cm.slfilter,nil,c))
end
end
function cm.slfilter(c,sc)
return cm.lvplus(c)==cm.lvplus(sc)
end
function cm.SelectSubGroup(g,tp,f,cancelable,min,max,...)
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
Auxiliary.SubGroupCaptured=Group.CreateGroup()
cm.CheckGroupRecursiveCapture(true,sg,g,f,min,max,ext_params)
local cg=Auxiliary.SubGroupCaptured:Clone()
Auxiliary.SubGroupCaptured:Clear()
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
end
function cm.chcost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.chcost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return not c:IsPublic() end if chk==0 then return not c:IsPublic() end
...@@ -175,7 +258,7 @@ function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -175,7 +258,7 @@ function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local tg=Group.CreateGroup() local tg=Group.CreateGroup()
for sc in aux.Next(sg) do for sc in aux.Next(sg) do
--aux.GCheckAdditional=cm.hspgcheck --aux.GCheckAdditional=cm.hspgcheck
local tc=trg:CheckSubGroup(cm.fselect,1,#trg,ng,cm.lvplus(sc),tp) local tc=cm.CheckSubGroup(trg,cm.fselect,1,#trg,ng,cm.lvplus(sc),tp)
--aux.GCheckAdditional=nil --aux.GCheckAdditional=nil
if tc then return true end if tc then return true end
end end
...@@ -193,7 +276,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -193,7 +276,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
local tg=Group.CreateGroup() local tg=Group.CreateGroup()
for sc in aux.Next(sg) do for sc in aux.Next(sg) do
--aux.GCheckAdditional=cm.hspgcheck --aux.GCheckAdditional=cm.hspgcheck
local tc=trg:CheckSubGroup(cm.fselect,1,#trg,ng,cm.lvplus(sc),tp) local tc=cm.CheckSubGroup(trg,cm.fselect,1,#trg,ng,cm.lvplus(sc),tp)
--aux.GCheckAdditional=nil --aux.GCheckAdditional=nil
if tc then tg:AddCard(sc) end if tc then tg:AddCard(sc) end
end end
...@@ -210,7 +293,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -210,7 +293,7 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
if rg and #rg>0 and rg:GetSum(cm.lvplus)>cm.lvplus(tc) then if rg and #rg>0 and rg:GetSum(cm.lvplus)>cm.lvplus(tc) then
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(m,7)) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(m,7))
aux.GCheckAdditional=cm.hspgcheck2(rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp) aux.GCheckAdditional=cm.hspgcheck2(rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp)
rg2=ng:SelectSubGroup(tp,cm.fselect3,true,1,#ng,rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp) rg2=cm.SelectSubGroup(ng,tp,cm.fselect3,true,1,#ng,rg,rg:GetSum(cm.lvplus)-cm.lvplus(tc),tp)
aux.GCheckAdditional=nil aux.GCheckAdditional=nil
if rg2 and #rg2>0 then if rg2 and #rg2>0 then
res=true res=true
......
...@@ -61,13 +61,14 @@ function cm.CheckGroupRecursive(sg,g,f,min,max,ext_params) ...@@ -61,13 +61,14 @@ function cm.CheckGroupRecursive(sg,g,f,min,max,ext_params)
end end
function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params) function cm.CheckGroupRecursiveCapture(bool,sg,g,f,min,max,ext_params)
local eg=g:Clone() local eg=g:Clone()
if bool then cm.esg=sg:Clone() end
for c in aux.Next(g-sg) do for c in aux.Next(g-sg) do
if not bool or not Auxiliary.SubGroupCaptured:IsContains(c) then if not bool or not Auxiliary.SubGroupCaptured:IsContains(c) then
sg:AddCard(c) sg:AddCard(c)
if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then if not Auxiliary.GCheckAdditional or Auxiliary.GCheckAdditional(sg,c,eg,f,min,max,ext_params) then
if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then -- or (#sg<max and cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params)) then if (#sg>=min and #sg<=max and f(sg,table.unpack(ext_params))) then -- or (#sg<max and cm.CheckGroupRecursiveCapture(false,sg,eg,f,min,max,ext_params)) then
--Debug.Message(cm[0]) --Debug.Message(cm[0])
for sc in aux.Next(sg) do for sc in aux.Next(sg-cm.esg) do
Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc)) Auxiliary.SubGroupCaptured:Merge(eg:Filter(cm.slfilter,nil,sc))
end end
end end
......
...@@ -16,7 +16,7 @@ function c60152905.initial_effect(c) ...@@ -16,7 +16,7 @@ function c60152905.initial_effect(c)
e1:SetOperation(c60152905.e1op) e1:SetOperation(c60152905.e1op)
c:RegisterEffect(e1) c:RegisterEffect(e1)
Duel.AddCustomActivityCounter(60152905,ACTIVITY_CHAIN,aux.TRUE) Duel.AddCustomActivityCounter(60152905,ACTIVITY_CHAIN,c60152905.chainfilter)
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(60152905,1)) e2:SetDescription(aux.Stringid(60152905,1))
...@@ -25,7 +25,7 @@ function c60152905.initial_effect(c) ...@@ -25,7 +25,7 @@ function c60152905.initial_effect(c)
e2:SetCode(EVENT_FREE_CHAIN) e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_MZONE) e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,6012905) e2:SetCountLimit(1,6012905)
e2:SetCondition(c60152905.con) e2:SetCondition(c60152905.e2con)
e2:SetTarget(c60152905.e2tg) e2:SetTarget(c60152905.e2tg)
e2:SetOperation(c60152905.e2op) e2:SetOperation(c60152905.e2op)
c:RegisterEffect(e2) c:RegisterEffect(e2)
...@@ -42,6 +42,10 @@ function c60152905.initial_effect(c) ...@@ -42,6 +42,10 @@ function c60152905.initial_effect(c)
e3:SetOperation(c60152905.e3op) e3:SetOperation(c60152905.e3op)
c:RegisterEffect(e3) c:RegisterEffect(e3)
end end
function c60152905.chainfilter(re,tp,cid)
local tp=re:GetControler()
return not (re:IsControler(1-tp))
end
function c60152905.con(e,tp,eg,ep,ev,re,r,rp) function c60152905.con(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(Card.IsFacedown,tp,LOCATION_EXTRA,0,nil)==0 return Duel.GetMatchingGroupCount(Card.IsFacedown,tp,LOCATION_EXTRA,0,nil)==0
end end
...@@ -103,9 +107,12 @@ function c60152905.e1op(e,tp,eg,ep,ev,re,r,rp) ...@@ -103,9 +107,12 @@ function c60152905.e1op(e,tp,eg,ep,ev,re,r,rp)
tc:CompleteProcedure() tc:CompleteProcedure()
end end
end end
function c60152905.e2con(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCustomActivityCount(60152905,tp,ACTIVITY_CHAIN)>0
end
function c60152905.e2tg(e,tp,eg,ep,ev,re,r,rp,chk) function c60152905.e2tg(e,tp,eg,ep,ev,re,r,rp,chk)
local p=PLAYER_ALL local p=PLAYER_ALL
if chk==0 then return Duel.GetCustomActivityCount(60152905,1-tp,ACTIVITY_CHAIN)~=0 end if chk==0 then return true end
Duel.SetTargetPlayer(p) Duel.SetTargetPlayer(p)
Duel.SetTargetParam(1000) Duel.SetTargetParam(1000)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,p,1000) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,p,1000)
......
...@@ -106,7 +106,7 @@ function c60152913.e3op(e,tp,eg,ep,ev,re,r,rp) ...@@ -106,7 +106,7 @@ function c60152913.e3op(e,tp,eg,ep,ev,re,r,rp)
e5:SetCode(EVENT_FREE_CHAIN) e5:SetCode(EVENT_FREE_CHAIN)
e5:SetRange(LOCATION_MZONE) e5:SetRange(LOCATION_MZONE)
e5:SetCountLimit(1,6012905) e5:SetCountLimit(1,6012905)
e5:SetCondition(c60152913.con) e5:SetCondition(c60152913.e22905con)
e5:SetTarget(c60152913.e22905tg) e5:SetTarget(c60152913.e22905tg)
e5:SetOperation(c60152913.e22905op) e5:SetOperation(c60152913.e22905op)
c:RegisterEffect(e5) c:RegisterEffect(e5)
...@@ -290,9 +290,12 @@ function c60152913.e22904op(e,tp,eg,ep,ev,re,r,rp) ...@@ -290,9 +290,12 @@ function c60152913.e22904op(e,tp,eg,ep,ev,re,r,rp)
end end
end end
end end
function c60152913.e22905con(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCustomActivityCount(60152905,tp,ACTIVITY_CHAIN)>0
end
function c60152913.e22905tg(e,tp,eg,ep,ev,re,r,rp,chk) function c60152913.e22905tg(e,tp,eg,ep,ev,re,r,rp,chk)
local p=PLAYER_ALL local p=PLAYER_ALL
if chk==0 then return Duel.GetCustomActivityCount(60152905,1-tp,ACTIVITY_CHAIN)~=0 end if chk==0 then return true end
Duel.SetTargetPlayer(p) Duel.SetTargetPlayer(p)
Duel.SetTargetParam(1000) Duel.SetTargetParam(1000)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,p,1000) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,p,1000)
......
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