name: Doom
card_text: If "Umi" is on the field (Quick Effect): You can target 1 WATER monster you control, except "Doom Kraken", and 1 monster your opponent controls; Special Summon this card from your hand, and if you do, return that monster you control to the hand, and if you do that, destroy that opponent's monster. When an opponent's monster declares an attack: You can return this card to the hand, and if you do, negate that attack. You can only use each effect of "Doom Kraken" once per turn.
external_ids: local CARD_ID_0 = 22702055 --Umi
  
lua: local CARD_ID_0 = 22702055 --Umi
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--SpecialSummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOHAND + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--NegateAttack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsEnvironment(CARD_ID_0)
  end
  function s.thfilter(c)
  	return c:IsFaceup() and not c:IsCode(id) and c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToHand()
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_MZONE, 0, 1, nil)
  			and Duel.IsExistingTarget(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g1 = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	e:SetLabelObject(g1:GetFirst())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g2 = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g2, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local hc = e:GetLabelObject()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		local tc = g:GetFirst()
  		if tc == hc then
  			tc = g:GetNext()
  		end
  		if hc:IsRelateToEffect(e) and hc:IsControler(tp) and Duel.SendtoHand(hc, nil, REASON_EFFECT) ~= 0 and hc:IsLocation(LOCATION_HAND) and tc:IsRelateToEffect(e) and tc:IsControler(1 - tp) then
  			Duel.Destroy(tc, REASON_EFFECT)
  		end
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():IsControler(1 - tp)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToHand()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, e:GetHandler(), 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SendtoHand(c, nil, REASON_EFFECT) > 0 and c:IsLocation(LOCATION_HAND) then
  		Duel.NegateAttack()
  	end
  end
  
  
source_text: Doom
  If "Umi" is on the field (Quick Effect): You can target 1 WATER monster you control, except "Doom Kraken", and 1 monster your opponent controls; Special Summon this card from your hand, and if you do, return that monster you control to the hand, and if you do that, destroy that opponent's monster. When an opponent's monster declares an attack: You can return this card to the hand, and if you do, negate that attack. You can only use each effect of "Doom Kraken" once per turn.
target_text: -- Doom
  local CARD_ID_0 = 22702055 --Umi
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--SpecialSummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOHAND + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--NegateAttack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsEnvironment(CARD_ID_0)
  end
  function s.thfilter(c)
  	return c:IsFaceup() and not c:IsCode(id) and c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToHand()
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_MZONE, 0, 1, nil)
  			and Duel.IsExistingTarget(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g1 = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	e:SetLabelObject(g1:GetFirst())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g2 = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g2, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local hc = e:GetLabelObject()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		local tc = g:GetFirst()
  		if tc == hc then
  			tc = g:GetNext()
  		end
  		if hc:IsRelateToEffect(e) and hc:IsControler(tp) and Duel.SendtoHand(hc, nil, REASON_EFFECT) ~= 0 and hc:IsLocation(LOCATION_HAND) and tc:IsRelateToEffect(e) and tc:IsControler(1 - tp) then
  			Duel.Destroy(tc, REASON_EFFECT)
  		end
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():IsControler(1 - tp)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToHand()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, e:GetHandler(), 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SendtoHand(c, nil, REASON_EFFECT) > 0 and c:IsLocation(LOCATION_HAND) then
  		Duel.NegateAttack()
  	end
  end
  
  