1+ -- DDD聖賢王アルフレッド
2+ -- D/D/D Sage King Alfred
3+ -- Scripted by The Razgriz
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ c :EnableReviveLimit ()
7+ -- Fusion Materials: 2 "D/D" monsters
8+ Fusion .AddProcMixN (c ,true ,true ,aux .FilterBoolFunctionEx (Card .IsSetCard ,SET_DD ),2 )
9+ local params = {
10+ fusfilter = aux .FilterBoolFunction (Card .IsSetCard ,SET_DDD ),
11+ matfilter = Card .IsAbleToDeck ,
12+ extrafil = function (e ,tp ,mg )
13+ return Duel .GetMatchingGroup (Fusion .IsMonsterFilter (Card .IsFaceup ,Card .IsAbleToDeck ),tp ,LOCATION_REMOVED ,0 ,nil )
14+ end ,
15+ extraop = Fusion .ShuffleMaterial ,
16+ extratg = function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
17+ if chk == 0 then return true end
18+ Duel .SetOperationInfo (0 ,CATEGORY_TODECK ,nil ,1 ,tp ,LOCATION_HAND |LOCATION_MZONE |LOCATION_REMOVED )
19+ end
20+ }
21+ -- Fusion Summon 1 "D/D/D" Fusion Monster from your Extra Deck, by shuffling its materials from your hand, field, and/or banishment into the Deck
22+ local e1 = Effect .CreateEffect (c )
23+ e1 :SetDescription (aux .Stringid (id ,0 ))
24+ e1 :SetCategory (CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON + CATEGORY_FUSION_SUMMON )
25+ e1 :SetType (EFFECT_TYPE_IGNITION )
26+ e1 :SetRange (LOCATION_MZONE )
27+ e1 :SetCountLimit (1 ,id )
28+ e1 :SetTarget (Fusion .SummonEffTG (params ))
29+ e1 :SetOperation (Fusion .SummonEffOP (params ))
30+ c :RegisterEffect (e1 )
31+ -- Place "Dark Contract" Spell/Traps face-up on your field from your GY and/or banishment, up to the number of "D/D/D" monsters you control
32+ local e2 = Effect .CreateEffect (c )
33+ e2 :SetDescription (aux .Stringid (id ,1 ))
34+ e2 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
35+ e2 :SetProperty (EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET )
36+ e2 :SetCode (EVENT_REMOVE )
37+ e2 :SetCountLimit (1 ,{id ,1 })
38+ e2 :SetTarget (s .pltg )
39+ e2 :SetOperation (s .plop )
40+ c :RegisterEffect (e2 )
41+ end
42+ s .listed_series = {SET_DD ,SET_DDD ,SET_DARK_CONTRACT }
43+ s .material_setcode = SET_DD
44+ function s .plfilter (c ,tp )
45+ return c :IsSetCard (SET_DARK_CONTRACT ) and c :IsContinuousSpellTrap () and c :IsFaceup () and c :CheckUniqueOnField (tp )
46+ and not c :IsForbidden ()
47+ end
48+ function s .pltg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ,chkc )
49+ if chkc then return chkc :IsLocation (LOCATION_GRAVE |LOCATION_REMOVED ) and chkc :IsControler (tp ) and s .plfilter (chkc ,tp ) end
50+ local ct = Duel .GetMatchingGroupCount (aux .FaceupFilter (Card .IsSetCard ,SET_DDD ),tp ,LOCATION_MZONE ,0 ,nil )
51+ local ft = Duel .GetLocationCount (tp ,LOCATION_SZONE )
52+ if chk == 0 then return ct > 0 and ft > 0 and Duel .IsExistingTarget (s .plfilter ,tp ,LOCATION_GRAVE |LOCATION_REMOVED ,0 ,1 ,nil ,tp ) end
53+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TOFIELD )
54+ local g = Duel .SelectTarget (tp ,s .plfilter ,tp ,LOCATION_GRAVE |LOCATION_REMOVED ,0 ,1 ,math.min (ct ,ft ),nil ,tp )
55+ if g :IsExists (Card .IsLocation ,1 ,nil ,LOCATION_GRAVE ) then
56+ Duel .SetOperationInfo (0 ,CATEGORY_LEAVE_GRAVE ,nil ,1 ,tp ,0 )
57+ end
58+ end
59+ function s .plop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
60+ local tg = Duel .GetTargetCards (e )
61+ if # tg == 0 then return end
62+ local gg = Group .CreateGroup ()
63+ local ft = Duel .GetLocationCount (tp ,LOCATION_SZONE )
64+ if ft <# tg then
65+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TOFIELD )
66+ local sg = tg :FilterSelect (tp ,s .plfilter ,ft ,ft ,nil ,tp )
67+ gg = tg - sg
68+ tg = sg
69+ end
70+ for tc in tg :Iter () do
71+ Duel .MoveToField (tc ,tp ,tp ,LOCATION_SZONE ,POS_FACEUP ,true )
72+ end
73+ if # gg > 0 then
74+ Duel .SendtoGrave (gg ,REASON_RULE |REASON_RETURN ,PLAYER_NONE ,tp )
75+ end
76+ end
0 commit comments