local m=31420009 local cm=_G["c"..m] cm.name="Moonlight of the Tokeito" function cm.initial_effect(c) aux.EnablePendulumAttribute(c) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_ADJUST) e2:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_HAND) e2:SetCondition(cm.wincon) e2:SetOperation(cm.winop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_CANNOT_NEGATE) e3:SetRange(LOCATION_PZONE) e3:SetTargetRange(1,0) e3:SetTarget(cm.splimit) --c:RegisterEffect(e3) local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(31420001,0)) e4:SetCategory(CATEGORY_TOHAND) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetCode(EVENT_PREDRAW) e4:SetRange(LOCATION_PZONE) e4:SetCondition(cm.thcon) e4:SetTarget(cm.thtg) e4:SetOperation(cm.thop) c:RegisterEffect(e4) local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_NEGATE) e5:SetType(EFFECT_TYPE_QUICK_O) e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e5:SetCode(EVENT_CHAINING) e5:SetRange(LOCATION_MZONE) e5:SetCondition(cm.negcon) e5:SetCost(cm.negcost) e5:SetTarget(cm.negtg) e5:SetOperation(cm.negop) c:RegisterEffect(e5) --Duel.AddCustomActivityCounter(31420001,ACTIVITY_CHAIN,cm.chainfilter) local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_FIELD) e6:SetCode(EFFECT_SPSUMMON_PROC) e6:SetProperty(EFFECT_FLAG_UNCOPYABLE) e6:SetRange(LOCATION_PZONE) e6:SetCondition(cm.hspcon) e6:SetValue(1) c:RegisterEffect(e6) local e7=Effect.CreateEffect(c) e7:SetProperty(EFFECT_FLAG_UNCOPYABLE) e7:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e7:SetCode(EVENT_SPSUMMON_SUCCESS) e7:SetCondition(cm.hspcon2) e7:SetOperation(cm.hspop) c:RegisterEffect(e7) end function cm.chainfilter(re,tp,cid) return re:GetHandler():IsSetCard(0x5311) or re:GetHandler():IsType(TYPE_SPELL) or re:GetHandler():IsType(TYPE_TRAP) end function cm.winfilter(c) local res=0 if c:IsSetCard(0x5311) and c:IsType(TYPE_MONSTER) then res=1 end return res end function cm.check(g) return g:GetCount()==6 and g:GetClassCount(Card.GetCode)==6 and g:GetSum(cm.winfilter)==6 end function cm.wincon(e,tp,eg,ep,ev,re,r,rp) return cm.check(Duel.GetFieldGroup(tp,LOCATION_HAND,0)) or cm.check(Duel.GetFieldGroup(tp,0,LOCATION_HAND)) end function cm.winop(e,tp,eg,ep,ev,re,r,rp) local winmessage = 0x60 local g1=Duel.GetFieldGroup(tp,LOCATION_HAND,0) local g2=Duel.GetFieldGroup(tp,0,LOCATION_HAND) local wtp=cm.check(g1) local wntp=cm.check(g2) if wtp and not wntp then Duel.ConfirmCards(1-tp,g1) Duel.Win(tp,winmessage) elseif not wtp and wntp then Duel.ConfirmCards(tp,g2) Duel.Win(1-tp,winmessage) elseif wtp and wntp then Duel.ConfirmCards(1-tp,g1) Duel.ConfirmCards(tp,g2) Duel.Win(PLAYER_NONE,winmessage) end end function cm.splimit(e,c) return not c:IsSetCard(0x5311) end function cm.thcon(e,tp,eg,ep,ev,re,r,rp) return tp==Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0 end function cm.thfilter(c) return c:IsSetCard(0x5311) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function cm.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and cm.thfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(cm.thfilter,tp,LOCATION_GRAVE,0,1,nil) end local dt=Duel.GetDrawCount(tp) if dt~=0 then e:SetLabel(1) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,cm.thfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_DRAW_COUNT) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_DRAW) e1:SetValue(0) Duel.RegisterEffect(e1,tp) else e:SetLabel(0) end end function cm.thop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tc=Duel.GetFirstTarget() if e:GetLabel()==1 and tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) end end function cm.negcon(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and (re:IsActiveType(TYPE_SPELL) or re:IsActiveType(TYPE_TRAP)) and Duel.IsChainNegatable(ev) and Duel.IsPlayerCanDraw(re:GetHandlerPlayer(),1) end function cm.negcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToHandAsCost() end-- and Duel.GetCustomActivityCount(31420001,tp,ACTIVITY_CHAIN)==0 end Duel.SendtoHand(e:GetHandler(),nil,REASON_COST) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetTargetRange(1,0) e1:SetValue(cm.aclimit) e1:SetReset(RESET_PHASE+PHASE_END) --Duel.RegisterEffect(e1,tp) end function cm.aclimit(e,re,tp) return not (re:GetHandler():IsSetCard(0x5311) or re:GetHandler():IsType(TYPE_SPELL) or re:GetHandler():IsType(TYPE_TRAP)) end function cm.negtg(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) end function cm.negop(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateActivation(ev) and re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:GetHandler():IsRelateToEffect(re) then Duel.SendtoGrave(eg,REASON_EFFECT) end Duel.Draw(re:GetHandler():GetControler(),1,REASON_EFFECT) end function cm.hspcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 end function cm.hspcon2(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+1 end function cm.hspop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetTarget(cm.splimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function cm.splimit(e,c,sump,sumtype,sumpos,targetp,se) return not c:IsSetCard(0x5311) end