name: Tyrant
card_text: During your Battle Phase, if your opponent controls a monster after this card's first attack, this card can make a second attack. Negate any Trap effects that target this card on the field, and if you do, destroy that Trap. This card cannot be Special Summoned from the GY, unless you Tribute 1 Dragon monster.
lua: function s.initial_effect(c)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--disable effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--self destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_SELF_DESTROY)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e3:SetTarget(s.distg)
  	c:RegisterEffect(e3)
  	--multiatk
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_EXTRA_ATTACK)
  	e4:SetValue(1)
  	e4:SetCondition(s.atkcon)
  	c:RegisterEffect(e4)
  	--spsummon cost
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_SPSUMMON_COST)
  	e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_GRAVE)
  	e5:SetCost(s.spcost)
  	e5:SetOperation(s.spcop)
  	c:RegisterEffect(e5)
  end
  function s.distg(e, c)
  	if not c:IsType(TYPE_TRAP) or c:GetCardTargetCount() == 0 then
  		return false
  	end
  	return c:GetCardTarget():IsContains(e:GetHandler())
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if not re:IsActiveType(TYPE_TRAP) then
  		return
  	end
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return
  	end
  	if not e:GetHandler():IsRelateToEffect(re) then
  		return
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() == 0 then
  		return
  	end
  	if g:IsContains(e:GetHandler()) then
  		if Duel.NegateEffect(ev, true) and re:GetHandler():IsRelateToEffect(re) then
  			Duel.Destroy(re:GetHandler(), REASON_EFFECT)
  		end
  	end
  end
  function s.atkcon(e)
  	return Duel.GetFieldGroupCount(e:GetHandlerPlayer(), 0, LOCATION_MZONE) > 0
  end
  function s.spcost(e, c, tp)
  	return Duel.CheckReleaseGroupEx(tp, Card.IsRace, 1, REASON_ACTION, false, nil, RACE_DRAGON)
  end
  function s.spcop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.SelectReleaseGroupEx(tp, Card.IsRace, 1, 1, REASON_ACTION, false, nil, RACE_DRAGON)
  	Duel.Release(g, REASON_ACTION)
  end
  
  
source_text: Tyrant
  During your Battle Phase, if your opponent controls a monster after this card's first attack, this card can make a second attack. Negate any Trap effects that target this card on the field, and if you do, destroy that Trap. This card cannot be Special Summoned from the GY, unless you Tribute 1 Dragon monster.
target_text: -- Tyrant
  function s.initial_effect(c)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--disable effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--self destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_SELF_DESTROY)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e3:SetTarget(s.distg)
  	c:RegisterEffect(e3)
  	--multiatk
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_EXTRA_ATTACK)
  	e4:SetValue(1)
  	e4:SetCondition(s.atkcon)
  	c:RegisterEffect(e4)
  	--spsummon cost
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_SPSUMMON_COST)
  	e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_GRAVE)
  	e5:SetCost(s.spcost)
  	e5:SetOperation(s.spcop)
  	c:RegisterEffect(e5)
  end
  function s.distg(e, c)
  	if not c:IsType(TYPE_TRAP) or c:GetCardTargetCount() == 0 then
  		return false
  	end
  	return c:GetCardTarget():IsContains(e:GetHandler())
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if not re:IsActiveType(TYPE_TRAP) then
  		return
  	end
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return
  	end
  	if not e:GetHandler():IsRelateToEffect(re) then
  		return
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() == 0 then
  		return
  	end
  	if g:IsContains(e:GetHandler()) then
  		if Duel.NegateEffect(ev, true) and re:GetHandler():IsRelateToEffect(re) then
  			Duel.Destroy(re:GetHandler(), REASON_EFFECT)
  		end
  	end
  end
  function s.atkcon(e)
  	return Duel.GetFieldGroupCount(e:GetHandlerPlayer(), 0, LOCATION_MZONE) > 0
  end
  function s.spcost(e, c, tp)
  	return Duel.CheckReleaseGroupEx(tp, Card.IsRace, 1, REASON_ACTION, false, nil, RACE_DRAGON)
  end
  function s.spcop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.SelectReleaseGroupEx(tp, Card.IsRace, 1, 1, REASON_ACTION, false, nil, RACE_DRAGON)
  	Duel.Release(g, REASON_ACTION)
  end
  
  