1+ -- エンディミオン皇国
2+ -- Endymion Empire
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- When this card is activated: Add 1 "Regulus, the Prince of Endymion" or 1 monster that mentions it from your Deck to your hand, then if your opponent controls a monster, you can Special Summon 1 Spellcaster monster from your hand
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_ACTIVATE )
11+ e1 :SetCode (EVENT_FREE_CHAIN )
12+ e1 :SetCountLimit (1 ,{id ,0 },EFFECT_COUNT_CODE_OATH )
13+ e1 :SetTarget (s .target )
14+ e1 :SetOperation (s .activate )
15+ c :RegisterEffect (e1 )
16+ -- If a card(s) you control would be destroyed by battle or card effect, you can destroy 1 "Regulus, the Prince of Endymion" in your hand or face-up Monster Zone instead
17+ local e2 = Effect .CreateEffect (c )
18+ e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
19+ e2 :SetCode (EFFECT_DESTROY_REPLACE )
20+ e2 :SetRange (LOCATION_SZONE )
21+ e2 :SetCountLimit (1 ,{id ,1 })
22+ e2 :SetTarget (s .desreptg )
23+ e2 :SetOperation (s .desrepop )
24+ e2 :SetValue (function (e ,c ) return s .repfilter (c ,e :GetHandlerPlayer ()) end )
25+ c :RegisterEffect (e2 )
26+ end
27+ s .listed_names = {CARD_REGULUS_THE_PRINCE_OF_ENDYMION }
28+ function s .thfilter (c )
29+ return (c :IsCode (CARD_REGULUS_THE_PRINCE_OF_ENDYMION ) or (c :IsMonster () and c :ListsCode (CARD_REGULUS_THE_PRINCE_OF_ENDYMION )))
30+ and c :IsAbleToHand ()
31+ end
32+ function s .target (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
33+ if chk == 0 then return Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,nil ) end
34+ Duel .SetOperationInfo (0 ,CATEGORY_TOHAND ,nil ,1 ,tp ,LOCATION_DECK )
35+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_HAND )
36+ end
37+ function s .spfilter (c ,e ,tp )
38+ return c :IsRace (RACE_SPELLCASTER ) and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false )
39+ end
40+ function s .activate (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
41+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_ATOHAND )
42+ local g = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,1 ,nil )
43+ if # g > 0 and Duel .SendtoHand (g ,nil ,REASON_EFFECT )> 0 then
44+ Duel .ConfirmCards (1 - tp ,g )
45+ Duel .ShuffleHand (tp )
46+ if Duel .GetFieldGroupCount (tp ,0 ,LOCATION_MZONE )> 0 and Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
47+ and Duel .IsExistingMatchingCard (s .spfilter ,tp ,LOCATION_HAND ,0 ,1 ,nil ,e ,tp )
48+ and Duel .SelectYesNo (tp ,aux .Stringid (id ,1 )) then
49+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
50+ local sg = Duel .SelectMatchingCard (tp ,s .spfilter ,tp ,LOCATION_HAND ,0 ,1 ,1 ,nil ,e ,tp )
51+ if # sg > 0 then
52+ Duel .BreakEffect ()
53+ Duel .SpecialSummon (sg ,0 ,tp ,tp ,false ,false ,POS_FACEUP )
54+ end
55+ end
56+ end
57+ end
58+ function s .repfilter (c ,tp )
59+ return c :IsControler (tp ) and c :IsOnField () and c :IsReason (REASON_BATTLE |REASON_EFFECT )
60+ and not c :IsReason (REASON_REPLACE )
61+ end
62+ function s .desfilter (c ,e )
63+ return c :IsCode (CARD_REGULUS_THE_PRINCE_OF_ENDYMION ) and (c :IsLocation (LOCATION_HAND ) or c :IsFaceup ())
64+ and c :IsDestructable (e ) and not c :IsStatus (STATUS_DESTROY_CONFIRMED |STATUS_BATTLE_DESTROYED )
65+ end
66+ function s .desreptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
67+ if chk == 0 then return eg :IsExists (s .repfilter ,1 ,nil ,tp )
68+ and Duel .IsExistingMatchingCard (s .desfilter ,tp ,LOCATION_HAND |LOCATION_MZONE ,0 ,1 ,nil ,e ) end
69+ if Duel .SelectEffectYesNo (tp ,e :GetHandler (),96 ) then
70+ Duel .Hint (HINT_CARD ,0 ,id )
71+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_DESREPLACE )
72+ local sc = Duel .SelectMatchingCard (tp ,s .desfilter ,tp ,LOCATION_HAND |LOCATION_MZONE ,0 ,1 ,1 ,nil ,e ):GetFirst ()
73+ e :SetLabelObject (sc )
74+ sc :SetStatus (STATUS_DESTROY_CONFIRMED ,true )
75+ if sc :IsLocation (LOCATION_HAND ) then
76+ Duel .ConfirmCards (1 - tp ,sc )
77+ else
78+ Duel .HintSelection (sc )
79+ end
80+ return true
81+ else
82+ return false
83+ end
84+ end
85+ function s .desrepop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
86+ local sc = e :GetLabelObject ()
87+ sc :SetStatus (STATUS_DESTROY_CONFIRMED ,false )
88+ Duel .Destroy (sc ,REASON_EFFECT |REASON_REPLACE )
89+ end
0 commit comments