local m=31420012 local cm=_G["c"..m] cm.name="Impermanence of the Tokeito" function cm.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_ADJUST) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_DELAY) e1:SetRange(LOCATION_HAND) e1:SetCondition(cm.wincon) e1:SetOperation(cm.winop) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_HAND) e2:SetCost(cm.searcost) e2:SetTarget(cm.seartg) e2:SetOperation(cm.searop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetCondition(cm.damcon) e3:SetOperation(cm.damop) c:RegisterEffect(e3) 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.searfilter(c) return c:IsSetCard(0x5311) and c:IsAbleToHand() and not c:IsCode(31420004) end function cm.searcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return not e:GetHandler():IsPublic() and not e:GetHandler():IsStatus(STATUS_CHAINING) and e:GetHandler():IsAbleToDeck() end end function cm.seartg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cm.searfilter,tp,LOCATION_DECK,0,1,nil) and e:GetHandler():IsAbleToDeck() end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_DECK) end function cm.searop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SendtoDeck(e:GetHandler(),tp,2,REASON_EFFECT) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cm.searfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function cm.damcon(e,tp,eg,ep,ev,re,r,rp) return (re and re:GetHandler():IsSetCard(0x5311)) or (e:GetHandler():IsSummonType(TYPE_PENDULUM)) end function cm.damop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CHANGE_DAMAGE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetValue(0) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local e2=e1:Clone() e2:SetCode(EFFECT_NO_EFFECT_DAMAGE) e2:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e2,tp) end