1+ -- 無垢なる者 メディウス
2+ -- Medius the Innocent
3+ -- Scripted by Hatter
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- Take 1 "Imprisoned Deity" monster from your Deck and either add it to your hand or Special Summon it
7+ local e1 = Effect .CreateEffect (c )
8+ e1 :SetDescription (aux .Stringid (id ,0 ))
9+ e1 :SetCategory (CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON )
10+ e1 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
11+ e1 :SetProperty (EFFECT_FLAG_DELAY )
12+ e1 :SetCode (EVENT_SUMMON_SUCCESS )
13+ e1 :SetCountLimit (1 ,id )
14+ e1 :SetTarget (s .thsptg )
15+ e1 :SetOperation (s .thspop )
16+ c :RegisterEffect (e1 )
17+ local e2 = e1 :Clone ()
18+ e2 :SetCode (EVENT_SPSUMMON_SUCCESS )
19+ c :RegisterEffect (e2 )
20+ -- Shuffle 1 monster from your hand or face-up field into the Deck, and if you do, Special Summon this card, but banish it when it leaves the field
21+ local e3 = Effect .CreateEffect (c )
22+ e3 :SetDescription (aux .Stringid (id ,1 ))
23+ e3 :SetCategory (CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON )
24+ e3 :SetType (EFFECT_TYPE_IGNITION )
25+ e3 :SetRange (LOCATION_GRAVE )
26+ e3 :SetCountLimit (1 ,{id ,1 })
27+ e3 :SetTarget (s .tdtg )
28+ e3 :SetOperation (s .tdop )
29+ c :RegisterEffect (e3 )
30+ end
31+ s .listed_series = {SET_IMPRISONED_DEITY }
32+ function s .thspfilter (c ,e ,tp ,sp_chk )
33+ return c :IsSetCard (SET_IMPRISONED_DEITY ) and c :IsMonster ()
34+ and (c :IsAbleToHand () or (sp_chk and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false )))
35+ end
36+ function s .thsptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
37+ if chk == 0 then
38+ local sp_chk = Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
39+ return Duel .IsExistingMatchingCard (s .thspfilter ,tp ,LOCATION_DECK ,0 ,1 ,nil ,e ,tp ,sp_chk )
40+ end
41+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_TOHAND ,nil ,1 ,tp ,LOCATION_DECK )
42+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_DECK )
43+ end
44+ function s .thspop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
45+ local sp_chk = Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
46+ Duel .Hint (HINT_SELECTMSG ,tp ,aux .Stringid (id ,2 ))
47+ local tc = Duel .SelectMatchingCard (tp ,s .thspfilter ,tp ,LOCATION_DECK ,0 ,1 ,1 ,nil ,e ,tp ,sp_chk ):GetFirst ()
48+ if not tc then return end
49+ aux .ToHandOrElse (tc ,tp ,
50+ function () return sp_chk and tc :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ) end ,
51+ function () Duel .SpecialSummon (tc ,0 ,tp ,tp ,false ,false ,POS_FACEUP ) end ,
52+ aux .Stringid (id ,3 )
53+ )
54+ end
55+ function s .tdfilter (c ,tp )
56+ return (c :IsLocation (LOCATION_HAND ) and c :IsMonster () or c :IsFaceup ())
57+ and c :IsAbleToDeck () and Duel .GetMZoneCount (tp ,c )> 0
58+ end
59+ function s .tdtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
60+ local c = e :GetHandler ()
61+ if chk == 0 then return Duel .IsExistingMatchingCard (s .tdfilter ,tp ,LOCATION_HAND |LOCATION_MZONE ,0 ,1 ,nil ,tp )
62+ and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ) end
63+ Duel .SetOperationInfo (0 ,CATEGORY_TODECK ,nil ,1 ,tp ,LOCATION_HAND |LOCATION_MZONE )
64+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,c ,1 ,tp ,0 )
65+ end
66+ function s .tdop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
67+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TODECK )
68+ local sc = Duel .SelectMatchingCard (tp ,s .tdfilter ,tp ,LOCATION_HAND |LOCATION_MZONE ,0 ,1 ,1 ,nil ,tp ):GetFirst ()
69+ if not sc then return end
70+ if sc :IsLocation (LOCATION_HAND ) then Duel .ConfirmCards (1 - tp ,sc )
71+ else Duel .HintSelection (sc ) end
72+ local c = e :GetHandler ()
73+ if Duel .SendtoDeck (sc ,nil ,SEQ_DECKSHUFFLE ,REASON_EFFECT )> 0
74+ and sc :IsLocation (LOCATION_DECK |LOCATION_EXTRA )
75+ and c :IsRelateToEffect (e )
76+ and Duel .SpecialSummon (c ,0 ,tp ,tp ,false ,false ,POS_FACEUP )> 0 then
77+ -- Banish it when it leaves the field
78+ local e1 = Effect .CreateEffect (c )
79+ e1 :SetDescription (3300 )
80+ e1 :SetType (EFFECT_TYPE_SINGLE )
81+ e1 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_CLIENT_HINT )
82+ e1 :SetCode (EFFECT_LEAVE_FIELD_REDIRECT )
83+ e1 :SetValue (LOCATION_REMOVED )
84+ e1 :SetReset (RESET_EVENT |RESETS_REDIRECT )
85+ c :RegisterEffect (e1 ,true )
86+ end
87+ end
0 commit comments