--灯火之赠礼 local m=28327013 local cm=_G["c"..m] xpcall(function() require("expansions/script/c28327000") end,function() require("script/c28327000") end) function cm.initial_effect(c) aux.AddCodeList(c,28327000) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DECKDES) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,m) e1:SetTarget(cm.target) e1:SetOperation(cm.activate) c:RegisterEffect(e1) --to hand local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_TODECK) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,m+900) e2:SetCondition(aux.exccon) e2:SetTarget(cm.thtg) e2:SetOperation(cm.thop) c:RegisterEffect(e2) end function cm.filter(c,e,tp,m) if bit.band(c:GetType(),0x81)~=0x81 or not c:IsCode(28327000) or not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,false,true) then return false end if c.mat_filter then m=m:Filter(c.mat_filter,nil,tp) end return m:CheckWithSumEqual(Card.GetRitualLevel,c:GetLevel(),1,99,c) end function cm.matfilter(c) return c:IsType(TYPE_RITUAL) and c:IsType(TYPE_MONSTER) and aux.IsCodeListed(c,28327000) and c:IsAbleToGrave() end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return false end local mg=Duel.GetMatchingGroup(cm.matfilter,tp,LOCATION_DECK,0,nil) return Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_HAND,0,1,nil,e,tp,mg) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function cm.activate(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local mg=Duel.GetMatchingGroup(cm.matfilter,tp,LOCATION_DECK,0,nil) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp,mg) if tg:GetCount()>0 then local tc=tg:GetFirst() if tc.mat_filter then mg=mg:Filter(tc.mat_filter,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local mat=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),1,99,tc) tc:SetMaterial(mat) Duel.SendtoGrave(mat,REASON_EFFECT+REASON_MATERIAL+REASON_RITUAL) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) tc:CompleteProcedure() end end function cm.thfilter(c) return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER) and c:IsAbleToHand() and c:IsType(TYPE_RITUAL) and c:IsType(TYPE_MONSTER) end function cm.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE+LOCATION_REMOVED) and chkc:IsControler(tp) and cm.thfilter(chkc) end if chk==0 then return e:GetHandler():IsAbleToDeck() and Duel.IsExistingTarget(cm.thfilter,tp,LOCATION_MZONE+LOCATION_REMOVED,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectTarget(tp,cm.thfilter,tp,LOCATION_MZONE+LOCATION_REMOVED,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0) end function cm.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,2,REASON_EFFECT)~=0 and c:IsLocation(LOCATION_DECK) and tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) end end