local m=31420014 local cm=_G["c"..m] cm.name="Disorder 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_REMOVE) e2:SetDescription(aux.Stringid(31420006,0)) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCountLimit(1,31420006) e2:SetRange(LOCATION_MZONE) e2:SetCode(EVENT_TO_HAND) e2:SetCondition(cm.bancon) e2:SetCost(cm.bancost) e2:SetOperation(cm.banop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_SPSUMMON_PROC) e3:SetProperty(EFFECT_FLAG_UNCOPYABLE) e3:SetRange(LOCATION_HAND) e3:SetCondition(cm.hspcon) e3:SetValue(1) c:RegisterEffect(e3) local e4=Effect.CreateEffect(c) e4:SetProperty(EFFECT_FLAG_UNCOPYABLE) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetCondition(cm.hspcon2) e4:SetOperation(cm.hspop) c:RegisterEffect(e4) 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.cfilter(c) return c:IsSetCard(0x5311) and c:IsLocation(LOCATION_HAND) and c:IsPreviousLocation(LOCATION_MZONE) end function cm.bancon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cm.cfilter,1,nil) and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_ONFIELD+LOCATION_GRAVE,LOCATION_ONFIELD+LOCATION_GRAVE,1,nil,tp) end function cm.bancost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToHandAsCost() end Duel.SendtoHand(e:GetHandler(),nil,REASON_COST) end function cm.banfilter(c) return c:IsSetCard(0x5311) and c:IsType(TYPE_MONSTER) end function cm.banop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetFieldGroup(tp,LOCATION_HAND,0) Duel.ConfirmCards(1-tp,g) Duel.BreakEffect() local num=g:Filter(cm.banfilter,nil):GetClassCount(Card.GetCode) local sg=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(Card.IsAbleToRemove),tp,LOCATION_ONFIELD+LOCATION_GRAVE,LOCATION_ONFIELD+LOCATION_GRAVE,1,num,nil,tp) if sg then Duel.Remove(sg,POS_FACEUP,REASON_EFFECT) end 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