@@ -18,134 +18,89 @@ function s.filter(c,e)
1818 return c :IsSetCard (SET_NUMBER_C ) and c :IsType (TYPE_XYZ ) and (c :IsLocation (LOCATION_GRAVE ) or c :IsFaceup ())
1919 and (c :GetRank ()> 0 or c :IsStatus (STATUS_NO_LEVEL )) and c :IsCanBeEffectTarget (e )
2020end
21- function s .xyzfilter (c ,sg ,e ,tp )
22- if not c :IsSetCard (SET_NUMBER_C ) or Duel .GetLocationCountFromEx (tp ,tp ,sg ,c )<= 0 then return false end
23- if c .rum_limit and not sg :IsExists (function (mc ) return c .rum_limit (mc ,e ) end ,1 ,nil ) then return false end
21+ function s .xyzcheck (c ,sg ,og ,minc ,maxc ,e )
22+ if c .rum_limit and not sg :IsExists (c .rum_limit ,1 ,nil ,e ) then return false end
2423 local se = nil
2524 if c .rum_xyzsummon then
2625 se = c .rum_xyzsummon (c )
2726 end
28- local res = c :IsXyzSummonable (nil , sg ,# sg , # sg )
27+ local res = c :IsXyzSummonable (sg ,og , minc , maxc )
2928 if se then
3029 se :Reset ()
3130 end
3231 return res
3332end
34- function s .chkfilter (c ,g ,sg ,e ,tp )
35- sg :AddCard (c )
36- local e1 = Effect .CreateEffect (e :GetHandler ())
37- e1 :SetType (EFFECT_TYPE_SINGLE )
38- e1 :SetCode (EFFECT_XYZ_LEVEL )
39- e1 :SetValue (c :GetRank ()+ 1 )
40- e1 :SetReset (RESET_CHAIN )
41- c :RegisterEffect (e1 )
42- local e2 = nil
43- if c :IsControler (1 - tp ) then
44- e2 = Effect .CreateEffect (e :GetHandler ())
45- e2 :SetType (EFFECT_TYPE_SINGLE )
46- e2 :SetCode (EFFECT_XYZ_MATERIAL )
47- e2 :SetReset (RESET_CHAIN )
48- c :RegisterEffect (e2 )
33+ function s .rescon (xyzg )
34+ return function (sg ,e ,tp ,g )
35+ if xyzg :IsExists (s .xyzcheck ,1 ,nil ,nil ,sg ,# sg ,# sg ,e ) then return true end
36+ -- If no xyz can be summoned using at least the currently seelcted cards as forced materials, stop
37+ return false ,not xyzg :IsExists (s .xyzcheck ,1 ,nil ,sg ,g ,# sg ,# g ,e )
4938 end
50- local res = Duel .IsExistingMatchingCard (s .xyzfilter ,tp ,LOCATION_EXTRA ,0 ,1 ,nil ,sg ,e ,tp )
51- or g :IsExists (s .chkfilter ,1 ,sg ,g ,sg ,e ,tp )
52- e1 :Reset ()
53- if e2 then e2 :Reset () end
54- sg :RemoveCard (c )
55- return res
39+ end
40+ function s .xyzfilter (c ,mg ,minc ,maxc )
41+ return c :IsSetCard (SET_NUMBER_C ) and c :IsXyzSummonable (nil ,mg ,minc ,maxc )
42+ end
43+ function s .register_effects (c ,mg ,tp )
44+ local xyz_mat_eff
45+ if mg :IsExists (Card .IsControler ,1 ,nil ,1 - tp ) then
46+ xyz_mat_eff = Effect .CreateEffect (c )
47+ xyz_mat_eff :SetType (EFFECT_TYPE_FIELD )
48+ xyz_mat_eff :SetCode (EFFECT_XYZ_MATERIAL )
49+ xyz_mat_eff :SetTargetRange (LOCATION_GRAVE |LOCATION_ONFIELD ,LOCATION_GRAVE |LOCATION_ONFIELD )
50+ xyz_mat_eff :SetTarget (function (e ,c ) return mg :IsContains (c ) end )
51+ xyz_mat_eff :SetReset (RESETS_STANDARD )
52+ xyz_mat_eff :SetProperty (EFFECT_FLAG_UNCOPYABLE |EFFECT_FLAG_CANNOT_DISABLE |EFFECT_FLAG_IGNORE_IMMUNE |EFFECT_FLAG_SET_AVAILABLE )
53+ Duel .RegisterEffect (xyz_mat_eff ,tp )
54+ end
55+ local xyz_level_eff = Effect .CreateEffect (c )
56+ xyz_level_eff :SetType (EFFECT_TYPE_FIELD )
57+ xyz_level_eff :SetCode (EFFECT_XYZ_LEVEL )
58+ xyz_level_eff :SetTargetRange (LOCATION_GRAVE |LOCATION_ONFIELD ,LOCATION_GRAVE |LOCATION_ONFIELD )
59+ xyz_level_eff :SetTarget (function (e ,c ) return mg :IsContains (c ) end )
60+ xyz_level_eff :SetReset (RESETS_STANDARD )
61+ xyz_level_eff :SetProperty (EFFECT_FLAG_UNCOPYABLE |EFFECT_FLAG_CANNOT_DISABLE |EFFECT_FLAG_IGNORE_IMMUNE |EFFECT_FLAG_SET_AVAILABLE )
62+ xyz_level_eff :SetValue (function (e ,c ) if a then Debug .Message (" b" ) end return c :GetRank ()+ 1 end )
63+ Duel .RegisterEffect (xyz_level_eff ,tp )
64+ return xyz_mat_eff ,xyz_level_eff
5665end
5766function s .target (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ,chkc )
5867 if chkc then return false end
59- local sg = Group .CreateGroup ()
6068 local mg = Duel .GetMatchingGroup (s .filter ,tp ,LOCATION_GRAVE |LOCATION_ONFIELD ,LOCATION_GRAVE |LOCATION_ONFIELD ,nil ,e )
61- if chk == 0 then return mg :IsExists (s .chkfilter ,1 ,nil ,mg ,sg ,e ,tp ) end
62- local reset = {}
63- local tc
64- local e1
65- local e2
66- :: start::
67- local cancel =# sg > 0 and Duel .IsExistingMatchingCard (s .xyzfilter ,tp ,LOCATION_EXTRA ,0 ,1 ,nil ,sg ,e ,tp )
68- local tg = mg :Filter (s .chkfilter ,sg ,mg ,sg ,e ,tp )
69- if # tg <= 0 then goto jump end
70- Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_XMATERIAL )
71- tc = Group .SelectUnselect (tg ,sg ,tp ,cancel ,cancel )
72- if not tc then goto jump end
73- if sg :IsContains (tc ) then
74- sg :RemoveCard (tc )
75- reset [tc ][0 ]:Reset ()
76- if reset [tc ][1 ] then
77- reset [tc ][1 ]:Reset ()
78- end
79- reset [tc ]= nil
80- else
81- sg :AddCard (tc )
82- reset [tc ]= {}
83- e1 = Effect .CreateEffect (e :GetHandler ())
84- e1 :SetType (EFFECT_TYPE_SINGLE )
85- e1 :SetCode (EFFECT_XYZ_LEVEL )
86- e1 :SetValue (tc :GetRank ()+ 1 )
87- e1 :SetReset (RESET_CHAIN )
88- tc :RegisterEffect (e1 )
89- reset [tc ][0 ]= e1
90- e2 = nil
91- if tc :IsControler (1 - tp ) then
92- e2 = Effect .CreateEffect (e :GetHandler ())
93- e2 :SetType (EFFECT_TYPE_SINGLE )
94- e2 :SetCode (EFFECT_XYZ_MATERIAL )
95- e2 :SetReset (RESET_CHAIN )
96- tc :RegisterEffect (e2 )
97- end
98- reset [tc ][1 ]= e2
99- end
100- goto start
101- :: jump::
102- Duel .SetTargetCard (sg )
103- for _ ,t in ipairs (reset ) do
104- t [0 ]:Reset ()
105- if t [1 ] then t [1 ]:Reset () end
69+ local xyz_mat_eff ,xyz_level_eff = s .register_effects (e :GetHandler (),mg ,tp )
70+ local xyzg = Duel .GetMatchingGroup (s .xyzfilter ,tp ,LOCATION_EXTRA ,0 ,nil ,mg )
71+ if chk == 0 then
72+ xyz_level_eff :Reset ()
73+ if xyz_mat_eff then xyz_mat_eff :Reset () end
74+ return # xyzg > 0
10675 end
76+ local sg = aux .SelectUnselectGroup (mg ,e ,tp ,1 ,# mg ,s .rescon (xyzg ),1 ,tp ,HINTMSG_TARGET ,s .rescon (xyzg ))
77+ Duel .SetTargetCard (sg )
78+ xyz_level_eff :Reset ()
79+ if xyz_mat_eff then xyz_mat_eff :Reset () end
10780 Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_EXTRA )
10881end
10982function s .activate (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
110- local g = Duel .GetTargetCards (e )
83+ local mg = Duel .GetTargetCards (e )
11184 local c = e :GetHandler ()
112- local reset = {}
113- for tc in aux .Next (g ) do
114- local e1 = Effect .CreateEffect (c )
115- e1 :SetType (EFFECT_TYPE_SINGLE )
116- e1 :SetCode (EFFECT_XYZ_LEVEL )
117- e1 :SetValue (tc :GetRank ()+ 1 )
118- e1 :SetReset (RESET_EVENT + RESETS_STANDARD )
119- tc :RegisterEffect (e1 )
120- table.insert (reset ,e1 )
121- if tc :IsControler (1 - tp ) then
122- local e2 = Effect .CreateEffect (c )
123- e2 :SetType (EFFECT_TYPE_SINGLE )
124- e2 :SetCode (EFFECT_XYZ_MATERIAL )
125- e2 :SetReset (RESET_EVENT + RESETS_STANDARD )
126- tc :RegisterEffect (e2 )
127- table.insert (reset ,e2 )
128- end
129- end
130- local xyzg = Duel .GetMatchingGroup (s .xyzfilter ,tp ,LOCATION_EXTRA ,0 ,nil ,g ,e ,tp )
131- if # xyzg > 0 then
132- Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
133- local xyz = xyzg :Select (tp ,1 ,1 ,nil ):GetFirst ()
85+ local xyz_mat_eff ,xyz_level_eff = s .register_effects (c ,mg ,tp )
86+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
87+ local xyz = Duel .SelectMatchingCard (tp ,s .xyzfilter ,tp ,LOCATION_EXTRA ,0 ,1 ,1 ,nil ,mg ,# mg ,# mg ):GetFirst ()
88+ if xyz then
89+ mg :KeepAlive ()
13490 aux .RankUpComplete (xyz ,aux .Stringid (id ,1 ))
135- Duel .XyzSummon (tp ,xyz ,g , nil , # g , # g )
91+ Duel .XyzSummon (tp ,xyz ,mg , mg , # mg , # mg )
13692 local e1 = Effect .CreateEffect (c )
13793 e1 :SetType (EFFECT_TYPE_SINGLE )
13894 e1 :SetCode (EFFECT_SPSUMMON_COST )
13995 e1 :SetOperation (function ()
140- for _ , eff in ipairs ( reset ) do
141- eff :Reset ()
142- end
96+ xyz_level_eff : Reset ()
97+ if xyz_mat_eff then xyz_mat_eff :Reset () end
98+ mg : DeleteGroup ()
14399 end )
144100 e1 :SetReset (RESET_EVENT + RESETS_STANDARD )
145101 xyz :RegisterEffect (e1 ,true )
146102 else
147- for _ ,eff in ipairs (reset ) do
148- eff :Reset ()
149- end
103+ xyz_level_eff :Reset ()
104+ if xyz_mat_eff then xyz_mat_eff :Reset () end
150105 end
151- end
106+ end
0 commit comments