Skip to content

Commit 125f7ab

Browse files
authored
Update and cleanup the Xyz procedure (#1130)
Do a major cleanup of the xyz procedure removing various redoundancies and trying to make the code less convoluted. All the various effects affecting the xyz procedure have been assigned a proper constant to make them more easily usable by other cards ``` EFFECT_XYZ_MAT_FROM_GRAVE = 511002793 EFFECT_SPELL_XYZ_MAT = 511000189 --Solid Overlay and similar cards EFFECT_EQUIP_SPELL_XYZ_MAT = 511001175 EFFECT_ORICHALCUM_CHAIN = 511002116 EFFECT_DOUBLE_XYZ_MATERIAL = 511001225 EFFECT_SATELLARKNIGHT_CAPELLA = 86466163 EFFECT_STAR_SERAPH_SOVEREIGNTY = 91110378 ``` The behaviour for the "automatic material selection" has been also changed to make it less bug prone, now if must_use is provided to Duel.XyzSummon and if minc and maxc both correspond to the size of the must_use group, then no user selection will be performed (Advanced Heraldry Art, Shining Hope Road, etc.). This changes the current behaviour, so that if only mg is provided to Duel.XyzSummon, the player will still be able to select the cards, making so cards that summon using a specific material pool (Galaxy Tyranno, Goblin Biker Grand Stampede, etc.) no longer have to pass maxc and minc to not break things. Cards got updated accordingly. Add the new constant `Xyz.InfiniteMats`, to be used in `Xyz.AddProcedure` instead of passing the magic value 99, to abstract away the logic from the user. Using `99` as magic value is now deprecated.
1 parent 156ad01 commit 125f7ab

File tree

139 files changed

+748
-1093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+748
-1093
lines changed

constant.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,13 @@ EFFECT_FUSION_MAT_RESTRICTION = 73941492+TYPE_FUSION
621621
EFFECT_SYNCHRO_MAT_RESTRICTION = 73941492+TYPE_SYNCHRO
622622
EFFECT_XYZ_MAT_RESTRICTION = 73941492+TYPE_XYZ
623623
EFFECT_SYNCHRO_MAT_FROM_HAND = 97682931
624+
EFFECT_XYZ_MAT_FROM_GRAVE = 511002793
625+
EFFECT_SPELL_XYZ_MAT = 511000189 --Solid Overlay and similar cards
626+
EFFECT_EQUIP_SPELL_XYZ_MAT = 511001175
627+
EFFECT_ORICHALCUM_CHAIN = 511002116
628+
EFFECT_DOUBLE_XYZ_MATERIAL = 511001225
629+
EFFECT_SATELLARKNIGHT_CAPELLA = 86466163
630+
EFFECT_STAR_SERAPH_SOVEREIGNTY = 91110378
624631
--Events
625632
EVENT_STARTUP = 1000
626633
EVENT_FLIP = 1001

official/c10666000.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableReviveLimit()
77
--Xyz Summon procedure
8-
Xyz.AddProcedure(c,nil,8,2,nil,nil,99)
8+
Xyz.AddProcedure(c,nil,8,2,nil,nil,Xyz.InfiniteMats)
99
--Attach 1 card from your opponent's GY to this card
1010
local e1=Effect.CreateEffect(c)
1111
e1:SetDescription(aux.Stringid(id,0))
@@ -98,4 +98,4 @@ function s.desop(e,tp,eg,ep,ev,re,r,rp)
9898
Duel.BreakEffect()
9999
Duel.Damage(1-tp,dam,REASON_EFFECT)
100100
end
101-
end
101+
end

official/c11132674.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableReviveLimit()
7-
Xyz.AddProcedure(c,nil,8,2,s.ovfilter,aux.Stringid(id,0),99,s.xyzop)
7+
Xyz.AddProcedure(c,nil,8,2,s.ovfilter,aux.Stringid(id,0),Xyz.InfiniteMats,s.xyzop)
88
--Search 1 "Springans" or "Therion" card
99
local e1=Effect.CreateEffect(c)
1010
e1:SetDescription(aux.Stringid(id,1))
@@ -75,4 +75,4 @@ function s.operation(e,tp,eg,ep,ev,re,r,rp)
7575
Duel.SendtoHand(tc,nil,REASON_EFFECT)
7676
end
7777
end
78-
end
78+
end

official/c1174075.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableReviveLimit()
7-
Xyz.AddProcedure(c,nil,1,2,nil,nil,99)
7+
Xyz.AddProcedure(c,nil,1,2,nil,nil,Xyz.InfiniteMats)
88
--ritual material
99
local e1=Effect.CreateEffect(c)
1010
e1:SetType(EFFECT_TYPE_FIELD)

official/c12615446.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
local s,id=GetID()
44
function s.initial_effect(c)
55
--xyz summon
6-
Xyz.AddProcedure(c,s.matfilter,3,2,nil,nil,99)
6+
Xyz.AddProcedure(c,s.matfilter,3,2,nil,nil,Xyz.InfiniteMats)
77
c:EnableReviveLimit()
88
--Position+Negate
99
local e1=Effect.CreateEffect(c)

official/c14970113.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
local s,id=GetID()
44
function s.initial_effect(c)
55
--xyz summon
6-
Xyz.AddProcedure(c,nil,4,3,s.ovfilter,aux.Stringid(id,0),99,s.xyzop)
6+
Xyz.AddProcedure(c,nil,4,3,s.ovfilter,aux.Stringid(id,0),Xyz.InfiniteMats,s.xyzop)
77
c:EnableReviveLimit()
88
--atk
99
local e1=Effect.CreateEffect(c)

official/c18326736.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
local s,id=GetID()
44
function s.initial_effect(c)
55
--xyz summon
6-
Xyz.AddProcedure(c,nil,4,2,nil,nil,99)
6+
Xyz.AddProcedure(c,nil,4,2,nil,nil,Xyz.InfiniteMats)
77
c:EnableReviveLimit()
88
--spsummon
99
local e1=Effect.CreateEffect(c)

official/c19369609.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableReviveLimit()
77
--Xyz Summon Procedure
8-
Xyz.AddProcedure(c,nil,1,2,nil,nil,99)
8+
Xyz.AddProcedure(c,nil,1,2,nil,nil,Xyz.InfiniteMats)
99
--Gains 500 ATK for each material attached to it
1010
local e1=Effect.CreateEffect(c)
1111
e1:SetType(EFFECT_TYPE_SINGLE)
@@ -84,4 +84,4 @@ function s.atkop(e,tp,eg,ep,ev,re,r,rp)
8484
e1:SetReset(RESET_PHASE|PHASE_END|RESET_EVENT|RESETS_STANDARD)
8585
tc:RegisterEffect(e1)
8686
end
87-
end
87+
end

official/c20285786.lua

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
--Halfway to Forever
33
local s,id=GetID()
44
function s.initial_effect(c)
5-
--Activate
5+
--Special Summon 2 monsters from your GY then Xyz Summon 1 Utopic monster using those monsters as materials
66
local e1=Effect.CreateEffect(c)
77
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
88
e1:SetType(EFFECT_TYPE_ACTIVATE)
@@ -20,39 +20,32 @@ end
2020
function s.xyzfilter(c,mg)
2121
return c:IsSetCard(SET_UTOPIC) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsXyzSummonable(nil,mg,2,2)
2222
end
23-
function s.mfilter1(c,mg,exg)
24-
return mg:IsExists(s.mfilter2,1,c,c,exg)
25-
end
26-
function s.mfilter2(c,mc,exg)
27-
return exg:IsExists(Card.IsXyzSummonable,1,nil,nil,Group.FromCards(c,mc))
23+
function s.rescon(exg)
24+
return function(sg)
25+
return #sg==2 and exg:IsExists(Card.IsXyzSummonable,1,nil,nil,sg,2,2)
26+
end
2827
end
2928
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
3029
if chkc then return false end
3130
local mg=Duel.GetMatchingGroup(s.filter,tp,LOCATION_GRAVE,0,nil,e,tp)
3231
local exg=Duel.GetMatchingGroup(s.xyzfilter,tp,LOCATION_EXTRA,0,nil,mg)
33-
if chk==0 then return Duel.IsPlayerCanSpecialSummonCount(tp,2)
32+
if chk==0 then return #exg>0
33+
and Duel.IsPlayerCanSpecialSummonCount(tp,2)
3434
and not Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT)
35-
and Duel.GetLocationCount(tp,LOCATION_MZONE)>1
36-
and #exg>0 end
37-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
38-
local sg1=mg:FilterSelect(tp,s.mfilter1,1,1,nil,mg,exg)
39-
local tc1=sg1:GetFirst()
40-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
41-
local sg2=mg:FilterSelect(tp,s.mfilter2,1,1,tc1,tc1,exg)
42-
sg1:Merge(sg2)
43-
Duel.SetTargetCard(sg1)
44-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,sg1,2,0,0)
35+
and Duel.GetLocationCount(tp,LOCATION_MZONE)>1 end
36+
local sg=aux.SelectUnselectGroup(mg,e,tp,2,2,s.rescon(exg),1,tp,HINTMSG_SPSUMMON)
37+
Duel.SetTargetCard(sg)
38+
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,sg,2,0,0)
4539
end
4640
function s.filter2(c,e,tp)
47-
return c:IsRelateToEffect(e) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
41+
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
4842
end
4943
function s.activate(e,tp,eg,ep,ev,re,r,rp)
5044
if Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) then return end
5145
if Duel.GetLocationCount(tp,LOCATION_MZONE)<2 then return end
52-
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(s.filter2,nil,e,tp)
53-
if #g<2 then return end
54-
local tc=g:GetFirst()
55-
for tc in aux.Next(g) do
46+
local g=Duel.GetTargetCards(e):Match(s.filter2,nil,e,tp)
47+
if #g~=2 then return end
48+
for tc in g:Iter() do
5649
Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP)
5750
local e1=Effect.CreateEffect(e:GetHandler())
5851
e1:SetType(EFFECT_TYPE_SINGLE)
@@ -69,6 +62,6 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp)
6962
if #xyzg>0 then
7063
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
7164
local xyz=xyzg:Select(tp,1,1,nil):GetFirst()
72-
Duel.XyzSummon(tp,xyz,nil,g)
65+
Duel.XyzSummon(tp,xyz,g,nil,2,2)
7366
end
7467
end

