--Magicalia's Majestic Unicorn local s,id=GetID() function s.initial_effect(c) --During the Main Phase, if your opponent controls more monsters than you do (Quick Effect): You can Special Summon this card from your hand. local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_HAND) e1:SetHintTiming(0,TIMING_MAIN_END|TIMINGS_CHECK_MONSTER|TIMING_SUMMON) e1:SetCountLimit(1,{id,0}) e1:SetCondition(s.spcon) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --During the Main Phase, if you have 3 or more banished "Magicalia" Normal Spells (Quick Effect): You can Fusion Summon 1 Spellcaster Fusion Monster from your Extra Deck, by banishing monsters from your hand or field as material, --including this card. If your opponent controls a monster that was Special Summoned from the Extra Deck, you can also banish 1 "Magicalia the Glorious Magical Girl" from your Deck as Fusion Material. local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_MZONE) e2:SetHintTiming(0,TIMING_MAIN_END|TIMINGS_CHECK_MONSTER|TIMING_SUMMON) e2:SetCountLimit(1,{id,1}) e2:SetCondition(s.fscon) e2:SetTarget(s.fstg) e2:SetOperation(s.fsop) c:RegisterEffect(e2) --Once per chain, if your opponent Special Summons a monster(s): You can banish 1 "Magicalia" Normal Spell from your Deck with a different name from your banished cards. local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_REMOVE) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetRange(LOCATION_MZONE) e3:SetCondition(s.rmcon) e3:SetTarget(s.rmtg) e3:SetOperation(s.rmop) c:RegisterEffect(e3) end function s.spcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return Duel.IsMainPhase() and Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.GetFieldGroupCount(c:GetControler(),LOCATION_MZONE,0,nil)0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end function s.cfilter(c) return c:IsFaceup() and c:IsSetCard(0x722) and c:GetType()==TYPE_SPELL end function s.fscon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_REMOVED,0,3,nil) and Duel.IsMainPhase() end function s.filter1(c,e) return c:IsOnField() and c:IsAbleToRemove() and not c:IsImmuneToEffect(e) end function s.filter2(c,e,tp,m,f,gc,chkf) return c:IsType(TYPE_FUSION) and c:IsRace(RACE_SPELLCASTER) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,gc,chkf) end function s.filter3(c,d) return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove() and (c:IsCode(77222578) or d==false) end function s.fcheck(tp,sg,fc) return sg:FilterCount(Card.IsLocation,nil,LOCATION_DECK)<=1 end function s.gcheck(sg) return sg:FilterCount(Card.IsLocation,nil,LOCATION_DECK)<=1 end function s.fstg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e) local mg2=Duel.GetMatchingGroup(s.filter3,tp,LOCATION_HAND,0,nil,false) mg1:Merge(mg2) if Duel.IsExistingMatchingCard(Card.IsSummonLocation,tp,0,LOCATION_MZONE,1,nil,LOCATION_EXTRA) then local mg3=Duel.GetMatchingGroup(s.filter3,tp,LOCATION_DECK,0,nil,true) if mg3:GetCount()>0 then mg1:Merge(mg3) aux.FCheckAdditional=s.fcheck aux.GCheckAdditional=s.gcheck end end local res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,c,chkf) if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg4=fgroup(ce,e,tp) local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg4,mf,c,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_ONFIELD+LOCATION_HAND) end function s.fsop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local chkf=tp if not c:IsRelateToEffect(e) or c:IsImmuneToEffect(e) then return end local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e) local mg2=Duel.GetMatchingGroup(s.filter3,tp,LOCATION_HAND,0,nil,false) mg1:Merge(mg2) local exmat=false if Duel.IsExistingMatchingCard(Card.IsSummonLocation,tp,0,LOCATION_MZONE,1,nil,LOCATION_EXTRA) then local mg3=Duel.GetMatchingGroup(s.filter3,tp,LOCATION_DECK+LOCATION_EXTRA,0,nil,true) if mg3:GetCount()>0 then mg1:Merge(mg3) exmat=true end end if exmat then aux.FCheckAdditional=s.fcheck aux.GCheckAdditional=s.gcheck end local sg1=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,c,chkf) aux.FCheckAdditional=nil aux.GCheckAdditional=nil local mg4=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg4=fgroup(ce,e,tp) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,mf,c,chkf) end if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then if exmat then aux.FCheckAdditional=s.fcheck aux.GCheckAdditional=s.gcheck end local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,c,chkf) aux.FCheckAdditional=nil aux.GCheckAdditional=nil tc:SetMaterial(mat1) Duel.Remove(mat1,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) else local mat2=Duel.SelectFusionMaterial(tp,tc,mg4,c,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end end function s.rmcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(Card.IsSummonPlayer,1,e:GetHandler(),1-tp) end function s.rmfilter2(c,code) return c:IsCode(code) and c:IsFaceup() end function s.rmfilter(c,tp) return c:IsSetCard(0x722) and c:IsAbleToRemove() and c:GetType()==TYPE_SPELL and not Duel.IsExistingMatchingCard(s.rmfilter2,tp,LOCATION_REMOVED,0,1,nil,c:GetCode()) end function s.rmtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.rmfilter,tp,LOCATION_DECK,0,1,nil,tp) and e:GetHandler():GetFlagEffect(id)==0 end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_DECK) e:GetHandler():RegisterFlagEffect(id,RESET_CHAIN,0,1) end function s.rmop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,s.rmfilter,tp,LOCATION_DECK,0,1,1,nil,tp) local tc=g:GetFirst() if tc then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end