1+ -- 黒魔術の護符
2+ -- Dark Magic Amulet
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- You can activate this card the turn it was Set by revealing 1 Spellcaster monster in your hand
7+ local e0 = Effect .CreateEffect (c )
8+ e0 :SetType (EFFECT_TYPE_SINGLE )
9+ e0 :SetProperty (EFFECT_FLAG_SET_AVAILABLE )
10+ e0 :SetCode (EFFECT_TRAP_ACT_IN_SET_TURN )
11+ e0 :SetValue (function (e ) e :SetLabel (1 ) end )
12+ e0 :SetCondition (function (e ) return Duel .IsExistingMatchingCard (s .discostfilter ,e :GetHandlerPlayer (),LOCATION_HAND ,0 ,1 ,nil ) end )
13+ c :RegisterEffect (e0 )
14+ -- Negate a monster effect that is activated in response to the activation of a card that mentions "Dark Magician" or its effect
15+ local e1 = Effect .CreateEffect (c )
16+ e1 :SetDescription (aux .Stringid (id ,0 ))
17+ e1 :SetCategory (CATEGORY_DISABLE )
18+ e1 :SetType (EFFECT_TYPE_ACTIVATE )
19+ e1 :SetCode (EVENT_CHAINING )
20+ e1 :SetCondition (s .discon )
21+ e1 :SetCost (s .discost )
22+ e1 :SetTarget (s .distg )
23+ e1 :SetOperation (s .disop )
24+ e1 :SetLabelObject (e0 )
25+ c :RegisterEffect (e1 )
26+ -- Set this card
27+ local e2 = Effect .CreateEffect (c )
28+ e2 :SetDescription (aux .Stringid (id ,1 ))
29+ e2 :SetCategory (CATEGORY_LEAVE_GRAVE )
30+ e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
31+ e2 :SetProperty (EFFECT_FLAG_DELAY ,EFFECT_FLAG2_CHECK_SIMULTANEOUS )
32+ e2 :SetCode (EVENT_SPSUMMON_SUCCESS )
33+ e2 :SetRange (LOCATION_GRAVE )
34+ e2 :SetCondition (s .setcon )
35+ e2 :SetCost (Cost .PayLP (2500 ))
36+ e2 :SetTarget (s .settg )
37+ e2 :SetOperation (s .setop )
38+ c :RegisterEffect (e2 )
39+ end
40+ s .listed_names = {CARD_DARK_MAGICIAN }
41+ function s .discon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
42+ local chainlink = Duel .GetCurrentChain (true )- 1
43+ if not (chainlink > 0 and re :IsMonsterEffect () and Duel .IsChainDisablable (ev )) then return false end
44+ local trig_eff = Duel .GetChainInfo (chainlink ,CHAININFO_TRIGGERING_EFFECT )
45+ return trig_eff and trig_eff :GetHandler ():ListsCode (CARD_DARK_MAGICIAN )
46+ end
47+ function s .discostfilter (c )
48+ return c :IsRace (RACE_SPELLCASTER ) and not c :IsPublic ()
49+ end
50+ function s .discost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
51+ local label_obj = e :GetLabelObject ()
52+ if chk == 0 then label_obj :SetLabel (0 ) return true end
53+ if label_obj :GetLabel ()> 0 then
54+ label_obj :SetLabel (0 )
55+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_CONFIRM )
56+ local g = Duel .SelectMatchingCard (tp ,s .discostfilter ,tp ,LOCATION_HAND ,0 ,1 ,1 ,nil )
57+ Duel .ConfirmCards (1 - tp ,g )
58+ Duel .ShuffleHand (tp )
59+ end
60+ end
61+ function s .distg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
62+ if chk == 0 then return true end
63+ Duel .SetOperationInfo (0 ,CATEGORY_DISABLE ,eg ,1 ,tp ,0 )
64+ end
65+ function s .disop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
66+ if Duel .NegateEffect (ev ) then
67+ local code1 ,code2 = re :GetHandler ():GetOriginalCodeRule ()
68+ -- For the rest of this turn, the activated effects of monsters with the same original name are negated
69+ local e1 = Effect .CreateEffect (e :GetHandler ())
70+ e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
71+ e1 :SetCode (EVENT_CHAIN_SOLVING )
72+ e1 :SetCondition (function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ) return re :IsMonsterEffect () and re :GetHandler ():IsOriginalCodeRule (code1 ,code2 ) end )
73+ e1 :SetOperation (function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ) Duel .Hint (HINT_CARD ,0 ,id ) Duel .NegateEffect (ev ) end )
74+ e1 :SetReset (RESET_PHASE |PHASE_END )
75+ Duel .RegisterEffect (e1 ,tp )
76+ end
77+ end
78+ function s .setconfilter (c ,tp )
79+ return c :IsCode (CARD_DARK_MAGICIAN ) and c :IsSummonPlayer (tp ) and c :IsFaceup ()
80+ end
81+ function s .setcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
82+ return eg :IsExists (s .setconfilter ,1 ,nil ,tp )
83+ end
84+ function s .settg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
85+ local c = e :GetHandler ()
86+ if chk == 0 then return c :IsSSetable () end
87+ Duel .SetOperationInfo (0 ,CATEGORY_LEAVE_GRAVE ,c ,1 ,tp ,0 )
88+ end
89+ function s .setop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
90+ local c = e :GetHandler ()
91+ if c :IsRelateToEffect (e ) then
92+ Duel .SSet (tp ,c )
93+ end
94+ end
0 commit comments