1+ -- 大輪の霊使い
2+ -- Charmers of the Grand Circle
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ c :EnableReviveLimit ()
7+ -- Fusion Materials: 2+ "Charmer" and/or "Familiar-Possessed" monsters
8+ Fusion .AddProcMixRep (c ,true ,true ,aux .FilterBoolFunctionEx (Card .IsSetCard ,{SET_CHARMER ,SET_FAMILIAR_POSSESSED }),2 ,99 )
9+ -- Keep track of the number of different original Attributes of the monsters used as its material
10+ local e0 = Effect .CreateEffect (c )
11+ e0 :SetType (EFFECT_TYPE_SINGLE )
12+ e0 :SetCode (EFFECT_MATERIAL_CHECK )
13+ e0 :SetValue (function (e ,c ) e :SetLabel (c :GetMaterial ():GetClassCount (Card .GetOriginalAttribute )) end )
14+ c :RegisterEffect (e0 )
15+ -- Repeat the process of applying 1 of these effects, up to the number of different original Attributes of the monsters used as its material (max. 4)
16+ local e1 = Effect .CreateEffect (c )
17+ e1 :SetDescription (aux .Stringid (id ,0 ))
18+ e1 :SetCategory (CATEGORY_ATKCHANGE + CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON )
19+ e1 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
20+ e1 :SetProperty (EFFECT_FLAG_DELAY )
21+ e1 :SetCode (EVENT_SPSUMMON_SUCCESS )
22+ e1 :SetCountLimit (1 ,id )
23+ e1 :SetCondition (function (e ) return e :GetHandler ():IsFusionSummoned () end )
24+ e1 :SetTarget (s .efftg )
25+ e1 :SetOperation (s .effop )
26+ e1 :SetLabelObject (e0 )
27+ c :RegisterEffect (e1 )
28+ end
29+ s .listed_series = {SET_CHARMER ,SET_FAMILIAR_POSSESSED ,SET_POSSESSED }
30+ s .material_setcode = {SET_CHARMER ,SET_FAMILIAR_POSSESSED }
31+ function s .efftg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
32+ local material_check_eff = e :GetLabelObject ()
33+ local label = material_check_eff :GetLabel ()
34+ if chk == 0 then return label > 0 end
35+ material_check_eff :SetLabel (0 )
36+ Duel .SetTargetParam (label )
37+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_ATKCHANGE ,e :GetHandler (),1 ,tp ,800 )
38+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_TOHAND ,nil ,1 ,tp ,LOCATION_DECK |LOCATION_ONFIELD )
39+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_GRAVE )
40+ end
41+ function s .thfilter (c )
42+ return c :IsSetCard (SET_POSSESSED ) and c :IsSpellTrap () and c :IsAbleToHand ()
43+ end
44+ function s .spfilter (c ,e ,tp )
45+ return c :IsRace (RACE_SPELLCASTER ) and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false )
46+ end
47+ function s .effop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
48+ local c = e :GetHandler ()
49+ local b1 ,b2 ,b3 ,b4 ,b5 ,op
50+ local max_count = math.min (Duel .GetChainInfo (0 ,CHAININFO_TARGET_PARAM ),4 )
51+ local remaining_count = max_count
52+ repeat
53+ b1 = c :IsRelateToEffect (e ) and c :IsFaceup ()
54+ b2 = Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,nil )
55+ b3 = Duel .IsExistingMatchingCard (Card .IsAbleToHand ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,1 ,nil )
56+ b4 = Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
57+ and Duel .IsExistingMatchingCard (aux .NecroValleyFilter (s .spfilter ),tp ,LOCATION_GRAVE ,0 ,1 ,nil ,e ,tp )
58+ if not (b1 or b2 or b3 or b4 ) then return end
59+ b5 = remaining_count < max_count
60+ op = Duel .SelectEffect (tp ,
61+ {b1 ,aux .Stringid (id ,1 )},
62+ {b2 ,aux .Stringid (id ,2 )},
63+ {b3 ,aux .Stringid (id ,3 )},
64+ {b4 ,aux .Stringid (id ,4 )},
65+ {b5 ,aux .Stringid (id ,5 )})
66+ remaining_count = remaining_count - 1
67+ if op == 1 then
68+ -- This card gains 800 ATK
69+ c :UpdateAttack (800 )
70+ elseif op == 2 then
71+ -- Add 1 "Possessed" Spell/Trap from your Deck to your hand
72+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_ATOHAND )
73+ local g = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,1 ,nil )
74+ if # g > 0 then
75+ Duel .SendtoHand (g ,nil ,REASON_EFFECT )
76+ Duel .ConfirmCards (1 - tp ,g )
77+ end
78+ elseif op == 3 then
79+ -- Return 1 card on the field to the hand
80+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_RTOHAND )
81+ local g = Duel .SelectMatchingCard (tp ,Card .IsAbleToHand ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,1 ,1 ,nil )
82+ if # g > 0 then
83+ Duel .HintSelection (g )
84+ Duel .SendtoHand (g ,nil ,REASON_EFFECT )
85+ end
86+ elseif op == 4 then
87+ -- Special Summon 1 Spellcaster monster from your GY
88+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
89+ local g = Duel .SelectMatchingCard (tp ,aux .NecroValleyFilter (s .spfilter ),tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil ,e ,tp )
90+ if # g > 0 then
91+ Duel .SpecialSummon (g ,0 ,tp ,tp ,false ,false ,POS_FACEUP )
92+ end
93+ elseif op == 5 then
94+ -- Finish applying effects
95+ return
96+ end
97+ until remaining_count == 0
98+ end
0 commit comments