name: Dinowrestler
card_text: If your opponent controls more monsters than you do, you can Special Summon this card (from your hand). You can only Special Summon "Dinowrestler Pankratops" once per turn this way. (Quick Effect): You can Tribute 1 "Dinowrestler" monster, then target 1 card your opponent controls; destroy it. You can only use this effect of "Dinowrestler Pankratops" once per turn.
external_ids: local SETCARD_ID_0 = 0x11a --Dinowrestler
  
lua: local SETCARD_ID_0 = 0x11a --Dinowrestler
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCost(s.descost)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.GetFieldGroupCount(c:GetControler(), LOCATION_MZONE, 0) < Duel.GetFieldGroupCount(c:GetControler(), 0, LOCATION_MZONE)
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.desfilter(c, tc, ec)
  	return c:GetEquipTarget() ~= tc and c ~= ec
  end
  function s.costfilter(c, ec, tp)
  	return c:IsSetCard(SETCARD_ID_0) and Duel.IsExistingTarget(s.desfilter, tp, 0, LOCATION_ONFIELD, 1, c, c, ec)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(1 - tp)
  	end
  	if chk == 0 then
  		if e:GetLabel() == 1 then
  			e:SetLabel(0)
  			return Duel.CheckReleaseGroup(tp, s.costfilter, 1, nil, c, tp)
  		else
  			return Duel.IsExistingTarget(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil)
  		end
  	end
  	if e:GetLabel() == 1 then
  		e:SetLabel(0)
  		local sg = Duel.SelectReleaseGroup(tp, s.costfilter, 1, 1, nil, c, tp)
  		Duel.Release(sg, REASON_COST)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  
source_text: Dinowrestler
  If your opponent controls more monsters than you do, you can Special Summon this card (from your hand). You can only Special Summon "Dinowrestler Pankratops" once per turn this way. (Quick Effect): You can Tribute 1 "Dinowrestler" monster, then target 1 card your opponent controls; destroy it. You can only use this effect of "Dinowrestler Pankratops" once per turn.
target_text: -- Dinowrestler
  local SETCARD_ID_0 = 0x11a --Dinowrestler
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCost(s.descost)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.GetFieldGroupCount(c:GetControler(), LOCATION_MZONE, 0) < Duel.GetFieldGroupCount(c:GetControler(), 0, LOCATION_MZONE)
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.desfilter(c, tc, ec)
  	return c:GetEquipTarget() ~= tc and c ~= ec
  end
  function s.costfilter(c, ec, tp)
  	return c:IsSetCard(SETCARD_ID_0) and Duel.IsExistingTarget(s.desfilter, tp, 0, LOCATION_ONFIELD, 1, c, c, ec)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(1 - tp)
  	end
  	if chk == 0 then
  		if e:GetLabel() == 1 then
  			e:SetLabel(0)
  			return Duel.CheckReleaseGroup(tp, s.costfilter, 1, nil, c, tp)
  		else
  			return Duel.IsExistingTarget(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil)
  		end
  	end
  	if e:GetLabel() == 1 then
  		e:SetLabel(0)
  		local sg = Duel.SelectReleaseGroup(tp, s.costfilter, 1, 1, nil, c, tp)
  		Duel.Release(sg, REASON_COST)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  