1+ -- ぜんなのついなぎひめ
2+ -- Zenna-no-Tsuinagihime
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ c :EnableReviveLimit ()
7+ -- Link Summon procedure: 2+ Effect Monsters
8+ Link .AddProcedure (c ,aux .FilterBoolFunctionEx (Card .IsType ,TYPE_EFFECT ),2 )
9+ -- You can also use 1 monster in your hand as material to Link Summon this card
10+ local e0 = Effect .CreateEffect (c )
11+ e0 :SetType (EFFECT_TYPE_FIELD )
12+ e0 :SetProperty (EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE )
13+ e0 :SetCode (EFFECT_EXTRA_MATERIAL )
14+ e0 :SetRange (LOCATION_EXTRA )
15+ e0 :SetTargetRange (1 ,0 )
16+ e0 :SetOperation (function (c ,e ,tp ,sg ,mg ,lc ,og ,chk ) return sg :FilterCount (Card .HasFlagEffect ,nil ,id )<= 1 end )
17+ e0 :SetValue (s .extraval )
18+ c :RegisterEffect (e0 )
19+ -- If this card is Link Summoned: You can send 1 monster from your Deck to the GY, or if this card was Link Summoned using only monsters you control, you can send 1 monster from your Extra Deck to the GY instead
20+ local e1a = Effect .CreateEffect (c )
21+ e1a :SetDescription (aux .Stringid (id ,0 ))
22+ e1a :SetCategory (CATEGORY_TOGRAVE )
23+ e1a :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
24+ e1a :SetProperty (EFFECT_FLAG_DELAY )
25+ e1a :SetCode (EVENT_SPSUMMON_SUCCESS )
26+ e1a :SetCountLimit (1 ,{id ,0 })
27+ e1a :SetCondition (function (e ) return e :GetHandler ():IsLinkSummoned () end )
28+ e1a :SetTarget (s .tgtg )
29+ e1a :SetOperation (s .tgop )
30+ c :RegisterEffect (e1a )
31+ local e1b = Effect .CreateEffect (c )
32+ e1b :SetType (EFFECT_TYPE_SINGLE )
33+ e1b :SetCode (EFFECT_MATERIAL_CHECK )
34+ e1b :SetValue (s .matcheck )
35+ e1b :SetLabelObject (e1a )
36+ c :RegisterEffect (e1b )
37+ -- During your next Standby Phase after this card was sent from the field to the GY: You can add 1 monster from your GY to your hand
38+ local e2a = Effect .CreateEffect (c )
39+ e2a :SetDescription (aux .Stringid (id ,1 ))
40+ e2a :SetCategory (CATEGORY_TOHAND )
41+ e2a :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
42+ e2a :SetCode (EVENT_PHASE + PHASE_STANDBY )
43+ e2a :SetRange (LOCATION_GRAVE )
44+ e2a :SetCountLimit (1 ,{id ,1 })
45+ e2a :SetCondition (function (e ,tp ) local c = e :GetHandler () return Duel .IsTurnPlayer (tp ) and c :HasFlagEffect (id ) and (c :GetFlagEffectLabel (id )== 1 or c :GetTurnID ()~= Duel .GetTurnCount ()) end )
46+ e2a :SetTarget (s .thtg )
47+ e2a :SetOperation (s .thop )
48+ c :RegisterEffect (e2a )
49+ local e2b = Effect .CreateEffect (c )
50+ e2b :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS )
51+ e2b :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
52+ e2b :SetCode (EVENT_TO_GRAVE )
53+ e2b :SetCondition (function (e ) return e :GetHandler ():IsPreviousLocation (LOCATION_ONFIELD ) end )
54+ e2b :SetOperation (function (e ,tp ) local ct = (Duel .IsTurnPlayer (tp ) and Duel .IsPhase (PHASE_STANDBY )) and 2 or 1 e :GetHandler ():RegisterFlagEffect (id ,RESET_EVENT |RESETS_STANDARD |RESET_PHASE |PHASE_STANDBY |RESET_SELF_TURN ,0 ,ct ,ct ) end )
55+ c :RegisterEffect (e2b )
56+ end
57+ function s .extraval (chk ,summon_type ,e ,...)
58+ if chk == 0 then
59+ local tp ,sc = ...
60+ if summon_type ~= SUMMON_TYPE_LINK or sc ~= e :GetHandler () then
61+ return Group .CreateGroup ()
62+ else
63+ local g = Duel .GetMatchingGroup (aux .NOT (Card .HasFlagEffect ),tp ,LOCATION_HAND ,0 ,nil ,id )
64+ for mc in g :Iter () do
65+ mc :RegisterFlagEffect (id ,0 ,0 ,1 )
66+ end
67+ return g
68+ end
69+ elseif chk == 2 then
70+ local g = Duel .GetMatchingGroup (Card .HasFlagEffect ,e :GetHandlerPlayer (),LOCATION_HAND ,0 ,nil ,id )
71+ for mc in g :Iter () do
72+ mc :ResetFlagEffect (id )
73+ end
74+ end
75+ end
76+ function s .tgtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
77+ local locations = e :GetLabel ()== 0 and LOCATION_DECK or LOCATION_DECK |LOCATION_EXTRA
78+ if chk == 0 then return Duel .IsExistingMatchingCard (aux .AND (Card .IsMonster ,Card .IsAbleToGrave ),tp ,locations ,0 ,1 ,nil ) end
79+ Duel .SetOperationInfo (0 ,CATEGORY_TOGRAVE ,nil ,1 ,tp ,locations )
80+ end
81+ function s .tgop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
82+ local locations = e :GetLabel ()== 0 and LOCATION_DECK or LOCATION_DECK |LOCATION_EXTRA
83+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TOGRAVE )
84+ local g = Duel .SelectMatchingCard (tp ,aux .AND (Card .IsMonster ,Card .IsAbleToGrave ),tp ,locations ,0 ,1 ,1 ,nil )
85+ if # g > 0 then
86+ Duel .SendtoGrave (g ,REASON_EFFECT )
87+ end
88+ end
89+ function s .matcheckfilter (c ,tp )
90+ return c :IsLocation (LOCATION_MZONE ) and c :IsControler (tp )
91+ end
92+ function s .matcheck (e ,c )
93+ local mg = c :GetMaterial ()
94+ e :GetLabelObject ():SetLabel (mg :FilterCount (s .matcheckfilter ,nil ,e :GetHandlerPlayer ())==# mg and 1 or 0 )
95+ end
96+ function s .thtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
97+ if chk == 0 then return Duel .IsExistingMatchingCard (aux .AND (Card .IsMonster ,Card .IsAbleToHand ),tp ,LOCATION_GRAVE ,0 ,1 ,nil ) end
98+ Duel .SetOperationInfo (0 ,CATEGORY_TOHAND ,nil ,1 ,tp ,LOCATION_GRAVE )
99+ end
100+ function s .thop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
101+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_ATOHAND )
102+ local g = Duel .SelectMatchingCard (tp ,aux .AND (Card .IsMonster ,Card .IsAbleToHand ),tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil )
103+ if # g > 0 then
104+ Duel .HintSelection (g )
105+ Duel .SendtoHand (g ,nil ,REASON_EFFECT )
106+ end
107+ end
0 commit comments