--水晶魔法小妖精 寇思莫兹 local m=33701412 local cm=_G["c"..m] function cm.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DECKDES) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_CHAINING) e1:SetRange(LOCATION_MZONE+LOCATION_HAND) e1:SetCondition(cm.condition) e1:SetCost(cm.cost) e1:SetOperation(cm.operation) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(m,0)) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_PREDRAW) e2:SetRange(LOCATION_DECK) e2:SetCountLimit(1) e2:SetCondition(cm.thcon) e2:SetOperation(cm.thop) c:RegisterEffect(e2) --destroy local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_BATTLE_CONFIRM) e3:SetRange(LOCATION_DECK) e3:SetCondition(cm.descon) e3:SetCost(cm.descost) e3:SetTarget(cm.destg) e3:SetOperation(cm.desop) c:RegisterEffect(e3) end function cm.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,0,LOCATION_ONFIELD)-Duel.GetFieldGroupCount(tp,LOCATION_ONFIELD,0)>=5 end function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function cm.operation(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CHANGE_DAMAGE) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetValue(cm.damval) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_PHASE+PHASE_END) e2:SetTargetRange(1,0) e2:SetReset(RESET_PHASE+PHASE_END) e2:SetCountLimit(1) e2:SetCondition(cm.tdcon) e2:SetOperation(cm.tdop) Duel.RegisterEffect(e2,tp) e:GetHandler():RegisterFlagEffect(m,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,0) end function cm.damval(e,re,val,r,rp,rc) local ct=Duel.GetFieldGroupCount(tp,LOCATION_DECK,0) local ct1=math.ceil(val/50) if ctct1 then val=val-ct1*50 else val=0 end return val end function cm.tdcon(e,tp,eg,ep,ev,re,r,rp) return e:GetOwner():GetFlagEffect(m)~=0 end function cm.tdop(e,tp,eg,ep,ev,re,r,rp) Duel.SendtoDeck(e:GetOwner(),tp,2,REASON_EFFECT) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_PUBLIC) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e:GetHandler():RegisterEffect(e1) end function cm.thcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return tp==Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0 and Duel.GetDrawCount(tp)>0 and Duel.GetDecktopGroup(tp,1):IsContains(c) and c:IsPublic() end function cm.thop(e,tp,eg,ep,ev,re,r,rp) aux.DrawReplaceCount=aux.DrawReplaceCount+1 local g=Duel.GetMatchingGroup(Card.IsAbleToHand,tp,LOCATION_GRAVE,0,nil) if aux.DrawReplaceCount<=aux.DrawReplaceMax and g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local sg=g:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function cm.descon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return Duel.GetDecktopGroup(tp,1):IsContains(c) and c:IsPublic() end function cm.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end Duel.SendtoGrave(e:GetHandler(),REASON_COST) end function cm.destg(e,tp,eg,ep,ev,re,r,rp,chk) local a=Duel.GetAttacker() local d=Duel.GetAttackTarget() if chk==0 then return a and d end if a:IsControler(tp) then a=d end Duel.SetTargetCard(a) Duel.SetOperationInfo(0,CATEGORY_DESTROY,a,1,0,0) end function cm.desop(e,tp,eg,ep,ev,re,r,rp) local t=Duel.GetFirstTarget() if t:IsRelateToBattle() then Duel.Destroy(t,REASON_EFFECT) end end