22-- Darkness/Spell A (Darkness)
33local s ,id = GetID ()
44function s .initial_effect (c )
5- -- activate
5+ -- Activate (Set Darkness/Trap A, B, C, D, and E from your hand or Deck)
66 local e1 = Effect .CreateEffect (c )
77 e1 :SetType (EFFECT_TYPE_ACTIVATE )
88 e1 :SetCode (EVENT_FREE_CHAIN )
9- e1 :SetTarget (s .target )
10- e1 :SetOperation (s .activate )
9+ e1 :SetTarget (s .settg )
10+ e1 :SetOperation (s .setop )
1111 c :RegisterEffect (e1 )
12- -- Indestructible OPT
12+ -- Once per turn, this card cannot be destroyed by card effects
1313 local e2 = Effect .CreateEffect (c )
1414 e2 :SetType (EFFECT_TYPE_SINGLE )
1515 e2 :SetCode (EFFECT_INDESTRUCTABLE_COUNT )
16- e2 :SetRange (LOCATION_SZONE )
16+ e2 :SetRange (LOCATION_FZONE )
1717 e2 :SetCountLimit (1 )
18- e2 :SetValue (s . valcon )
18+ e2 :SetValue (function ( e , re , r , rp ) return ( r & REASON_EFFECT ) > 0 end )
1919 c :RegisterEffect (e2 )
20- -- cannot be negate/disable
20+ -- Activation and effects of Continuous Traps you control cannot be negated
2121 local e3 = Effect .CreateEffect (c )
2222 e3 :SetType (EFFECT_TYPE_FIELD )
2323 e3 :SetCode (EFFECT_CANNOT_INACTIVATE )
24- e3 :SetRange (LOCATION_SZONE )
25- e3 :SetTargetRange (1 ,0 )
26- e3 :SetValue (s .efilter )
24+ e3 :SetRange (LOCATION_FZONE )
25+ e3 :SetValue (s .effectfilter )
2726 c :RegisterEffect (e3 )
2827 local e4 = Effect .CreateEffect (c )
2928 e4 :SetType (EFFECT_TYPE_FIELD )
3029 e4 :SetCode (EFFECT_CANNOT_DISEFFECT )
31- e4 :SetRange (LOCATION_SZONE )
32- e4 :SetTargetRange (1 ,0 )
33- e4 :SetValue (s .efilter )
30+ e4 :SetRange (LOCATION_FZONE )
31+ e4 :SetValue (s .effectfilter )
3432 c :RegisterEffect (e4 )
35- -- tohand
33+ -- (Hidden Effect) Return all other Spell/Trap cards on the field to the hand
3634 local e5 = Effect .CreateEffect (c )
3735 e5 :SetCategory (CATEGORY_TOHAND )
3836 e5 :SetType (EFFECT_TYPE_IGNITION )
@@ -42,47 +40,42 @@ function s.initial_effect(c)
4240 e5 :SetOperation (s .thop )
4341 c :RegisterEffect (e5 )
4442end
45- s .listed_names = {95000004 ,95000005 ,95000006 ,95000007 ,95000008 }
43+ s .listed_names = {95000004 ,95000005 ,95000006 ,95000007 ,95000008 } -- "Darkness/Trap A", "Darkness/Trap B", "Darkness/Trap C", "Darkness/Trap D", "Darkness/Trap E",
4644s .mark = 0
47- function s .filter (c )
45+ function s .setfilter (c )
4846 return c :IsCode (95000004 ,95000005 ,95000006 ,95000007 ,95000008 ) and c :IsSSetable (true )
4947end
50- function s .target (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
51- if chk == 0 then return Duel .GetMatchingGroup (s .filter ,tp ,LOCATION_DECK | LOCATION_HAND ,0 ,1 ,nil ):GetClassCount (Card .GetCode )== 5 end
48+ function s .settg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
49+ if chk == 0 then return Duel .GetMatchingGroup (s .setfilter ,tp ,LOCATION_HAND | LOCATION_DECK ,0 ,1 ,nil ):GetClassCount (Card .GetCode )== 5 end
5250end
5351function s .rescon (sg ,e ,tp ,mg )
54- return sg :IsExists (Card .IsCode ,1 ,nil ,95000004 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000005 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000006 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000007 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000008 )
52+ return sg :IsExists (Card .IsCode ,1 ,nil ,95000004 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000005 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000006 )
53+ and sg :IsExists (Card .IsCode ,1 ,nil ,95000007 ) and sg :IsExists (Card .IsCode ,1 ,nil ,95000008 )
5554end
56- function s .activate (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
55+ function s .setop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
5756 if not e :GetHandler ():IsRelateToEffect (e ) then return end
5857 if Duel .GetLocationCount (tp ,LOCATION_SZONE )< 5 then return end
59- local sg = Duel .GetMatchingGroup (s .filter ,tp ,LOCATION_DECK | LOCATION_HAND ,0 ,nil )
58+ local sg = Duel .GetMatchingGroup (s .setfilter ,tp ,LOCATION_HAND | LOCATION_DECK ,0 ,nil )
6059 if not s .rescon (sg ) then return end
6160 local setg = aux .SelectUnselectGroup (sg ,e ,tp ,5 ,5 ,s .rescon ,1 ,tp ,HINTMSG_SET )
6261 if # sg > 0 then
6362 Duel .SSet (tp ,setg )
6463 end
6564end
66- function s .valcon (e ,re ,r ,rp )
67- return (r &REASON_EFFECT )~= 0
68- end
69- function s .indtg (e ,c )
70- return c :IsFaceup () and c :GetType ()== TYPE_TRAP + TYPE_CONTINUOUS
71- end
72- function s .efilter (e ,ct )
73- local te = Duel .GetChainInfo (ct ,CHAININFO_TRIGGERING_EFFECT )
74- local tc = te :GetHandler ()
75- return tc :GetType ()== TYPE_TRAP + TYPE_CONTINUOUS
76- end
77- function s .thfilter (c )
78- return c :IsSpellTrap () and c :IsAbleToHand ()
65+ function s .effectfilter (e ,ct )
66+ local trig_e = Duel .GetChainInfo (ct ,CHAININFO_TRIGGERING_EFFECT )
67+ local trig_c = trig_e :GetHandler ()
68+ if not (trig_e :IsTrapEffect () and trig_c :IsContinuousTrap ()) then return false end
69+ return trig_c :IsControler (e :GetHandlerPlayer ()) and trig_c :IsLocation (LOCATION_ONFIELD ) and trig_c :IsFaceup ()
7970end
8071function s .thtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
81- if chk == 0 then return Duel .IsExistingMatchingCard (s . thfilter ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,1 ,e :GetHandler ()) end
82- local g = Duel .GetMatchingGroup (s . thfilter ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,e :GetHandler ())
72+ if chk == 0 then return Duel .IsExistingMatchingCard (aux . AND ( Card . IsSpellTrap , Card . IsAbleToHand ) ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,1 ,e :GetHandler ()) end
73+ local g = Duel .GetMatchingGroup (aux . AND ( Card . IsSpellTrap , Card . IsAbleToHand ) ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,e :GetHandler ())
8374 Duel .SetOperationInfo (0 ,CATEGORY_TOHAND ,g ,# g ,0 ,0 )
8475end
8576function s .thop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
86- local g = Duel .GetMatchingGroup (s .thfilter ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,e :GetHandler ())
87- Duel .SendtoHand (g ,nil ,REASON_EFFECT )
88- end
77+ local g = Duel .GetMatchingGroup (aux .AND (Card .IsSpellTrap ,Card .IsAbleToHand ),tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,e :GetHandler ())
78+ if # g > 0 then
79+ Duel .SendtoHand (g ,nil ,REASON_EFFECT )
80+ end
81+ end
0 commit comments