--灯火之哀思 local m=28327017 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_NEGATE+CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetCountLimit(1,m) e1:SetCondition(cm.condition) e1:SetTarget(cm.target) e1:SetOperation(cm.activate) c:RegisterEffect(e1) --ritual summon local e2=aux.AddRitualProcGreaterCode(c,28327000) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_GRAVE) e2:SetHintTiming(0,TIMING_END_PHASE) e2:SetCountLimit(1,m+900) e2:SetCondition(aux.exccon) e2:SetCost(aux.bfgcost) --act in hand local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_TRAP_ACT_IN_HAND) e3:SetCondition(cm.phandcon) c:RegisterEffect(e3) end function cm.cfilter(c) return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER) and c:IsType(TYPE_RITUAL) and c:IsType(TYPE_MONSTER) end function cm.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(cm.cfilter,tp,LOCATION_MZONE,0,1,nil) and Duel.IsChainNegatable(ev) and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_TOHAND,eg,1,0,0) end end function cm.sgfilter(c) return c:IsLocation(LOCATION_HAND) end function cm.activate(e,tp,eg,ep,ev,re,r,rp) local ec=re:GetHandler() if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then ec:CancelToGrave() Duel.SendtoHand(ec,nil,REASON_EFFECT) end local og=Duel.GetOperatedGroup() local ct=og:FilterCount(cm.sgfilter,nil,1-tp) if ct==0 then local tg=Duel.GetMatchingGroup(Card.IsAbleToDeck,tp,LOCATION_GRAVE+LOCATION_ONFIELD,LOCATION_GRAVE+LOCATION_ONFIELD,nil) if #tg>0 and Duel.SelectYesNo(tp,aux.Stringid(m,1)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=tg:Select(tp,1,1,nil) Duel.BreakEffect() Duel.SendtoDeck(sg,nil,2,REASON_EFFECT) end end end function cm.pfilter(c) return c:IsFaceup() and c:IsCode(28327000) end function cm.phandcon(e) return Duel.IsExistingMatchingCard(cm.pfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil) end