1+ -- 幻魔の扉
2+ -- Illusion Gate
3+ local s ,id = GetID ()
4+ function s .initial_effect (c )
5+ -- Destroy as many monsters your opponent controls as possible, then you can Special Summon 1 monster from your opponent's GY to your field, ignoring its Summoning conditions
6+ local e1 = Effect .CreateEffect (c )
7+ e1 :SetDescription (aux .Stringid (id ,0 ))
8+ e1 :SetCategory (CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON )
9+ e1 :SetType (EFFECT_TYPE_ACTIVATE )
10+ e1 :SetCode (EVENT_FREE_CHAIN )
11+ e1 :SetCost (Cost .PayLP (1 / 2 ))
12+ e1 :SetTarget (s .target )
13+ e1 :SetOperation (s .activate )
14+ c :RegisterEffect (e1 )
15+ end
16+ function s .target (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
17+ local g = Duel .GetMatchingGroup (nil ,tp ,0 ,LOCATION_MZONE ,nil )
18+ if chk == 0 then return not Duel .HasFlagEffect (tp ,id ) and # g > 0 end
19+ Duel .SetOperationInfo (0 ,CATEGORY_DESTROY ,g ,# g ,tp ,0 )
20+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,1 - tp ,LOCATION_GRAVE )
21+ end
22+ function s .spfilter (c ,e ,tp )
23+ return c :IsMonster () and c :IsCanBeSpecialSummoned (e ,0 ,tp ,true ,false )
24+ end
25+ function s .activate (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
26+ if Duel .HasFlagEffect (tp ,id ) then return end
27+ Duel .RegisterFlagEffect (tp ,id ,0 ,0 ,1 )
28+ local g = Duel .GetMatchingGroup (nil ,tp ,0 ,LOCATION_MZONE ,nil )
29+ if # g > 0 and Duel .Destroy (g ,REASON_EFFECT )> 0 and Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
30+ and Duel .IsExistingMatchingCard (aux .NecroValleyFilter (s .spfilter ),tp ,0 ,LOCATION_GRAVE ,1 ,nil ,e ,tp )
31+ and Duel .SelectYesNo (tp ,aux .Stringid (id ,1 )) then
32+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
33+ local sg = Duel .SelectTarget (tp ,aux .NecroValleyFilter (s .spfilter ),tp ,0 ,LOCATION_GRAVE ,1 ,1 ,nil ,e ,tp )
34+ if # sg > 0 then
35+ Duel .BreakEffect ()
36+ Duel .SpecialSummon (sg ,0 ,tp ,tp ,true ,false ,POS_FACEUP )
37+ end
38+ end
39+ end
0 commit comments