Commit 1f95c83a authored by VanillaSalt's avatar VanillaSalt

tweak

parent 9cfae0c8
--覇王龍ズァーク
function c13331639.initial_effect(c)
c:EnableReviveLimit()
--aux.AddFusionProcFunMulti(c,false,c13331639.filters)
aux.AddFusionProcMix(c,false,true,c13331639.fusfilter1,c13331639.fusfilter2,c13331639.fusfilter3,c13331639.fusfilter4)
aux.EnablePendulumAttribute(c,false)
--fusion procedure
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetCode(EFFECT_FUSION_MATERIAL)
e0:SetCondition(c13331639.fuscon)
e0:SetOperation(c13331639.fusop)
c:RegisterEffect(e0)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
......@@ -94,246 +86,6 @@ end
function c13331639.fusfilter4(c)
return c:IsRace(RACE_DRAGON) and c:IsFusionType(TYPE_PENDULUM)
end
c13331639.filters={c13331639.fusfilter1,c13331639.fusfilter2,c13331639.fusfilter3,c13331639.fusfilter4}
-- TO BE REMOVED ONCE THE UTILITIES ARE UPDATED
function c13331639.FConditionFilterMultiOr(c,funs,n)
for i=1,n do
if funs[i](c) then return true end
end
return false
end
function c13331639.FConditionFilterMulti(c,mg,funs,n,tbt)
for i=1,n do
local tp=2^(i-1)
if bit.band(tbt,tp)~=0 and funs[i](c) then
local t2=tbt-tp
if t2==0 then return true end
local mg2=mg:Clone()
mg2:RemoveCard(c)
if mg2:IsExists(c13331639.FConditionFilterMulti,1,nil,mg2,funs,n,t2) then return true end
end
end
return false
end
function c13331639.CloneTable(g)
local ng={}
for i=1,#g do
local sg=g[i]:Clone()
table.insert(ng,sg)
end
return ng
end
function c13331639.FConditionFilterMulti2(c,gr)
local gr2=c13331639.CloneTable(gr)
for i=1,#gr2 do
gr2[i]:RemoveCard(c)
end
table.remove(gr2,1)
if #gr2==1 then
return gr2[1]:IsExists(aux.TRUE,1,nil)
else
return gr2[1]:IsExists(c13331639.FConditionFilterMulti2,1,nil,gr2)
end
end
function c13331639.FConditionFilterMultiSelect(c,funs,n,mg,sg)
local valid=c13331639.FConditionFilterMultiValid(sg,funs,n)
if not valid then valid={0} end
local all = (2^n)-1
for k,v in pairs(valid) do
v=bit.bxor(all,v)
if c13331639.FConditionFilterMulti(c,mg,funs,n,v) then return true end
end
return false
end
function c13331639.FConditionFilterMultiValid(g,funs,n)
local tp={}
local tc=g:GetFirst()
while tc do
local tp1={}
for i=1,n do
if funs[i](tc) then table.insert(tp1,2^(i-1)) end
end
table.insert(tp,tp1)
tc=g:GetNext()
end
return c13331639.FConditionMultiGenerateValids(tp,n)
end
function c13331639.FConditionMultiGenerateValids(vs,n)
local c=2
while #vs > 1 do
local v1=vs[1]
table.remove(vs,1)
local v2=vs[1]
table.remove(vs,1)
table.insert(vs,1,c13331639.FConditionMultiCombine(v1,v2,n,c))
c=c+1
end
return vs[1]
end
function c13331639.FConditionMultiCombine(t1,t2,n,c)
local res={}
for k1,v1 in pairs(t1) do
for k2,v2 in pairs(t2) do
table.insert(res,bit.bor(v1,v2))
end
end
res=c13331639.FConditionMultiCheckCount(res,n)
return c13331639.FConditionFilterMultiClean(res)
end
function c13331639.FConditionMultiCheckCount(vals,n)
local res={} local flags={}
for k,v in pairs(vals) do
local c=0
for i=1,n do
if bit.band(v,2^(i-1))~=0 then c=c+1 end
end
if not flags[c] then
res[c] = {v}
flags[c] = true
else
table.insert(res[c],v)
end
end
local mk=0
for k,v in pairs(flags) do
if k>mk then mk=k end
end
return res[mk]
end
function c13331639.FConditionFilterMultiClean(vals)
local res={} local flags={}
for k,v in pairs(vals) do
if not flags[v] then
table.insert(res,v)
flags[v] = true
end
end
return res
end
function c13331639.fuscon(e,g,gc,chkfnf)
local c=e:GetHandler()
if g==nil then return true end
if c:IsFaceup() then return false end
local chkf=bit.band(chkfnf,0xff)
local funs=c13331639.filters
local n=4
local mg=g:Filter(Card.IsCanBeFusionMaterial,nil,c):Filter(c13331639.FConditionFilterMultiOr,nil,funs,n)
if gc then
if not gc:IsCanBeFusionMaterial(c) then return false end
local check_tot=(2^n)-1
local mg2=mg:Clone()
mg2:RemoveCard(gc)
for i=1,n do
if funs[i](gc) then
local tbt=check_tot-2^(i-1)
if mg2:IsExists(c13331639.FConditionFilterMulti,1,nil,mg2,funs,n,tbt) then return true end
end
end
return false
end
local fs=false
local groups={}
for i=1,n do
table.insert(groups,Group.CreateGroup())
end
local tc=mg:GetFirst()
while tc do
for i=1,n do
if funs[i](tc) then
groups[i]:AddCard(tc)
if Auxiliary.FConditionCheckF(tc,chkf) then fs=true end
end
end
tc=mg:GetNext()
end
local gr2=c13331639.CloneTable(groups)
if chkf~=PLAYER_NONE then
return fs and gr2[1]:IsExists(c13331639.FConditionFilterMulti2,1,nil,gr2)
else
return gr2[1]:IsExists(c13331639.FConditionFilterMulti2,1,nil,gr2)
end
end
function c13331639.fusop(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf)
local c=e:GetHandler()
local chkf=bit.band(chkfnf,0xff)
local funs=c13331639.filters
local n=4
local g=eg:Filter(Card.IsCanBeFusionMaterial,nil,c):Filter(c13331639.FConditionFilterMultiOr,nil,funs,n)
if gc then
local sg=Group.FromCards(gc)
local mg=g:Clone()
mg:RemoveCard(gc)
for i=1,n-1 do
local mg2=mg:Filter(c13331639.FConditionFilterMultiSelect,nil,funs,n,mg,sg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local sg2=mg2:Select(tp,1,1,nil)
sg:AddCard(sg2:GetFirst())
mg:RemoveCard(sg2:GetFirst())
end
Duel.SetFusionMaterial(sg)
return
end
local sg=Group.CreateGroup()
local mg=g:Clone()
for i=1,n do
local mg2=mg:Filter(c13331639.FConditionFilterMultiSelect,nil,funs,n,mg,sg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local sg2=nil
if i==1 and chkf~=PLAYER_NONE then
sg2=mg2:FilterSelect(tp,Auxiliary.FConditionCheckF,1,1,nil,chkf)
else
sg2=mg2:Select(tp,1,1,nil)
end
sg:AddCard(sg2:GetFirst())
mg:RemoveCard(sg2:GetFirst())
end
Duel.SetFusionMaterial(sg)
end
-- END SECTION TO BE REMOVED
function c13331639.check_fusion_material_48144509(g,chkf)
local fs=false
local mg=g:Filter(Card.IsLocation,nil,LOCATION_HAND+LOCATION_MZONE)
local funs=c13331639.filters
local groups={}
for i=1,4 do
table.insert(groups,Group.CreateGroup())
end
local tc=mg:GetFirst()
while tc do
for i=1,4 do
if funs[i](tc) then
groups[i]:AddCard(tc)
if Auxiliary.FConditionCheckF(tc,chkf) then fs=true end
end
end
tc=mg:GetNext()
end
local gr2=c13331639.CloneTable(groups)
if chkf~=PLAYER_NONE then
return fs and gr2[1]:IsExists(c13331639.FConditionFilterMulti2,1,nil,gr2)
else
return gr2[1]:IsExists(c13331639.FConditionFilterMulti2,1,nil,gr2)
end
end
function c13331639.select_fusion_material_48144509(tp,g,chkf)
local mg=g:Filter(Card.IsLocation,nil,LOCATION_HAND+LOCATION_MZONE)
local sg=Group.CreateGroup()
local funs=c13331639.filters
for i=1,4 do
local mg2=mg:Filter(c13331639.FConditionFilterMultiSelect,nil,funs,4,mg,sg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local sg2=nil
if i==1 and chkf~=PLAYER_NONE then
sg2=mg2:FilterSelect(tp,Auxiliary.FConditionCheckF,1,1,nil,chkf)
else
sg2=mg2:Select(tp,1,1,nil)
end
sg:AddCard(sg2:GetFirst())
mg:RemoveCard(sg2:GetFirst())
end
Duel.SetFusionMaterial(sg)
return sg
end
function c13331639.limval(e,re,rp)
local rc=re:GetHandler()
return rc:IsLocation(LOCATION_MZONE) and re:IsActiveType(TYPE_MONSTER)
......
......@@ -23,26 +23,20 @@ function c48144509.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and c:IsRace(RACE_DRAGON) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
--fusion monster filter
--check_fusion_material_48144509: for dragon-type monsters that >2 odd-eye is possible
function c48144509.filter3(c,e,tp,m,f,chkf)
local mg=m:Clone()
mg:RemoveCard(c)
if c:IsType(TYPE_FUSION) and c:IsRace(RACE_DRAGON) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) then
if c.check_fusion_material_48144509 then return c.check_fusion_material_48144509(mg,chkf) end
return c:CheckFusionMaterial(mg,nil,chkf)
else return false end
function c48144509.fcheck(tp,sg,fc)
return not sg:IsContains(fc) and sg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)<=2
end
function c48144509.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp):Filter(Card.IsAbleToGrave,nil)
if Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>1 then
Auxiliary.FCheckAdditional=c48144509.fcheck
local sg=Duel.GetMatchingGroup(c48144509.exfilter0,tp,LOCATION_EXTRA,0,nil)
mg1:Merge(sg)
end
local res=Duel.IsExistingMatchingCard(c48144509.filter3,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
local res=Duel.IsExistingMatchingCard(c48144509.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
Auxiliary.FCheckAdditional=nil
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
......@@ -59,11 +53,15 @@ end
function c48144509.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c48144509.filter1,nil,e)
local exmat=false
if Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>1 then
exmat=true
local sg=Duel.GetMatchingGroup(c48144509.exfilter1,tp,LOCATION_EXTRA,0,nil,e)
mg1:Merge(sg)
end
local sg1=Duel.GetMatchingGroup(c48144509.filter3,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
if exmat then Auxiliary.FCheckAdditional=c48144509.fcheck end
local sg1=Duel.GetMatchingGroup(c48144509.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
Auxiliary.FCheckAdditional=nil
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
......@@ -81,12 +79,9 @@ function c48144509.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=tg:GetFirst()
mg1:RemoveCard(tc)
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=nil
if tc.select_fusion_material_48144509 then
mat1=tc.select_fusion_material_48144509(tp,mg1,chkf)
else
mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
end
if exmat then Auxiliary.FCheckAdditional=c48144509.fcheck end
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
Auxiliary.FCheckAdditional=nil
tc:SetMaterial(mat1)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
......
......@@ -2,5 +2,5 @@
function c54401832.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFunFunRep(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0xe1),aux.FilterBoolFunction(Card.IsAttackBelow,3000),2,2,true)
aux.AddFusionProcFunFun(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0xe1),aux.FilterBoolFunction(Card.IsAttackBelow,3000),2,true)
end
......@@ -20,39 +20,3 @@ end
function c99267150.batfilter(e,c)
return c:IsAttribute(0x2f)
end
function c99267150.check_fusion_material_48144509(m,chkf)
local g1=m:Filter(Card.IsRace,nil,RACE_DRAGON)
if chkf~=PLAYER_NONE and not g1:IsExists(Card.IsOnField,1,nil) then return false end
local ct1=g1:GetCount()
local ct2=g1:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)
return (ct1-ct2)+math.min(ct2,2)>=5
end
function c99267150.select_fusion_material_48144509(tp,m,chkf)
local cc=5
local mg1=m:Filter(Card.IsRace,nil,RACE_DRAGON)
local mg2=mg1:Filter(Card.IsLocation,nil,LOCATION_EXTRA)
local sg=Group.CreateGroup()
if mg2:GetCount()>2 then
mg1:Sub(mg2)
if mg1:GetCount()<5 or Duel.SelectYesNo(tp,aux.Stringid(48144509,0)) then
local minc=1
if mg1:GetCount()<4 then minc=2 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local g=mg2:Select(tp,minc,2,nil)
sg:Merge(g)
cc=cc-g:GetCount()
end
end
if chkf~=PLAYER_NONE and mg1:GetCount()>cc then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local g=mg1:FilterSelect(tp,aux.FConditionCheckF,1,1,nil,chkf)
mg1:Sub(g)
sg:Merge(g)
cc=cc-1
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local g=mg1:Select(tp,cc,cc,nil)
sg:Merge(g)
Duel.SetFusionMaterial(sg)
return sg
end
......@@ -450,7 +450,11 @@ function Auxiliary.AddFusionProcMix(c,sub,insf,...)
if type(val[i])=='function' then
fun[i]=function(c) return val[i](c) and not c:IsHasEffect(6205579) end
else
if sub then
fun[i]=function(c,fc,sub) return c:IsFusionCode(val[i]) or (sub and c:CheckFusionSubstitute(fc)) end
else
fun[i]=function(c) return c:IsFusionCode(val[i]) end
end
table.insert(mat,val[i])
end
end
......@@ -472,7 +476,7 @@ function Auxiliary.FConditionMix(insf,sub,...)
--g:Material group(nil for Instant Fusion)
--gc:Material already used
--chkf: check field, default:PLAYER_NONE
local funs = {...}
local funs={...}
return function(e,g,gc,chkfnf)
if g==nil then return insf end
local chkf=bit.band(chkfnf,0xff)
......@@ -491,7 +495,7 @@ function Auxiliary.FConditionMix(insf,sub,...)
end
end
function Auxiliary.FOperationMix(insf,sub,...)
local funs = {...}
local funs={...}
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf)
local chkf=bit.band(chkfnf,0xff)
local c=e:GetHandler()
......@@ -510,27 +514,28 @@ function Auxiliary.FOperationMix(insf,sub,...)
end
end
function Auxiliary.FConditionFilterMix(c,fc,sub,...)
local funs={...}
for i=1,#funs do
if funs[i](c,fc,sub) then return true end
if not c:IsCanBeFusionMaterial(fc) then return false end
for i,f in ipairs({...}) do
if f(c,fc,sub) then return true end
end
return false
end
function Auxiliary.FCheckMix(c,mg,sg,fc,sub,fun1,fun2,...)
sg:AddCard(c)
local res
if fun2 then
res=(fun1(c,fc,false) and mg:IsExists(Auxiliary.FCheckMix,1,sg,mg,sg,fc,sub,fun2,...)
or fun1(c,fc,sub) and mg:IsExists(Auxiliary.FCheckMix,1,sg,mg,sg,fc,false,fun2,...))
else
res=fun1(c,fc,sub)
end
sg:AddCard(c)
local res=fun1(c,fc,false) and mg:IsExists(Auxiliary.FCheckMix,1,sg,mg,sg,fc,sub,fun2,...)
or sub and c:CheckFusionSubstitute(fc) and mg:IsExists(Auxiliary.FCheckMix,1,sg,mg,sg,fc,false,fun2,...)
sg:RemoveCard(c)
return res
else
return fun1(c,fc,sub)
end
end
Auxiliary.FCheckAdditional=nil
function Auxiliary.FCheckMixGoal(tp,sg,fc,sub,...)
local g=Group.CreateGroup()
return sg:IsExists(Auxiliary.FCheckMix,1,nil,sg,g,fc,sub,...) and Duel.GetLocationCountFromEx(tp,tp,sg,fc)>0
and (not Auxiliary.FCheckAdditional or Auxiliary.FCheckAdditional(tp,sg,fc))
end
function Auxiliary.FSelectMix(c,tp,mg,sg,fc,sub,...)
sg:AddCard(c)
......@@ -570,14 +575,13 @@ function Auxiliary.AddFusionProcCodeRep(c,code1,cc,sub,insf)
end
Auxiliary.AddFusionProcMix(c,sub,insf,table.unpack(code))
end
--Fusion monster, name + condition
--Fusion monster, name + condition * n
function Auxiliary.AddFusionProcCodeFun(c,code1,f,cc,sub,insf)
local fun={}
fun[1]=code1
for i=2,cc+1 do
for i=1,cc do
fun[i]=f
end
Auxiliary.AddFusionProcMix(c,sub,insf,table.unpack(fun))
Auxiliary.AddFusionProcMix(c,sub,insf,code1,table.unpack(fun))
end
--Fusion monster, condition + condition
function Auxiliary.AddFusionProcFun2(c,f1,f2,insf)
......@@ -591,6 +595,14 @@ function Auxiliary.AddFusionProcFunRep(c,f,cc,insf)
end
Auxiliary.AddFusionProcMix(c,false,insf,table.unpack(fun))
end
--Fusion monster, condition1 + condition2 * n
function Auxiliary.AddFusionProcFunFun(c,f1,f2,cc,sub,insf)
local fun={}
for i=1,cc do
fun[i]=f2
end
Auxiliary.AddFusionProcMix(c,sub,insf,f1,table.unpack(fun))
end
--Fusion monster, condition1 + condition2 * minc to maxc
function Auxiliary.AddFusionProcFunFunRep(c,f1,f2,minc,maxc,insf)
local f1=function(c) return f1(c) and not c:IsHasEffect(6205579) end
......
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