--魔界台本「火竜の住処」 function c50179591.initial_effect(c) aux.AddSetNameMonsterList(c,0x10ec) --activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(c50179591.target) e1:SetOperation(c50179591.operation) c:RegisterEffect(e1) --destroyed local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(50179591,1)) e2:SetCategory(CATEGORY_REMOVE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_DESTROYED) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCountLimit(1,50179591) e2:SetCondition(c50179591.rmcon2) e2:SetTarget(c50179591.rmtg2) e2:SetOperation(c50179591.rmop2) c:RegisterEffect(e2) end function c50179591.filter(c) return c:IsFaceup() and c:IsSetCard(0x10ec) end function c50179591.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c50179591.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c50179591.filter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c50179591.filter,tp,LOCATION_MZONE,0,1,1,nil) end function c50179591.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then tc:RegisterFlagEffect(50179591,RESET_EVENT+0x1220000+RESET_PHASE+PHASE_END,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(50179591,0)) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_BATTLE_DESTROYING) e1:SetLabelObject(tc) e1:SetCondition(c50179591.rmcon1) e1:SetOperation(c50179591.rmop1) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end end function c50179591.rmcon1(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() return eg:IsContains(tc) and tc:GetFlagEffect(50179591)~=0 end function c50179591.rmop1(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_EXTRA,nil) if g:GetCount()<3 then return end Duel.Hint(HINT_CARD,0,50179591) Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_REMOVE) local mg=g:Select(1-tp,3,3,nil) if mg:GetCount()>0 then Duel.Remove(mg,POS_FACEUP,REASON_EFFECT) end end function c50179591.rmcon2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return rp==1-tp and c:IsReason(REASON_EFFECT) and c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEDOWN) and Duel.IsExistingMatchingCard(c50179591.filter,tp,LOCATION_EXTRA,0,1,nil) end function c50179591.rmtg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_EXTRA,1,nil) end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,0,0) end function c50179591.rmop2(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetFieldGroup(tp,0,LOCATION_EXTRA) if g:GetCount()==0 then return end Duel.ConfirmCards(tp,g) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local mg=g:FilterSelect(tp,Card.IsAbleToRemove,1,1,nil) if mg:GetCount()>0 then Duel.Remove(mg,POS_FACEUP,REASON_EFFECT) end Duel.ShuffleExtra(1-tp) end