official/c21065189.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableReviveLimit()
7-
Xyz.AddProcedure(c,nil,4,2,nil,nil,99)
7+
Xyz.AddProcedure(c,nil,4,2,nil,nil,Xyz.InfiniteMats)
88
--atk gain
99
local e1=Effect.CreateEffect(c)
1010
e1:SetType(EFFECT_TYPE_SINGLE)
@@ -38,7 +38,7 @@ function s.atkval(e,c)
3838
end
3939
function s.spfilter(c,e,tp,ec)
4040
local zone=ec:GetToBeLinkedZone(c,tp)
41-
return zone~=0 and c:IsLinkMonster() and c:IsRace(RACE_CYBERSE) and c:GetLink()==4
41+
return zone~=0 and c:IsLinkMonster() and c:IsRace(RACE_CYBERSE) and c:GetLink()==4
4242
and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,tp,zone)
4343
end
4444
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
@@ -54,7 +54,7 @@ function s.spop(e,tp,eg,ep,ev,re,r,rp)
5454
local tc=Duel.GetFirstTarget()
5555
if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
5656
local zone=c:GetToBeLinkedZone(tc,tp)
57-
if zone~=0 then
57+
if zone~=0 then
5858
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP,zone)
5959
end
6060
end

0 commit comments

Comments
 (0)