name: Jurassic
card_text: If you control 2 or more Dinosaur monsters and your LP is lower than your opponent's: Destroy as many monsters on the field as possible, and if you do, take 1000 damage for each monster destroyed, then inflict damage to your opponent, equal to the damage you took. Until the end of the next turn after this card is activated, neither player can Normal or Special Summon.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsRace, tp, LOCATION_MZONE, 0, 2, nil, RACE_DINOSAUR) and Duel.GetLP(tp) < Duel.GetLP(1 - tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, LOCATION_MZONE) > 0
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, LOCATION_MZONE)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, PLAYER_ALL, g:GetCount() * 1000)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, LOCATION_MZONE)
  	local ct = Duel.Destroy(g, REASON_EFFECT)
  	if ct > 0 then
  		local val = Duel.Damage(tp, ct * 1000, REASON_EFFECT)
  		if val > 0 and Duel.GetLP(tp) > 0 then
  			Duel.BreakEffect()
  			Duel.Damage(1 - tp, val, REASON_EFFECT)
  		end
  	end
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_CANNOT_SUMMON)
  		e1:SetTargetRange(1, 1)
  		e1:SetReset(RESET_PHASE + PHASE_END, 2)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  
  
source_text: Jurassic
  If you control 2 or more Dinosaur monsters and your LP is lower than your opponent's: Destroy as many monsters on the field as possible, and if you do, take 1000 damage for each monster destroyed, then inflict damage to your opponent, equal to the damage you took. Until the end of the next turn after this card is activated, neither player can Normal or Special Summon.
target_text: -- Jurassic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsRace, tp, LOCATION_MZONE, 0, 2, nil, RACE_DINOSAUR) and Duel.GetLP(tp) < Duel.GetLP(1 - tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, LOCATION_MZONE) > 0
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, LOCATION_MZONE)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, PLAYER_ALL, g:GetCount() * 1000)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, LOCATION_MZONE)
  	local ct = Duel.Destroy(g, REASON_EFFECT)
  	if ct > 0 then
  		local val = Duel.Damage(tp, ct * 1000, REASON_EFFECT)
  		if val > 0 and Duel.GetLP(tp) > 0 then
  			Duel.BreakEffect()
  			Duel.Damage(1 - tp, val, REASON_EFFECT)
  		end
  	end
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_CANNOT_SUMMON)
  		e1:SetTargetRange(1, 1)
  		e1:SetReset(RESET_PHASE + PHASE_END, 2)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  
  