Skip to content

Commit ad2415b

Browse files
committed
Xyz proc: Reorder functions
1 parent ce40118 commit ad2415b

File tree

1 file changed

+46
-50
lines changed

1 file changed

+46
-50
lines changed

proc_xyz.lua

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,64 @@ function Xyz.CheckValidMultiXyzMaterial(effs,xyz)
117117
end
118118
return false
119119
end
120+
function Xyz.MatNumChk(matct,ct,comp)
121+
if (comp&0x1)==0x1 and matct>ct then return true end
122+
if (comp&0x2)==0x2 and matct==ct then return true end
123+
if (comp&0x4)==0x4 and matct<ct then return true end
124+
return false
125+
end
126+
function Xyz.MatNumChkF(tg)
127+
for chkc in tg:Iter() do
128+
for _,te in ipairs({chkc:GetCardEffect(EFFECT_STAR_SERAPH_SOVEREIGNTY)}) do
129+
local rct=te:GetValue()&0xffff
130+
local comp=(te:GetValue()>>16)&0xffff
131+
if not Xyz.MatNumChk(tg:FilterCount(Card.IsMonster,nil),rct,comp) then return false end
132+
end
133+
end
134+
return true
135+
end
136+
function Xyz.MatNumChkF2(tg,lv,xyz)
137+
for chkc in tg:Iter() do
138+
local rev={}
139+
for _,te in ipairs({chkc:GetCardEffect(EFFECT_SATELLARKNIGHT_CAPELLA)}) do
140+
local rct=te:GetValue()&0xffff
141+
local comp=(te:GetValue()>>16)&0xffff
142+
if not Xyz.MatNumChk(tg:FilterCount(Card.IsMonster,nil),rct,comp) then
143+
local con=te:GetLabelObject():GetCondition()
144+
if not con then con=aux.TRUE end
145+
if not rev[te] then
146+
table.insert(rev,te)
147+
rev[te]=con
148+
te:GetLabelObject():SetCondition(aux.FALSE)
149+
end
150+
end
151+
end
152+
if #rev>0 then
153+
local islv=chkc:IsXyzLevel(xyz,lv)
154+
for _,te in ipairs(rev) do
155+
local con=rev[te]
156+
te:GetLabelObject():SetCondition(con)
157+
end
158+
if not islv then return false end
159+
end
160+
end
161+
return true
162+
end
120163
function Xyz.CheckMaterialSet(matg,xyz,tp,exchk,mustg,lv)
121164
if not matg:Includes(mustg) then return false end
122-
if matg:IsExists(Card.IsHasEffect,1,nil,EFFECT_STAR_SERAPH_SOVEREIGNTY) and not Xyz.MatNumChkF(matg) then
165+
if not Xyz.MatNumChkF(matg) then
123166
return false
124167
end
125-
if lv and matg:IsExists(Card.IsHasEffect,1,nil,EFFECT_SATELLARKNIGHT_CAPELLA) and not Xyz.MatNumChkF2(matg,lv,xyz) then
168+
if lv and not Xyz.MatNumChkF2(matg,lv,xyz) then
126169
return false
127170
end
128171
if exchk and #matg>0 and not exchk(matg,tp,xyz) then
129172
return false
130173
end
131174
if xyz:IsLocation(LOCATION_EXTRA) then
132175
return Duel.GetLocationCountFromEx(tp,tp,matg,xyz)>0
133-
else
134-
return Duel.GetMZoneCount(tp,matg,tp)>0
135176
end
177+
return Duel.GetMZoneCount(tp,matg,tp)>0
136178
end
137179
function Xyz.RecursionChk(c,mg,xyz,tp,min,max,minc,maxc,sg,matg,ct,matct,mustbemat,exchk,f,mustg,lv,eqmg,equips_inverse)
138180
local addToMatg=true
@@ -206,52 +248,6 @@ function Xyz.RecursionChk(c,mg,xyz,tp,min,max,minc,maxc,sg,matg,ct,matct,mustbem
206248
mg:Merge(rg)
207249
return res
208250
end
209-
function Xyz.MatNumChkF(tg)
210-
local chkg=tg:Filter(Card.IsHasEffect,nil,EFFECT_STAR_SERAPH_SOVEREIGNTY)
211-
for chkc in aux.Next(chkg) do
212-
for _,te in ipairs({chkc:GetCardEffect(EFFECT_STAR_SERAPH_SOVEREIGNTY)}) do
213-
local rct=te:GetValue()&0xffff
214-
local comp=te:GetValue()>>16
215-
if not Xyz.MatNumChk(tg:FilterCount(Card.IsMonster,nil),rct,comp) then return false end
216-
end
217-
end
218-
return true
219-
end
220-
function Xyz.MatNumChk(matct,ct,comp)
221-
local ok=false
222-
if not ok and comp&0x1==0x1 and matct>ct then ok=true end
223-
if not ok and comp&0x2==0x2 and matct==ct then ok=true end
224-
if not ok and comp&0x4==0x4 and matct<ct then ok=true end
225-
return ok
226-
end
227-
function Xyz.MatNumChkF2(tg,lv,xyz)
228-
local chkg=tg:Filter(Card.IsHasEffect,nil,EFFECT_SATELLARKNIGHT_CAPELLA)
229-
for chkc in aux.Next(chkg) do
230-
local rev={}
231-
for _,te in ipairs({chkc:GetCardEffect(EFFECT_SATELLARKNIGHT_CAPELLA)}) do
232-
local rct=te:GetValue()&0xffff
233-
local comp=te:GetValue()>>16
234-
if not Xyz.MatNumChk(tg:FilterCount(Card.IsMonster,nil),rct,comp) then
235-
local con=te:GetLabelObject():GetCondition()
236-
if not con then con=aux.TRUE end
237-
if not rev[te] then
238-
table.insert(rev,te)
239-
rev[te]=con
240-
te:GetLabelObject():SetCondition(aux.FALSE)
241-
end
242-
end
243-
end
244-
if #rev>0 then
245-
local islv=chkc:IsXyzLevel(xyz,lv)
246-
for _,te in ipairs(rev) do
247-
local con=rev[te]
248-
te:GetLabelObject():SetCondition(con)
249-
end
250-
if not islv then return false end
251-
end
252-
end
253-
return true
254-
end
255251
function Auxiliary.HarmonizingMagFilterXyz(c,e,f)
256252
return not f or f(e,c) or c:IsHasEffect(EFFECT_ORICHALCUM_CHAIN) or c:IsHasEffect(EFFECT_EQUIP_SPELL_XYZ_MAT)
257253
end

0 commit comments

Comments
 (0)