1+ -- 滅びの黒魔術師
2+ -- Dark Magician of Destruction
3+ -- scripted by Naim
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ c :EnableReviveLimit ()
7+ -- Fusion Materials: "Dark Magician" + 1 LIGHT or DARK monster
8+ Fusion .AddProcMix (c ,true ,true ,CARD_DARK_MAGICIAN ,aux .FilterBoolFunctionEx (Card .IsAttribute ,ATTRIBUTE_LIGHT |ATTRIBUTE_DARK ))
9+ c :AddMustBeFusionSummoned ()
10+ -- You can only Fusion Summon or Special Summon by its alternate procedure "Dark Magician of Destruction" once per turn
11+ local e0 = Effect .CreateEffect (c )
12+ e0 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS )
13+ e0 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
14+ e0 :SetCode (EVENT_SPSUMMON_SUCCESS )
15+ e0 :SetCondition (s .regcon )
16+ e0 :SetOperation (s .regop )
17+ c :RegisterEffect (e0 )
18+ -- You can Special Summon this card by banishing 1 Level 6 or higher DARK Spellcaster monster you control during the turn a Spell Card or effect was activated
19+ local e1 = Effect .CreateEffect (c )
20+ e1 :SetDescription (aux .Stringid (id ,0 ))
21+ e1 :SetType (EFFECT_TYPE_FIELD )
22+ e1 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE )
23+ e1 :SetCode (EFFECT_SPSUMMON_PROC )
24+ e1 :SetRange (LOCATION_EXTRA )
25+ e1 :SetCondition (s .selfspcon )
26+ e1 :SetTarget (s .selfsptg )
27+ e1 :SetOperation (s .selfspop )
28+ e1 :SetValue (1 )
29+ c :RegisterEffect (e1 )
30+ -- Add 1 "Dark Magician" or 1 card that mentions it from your Deck to your hand
31+ local e2 = Effect .CreateEffect (c )
32+ e2 :SetDescription (aux .Stringid (id ,1 ))
33+ e2 :SetCategory (CATEGORY_TOHAND + CATEGORY_SEARCH )
34+ e2 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
35+ e2 :SetProperty (EFFECT_FLAG_DELAY )
36+ e2 :SetCode (EVENT_SPSUMMON_SUCCESS )
37+ e2 :SetTarget (s .thtg )
38+ e2 :SetOperation (s .thop )
39+ c :RegisterEffect (e2 )
40+ -- This card's name becomes "Dark Magician" while on the field or in the GY
41+ local e3 = Effect .CreateEffect (c )
42+ e3 :SetType (EFFECT_TYPE_SINGLE )
43+ e3 :SetProperty (EFFECT_FLAG_SINGLE_RANGE )
44+ e3 :SetCode (EFFECT_CHANGE_CODE )
45+ e3 :SetRange (LOCATION_MZONE |LOCATION_GRAVE )
46+ e3 :SetValue (CARD_DARK_MAGICIAN )
47+ c :RegisterEffect (e3 )
48+ -- Keep track of a turn a Spell Card or effect was activated
49+ Duel .AddCustomActivityCounter (id ,ACTIVITY_CHAIN ,function (re ,tp ,cid ) return not re :IsSpellEffect () end )
50+ end
51+ s .listed_names = {CARD_DARK_MAGICIAN }
52+ s .material_setcode = SET_DARK_MAGICIAN
53+ function s .regcon (e )
54+ local c = e :GetHandler ()
55+ return c :IsFusionSummoned () or c :IsSummonType (SUMMON_TYPE_SPECIAL + 1 )
56+ end
57+ function s .regop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
58+ -- Prevent another Fusion Summon or Special Summon by its alternate procedure of "Dark Magician of Destruction" that turn
59+ local e1 = Effect .CreateEffect (e :GetHandler ())
60+ e1 :SetType (EFFECT_TYPE_FIELD )
61+ e1 :SetProperty (EFFECT_FLAG_PLAYER_TARGET )
62+ e1 :SetCode (EFFECT_CANNOT_SPECIAL_SUMMON )
63+ e1 :SetTargetRange (1 ,0 )
64+ e1 :SetTarget (function (e ,c ,sump ,sumtype ) return c :IsOriginalCode (id ) and (sumtype &SUMMON_TYPE_FUSION == SUMMON_TYPE_FUSION or sumtype &SUMMON_TYPE_SPECIAL + 1 == SUMMON_TYPE_SPECIAL + 1 ) end )
65+ e1 :SetReset (RESET_PHASE |PHASE_END )
66+ Duel .RegisterEffect (e1 ,tp )
67+ end
68+ function s .selfspcostfilter (c ,tp ,sc )
69+ return c :IsLevelAbove (6 ) and c :IsAttribute (ATTRIBUTE_DARK ) and c :IsRace (RACE_SPELLCASTER ) and Duel .GetLocationCountFromEx (tp ,tp ,c ,sc )> 0
70+ end
71+ function s .selfspcon (e ,c )
72+ if not c then return true end
73+ local tp = c :GetControler ()
74+ return (Duel .GetCustomActivityCount (id ,tp ,ACTIVITY_CHAIN )> 0 or Duel .GetCustomActivityCount (id ,1 - tp ,ACTIVITY_CHAIN )> 0 )
75+ and Duel .IsExistingMatchingCard (s .selfspcostfilter ,tp ,LOCATION_MZONE ,0 ,1 ,nil ,tp ,sc )
76+ end
77+ function s .selfsptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ,c )
78+ local g = Duel .SelectMatchingCard (tp ,s .selfspcostfilter ,tp ,LOCATION_MZONE ,0 ,1 ,1 ,true ,nil ,tp ,c )
79+ if g and # g > 0 then
80+ g :KeepAlive ()
81+ e :SetLabelObject (g )
82+ return true
83+ end
84+ return false
85+ end
86+ function s .selfspop (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,c )
87+ local g = e :GetLabelObject ()
88+ if not g then return end
89+ Duel .Remove (g ,POS_FACEUP ,REASON_COST |REASON_MATERIAL )
90+ g :DeleteGroup ()
91+ end
92+ function s .thfilter (c )
93+ return (c :IsCode (CARD_DARK_MAGICIAN ) or c :ListsCode (CARD_DARK_MAGICIAN )) and c :IsAbleToHand ()
94+ end
95+ function s .thtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
96+ if chk == 0 then return Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,nil ) end
97+ Duel .SetOperationInfo (0 ,CATEGORY_TOHAND ,nil ,1 ,tp ,LOCATION_DECK )
98+ end
99+ function s .thop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
100+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_ATOHAND )
101+ local g = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,1 ,nil )
102+ if # g > 0 then
103+ Duel .SendtoHand (g ,nil ,REASON_EFFECT )
104+ Duel .ConfirmCards (1 - tp ,g )
105+ end
106+ end
0 commit comments