33local s ,id = GetID ()
44function s .initial_effect (c )
55 -- Activate
6+ local e0 = Effect .CreateEffect (c )
7+ e0 :SetType (EFFECT_TYPE_ACTIVATE )
8+ e0 :SetCode (EVENT_FREE_CHAIN )
9+ c :RegisterEffect (e0 )
10+ -- Place 1 "Spellbook" Spell from your GY on the bottom of your Deck, except "The Grand Spellbook Tower", and if you do, draw 1 card
611 local e1 = Effect .CreateEffect (c )
7- e1 :SetType (EFFECT_TYPE_ACTIVATE )
8- e1 :SetCode (EVENT_FREE_CHAIN )
12+ e1 :SetDescription (aux .Stringid (id ,0 ))
13+ e1 :SetCategory (CATEGORY_TODECK + CATEGORY_DRAW )
14+ e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
15+ e1 :SetCode (EVENT_PHASE |PHASE_STANDBY )
16+ e1 :SetRange (LOCATION_FZONE )
17+ e1 :SetCountLimit (1 )
18+ e1 :SetCondition (function (e ,tp ) return Duel .IsTurnPlayer (tp ) and Duel .IsExistingMatchingCard (aux .FaceupFilter (Card .IsRace ,RACE_SPELLCASTER ),tp ,LOCATION_MZONE |LOCATION_GRAVE ,0 ,1 ,nil ) end )
19+ e1 :SetTarget (s .drtg )
20+ e1 :SetOperation (s .drop )
921 c :RegisterEffect (e1 )
10- -- Place 1 "Spellbook" Spell Card from your GY on the bottom of your Deck then draw 1 card
22+ -- Special Summon 1 Spellcaster monster from your hand or Deck whose Level is less than or equal to the number of "Spellbook" Spells in your GY
1123 local e2 = Effect .CreateEffect (c )
12- e2 :SetDescription (aux .Stringid (id ,0 ))
13- e2 :SetCategory (CATEGORY_TODECK + CATEGORY_DRAW )
14- e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
15- e2 :SetRange (LOCATION_FZONE )
16- e2 :SetCode (EVENT_PHASE |PHASE_STANDBY )
17- e2 :SetCountLimit (1 )
18- e2 :SetCondition (s .drcon )
19- e2 :SetTarget (s .drtg )
20- e2 :SetOperation (s .drop )
24+ e2 :SetDescription (aux .Stringid (id ,1 ))
25+ e2 :SetCategory (CATEGORY_SPECIAL_SUMMON )
26+ e2 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
27+ e2 :SetCode (EVENT_TO_GRAVE )
28+ e2 :SetCondition (function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ) return rp == 1 - tp and e :GetHandler ():IsReason (REASON_DESTROY ) end )
29+ e2 :SetTarget (s .sptg )
30+ e2 :SetOperation (s .spop )
2131 c :RegisterEffect (e2 )
22- -- Special Summon 1 Spellcaster monster from your hand or Deck whose Level is less than or equal to the number of "Spellbook" Spell Cards in your GY
23- local e3 = Effect .CreateEffect (c )
24- e3 :SetDescription (aux .Stringid (id ,1 ))
25- e3 :SetCategory (CATEGORY_SPECIAL_SUMMON )
26- e3 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
27- e3 :SetProperty (EFFECT_FLAG_DAMAGE_STEP )
28- e3 :SetCode (EVENT_TO_GRAVE )
29- e3 :SetCondition (s .spcon )
30- e3 :SetTarget (s .sptg )
31- e3 :SetOperation (s .spop )
32- c :RegisterEffect (e3 )
3332end
3433s .listed_series = {SET_SPELLBOOK }
3534s .listed_names = {id }
36- function s .cfilter (c )
37- return c :IsRace (RACE_SPELLCASTER ) and (c :IsLocation (LOCATION_GRAVE ) or c :IsFaceup ())
38- end
39- function s .drcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
40- return Duel .IsTurnPlayer (tp ) and Duel .IsExistingMatchingCard (s .cfilter ,tp ,LOCATION_MZONE |LOCATION_GRAVE ,0 ,1 ,nil )
41- end
42- function s .filter (c )
35+ function s .tdfilter (c )
4336 return c :IsSetCard (SET_SPELLBOOK ) and c :IsSpell () and c :IsAbleToDeck () and not c :IsCode (id )
4437end
4538function s .drtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
46- if chk == 0 then return Duel .IsPlayerCanDraw (tp ,1 ) and Duel .IsExistingMatchingCard (s .filter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil ) end
39+ if chk == 0 then return Duel .IsPlayerCanDraw (tp ,1 ) and Duel .IsExistingMatchingCard (s .tdfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil ) end
4740 Duel .SetOperationInfo (0 ,CATEGORY_TODECK ,nil ,1 ,tp ,LOCATION_GRAVE )
4841 Duel .SetOperationInfo (0 ,CATEGORY_DRAW ,nil ,0 ,tp ,1 )
4942end
5043function s .drop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
5144 Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TODECK )
52- local g = Duel .SelectMatchingCard (tp ,s .filter ,tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil )
45+ local g = Duel .SelectMatchingCard (tp ,s .tdfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil )
46+ if # g == 0 then return end
5347 Duel .HintSelection (g )
54- if # g > 0 and Duel .SendtoDeck (g ,nil ,SEQ_DECKBOTTOM ,REASON_EFFECT )> 0 then
55- Duel .BreakEffect ()
48+ if Duel .SendtoDeck (g ,nil ,SEQ_DECKBOTTOM ,REASON_EFFECT )> 0 then
5649 Duel .Draw (tp ,1 ,REASON_EFFECT )
5750 end
5851end
59- function s .spcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
60- return e :GetHandler ():IsReason (REASON_DESTROY ) and not e :GetHandler ():IsReason (REASON_RULE ) and rp == 1 - tp
61- end
6252function s .ctfilter (c )
6353 return c :IsSetCard (SET_SPELLBOOK ) and c :IsSpell ()
6454end
@@ -69,16 +59,17 @@ function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
6959 if chk == 0 then
7060 if Duel .GetLocationCount (tp ,LOCATION_MZONE )<= 0 then return false end
7161 local ct = Duel .GetMatchingGroupCount (s .ctfilter ,tp ,LOCATION_GRAVE ,0 ,nil )
72- return Duel .IsExistingMatchingCard (s .spfilter ,tp ,LOCATION_DECK | LOCATION_HAND ,0 ,1 ,nil ,e ,tp ,ct )
62+ return ct > 0 and Duel .IsExistingMatchingCard (s .spfilter ,tp ,LOCATION_HAND | LOCATION_DECK ,0 ,1 ,nil ,e ,tp ,ct )
7363 end
74- Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_DECK | LOCATION_HAND )
64+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_HAND | LOCATION_DECK )
7565end
7666function s .spop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
7767 if Duel .GetLocationCount (tp ,LOCATION_MZONE )<= 0 then return false end
7868 local ct = Duel .GetMatchingGroupCount (s .ctfilter ,tp ,LOCATION_GRAVE ,0 ,nil )
69+ if ct == 0 then return end
7970 Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
80- local g = Duel .SelectMatchingCard (tp ,s .spfilter ,tp ,LOCATION_DECK | LOCATION_HAND ,0 ,1 ,1 ,nil ,e ,tp ,ct )
71+ local g = Duel .SelectMatchingCard (tp ,s .spfilter ,tp ,LOCATION_HAND | LOCATION_DECK ,0 ,1 ,1 ,nil ,e ,tp ,ct )
8172 if # g > 0 then
8273 Duel .SpecialSummon (g ,0 ,tp ,tp ,false ,false ,POS_FACEUP )
8374 end
84- end
75+ end
0 commit comments