name: Free-Range
card_text: During the Main Phase: Immediately after this effect resolves, Normal Summon/Set 1 monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	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)
  	local ph = Duel.GetCurrentPhase()
  	return ph == PHASE_MAIN1 or ph == PHASE_MAIN2
  end
  function s.filter(c)
  	return c:IsSummonable(true, nil) or c:IsMSetable(true, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		if tc:IsSummonable(true, nil) and (not tc:IsMSetable(true, nil) or Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) == POS_FACEUP_ATTACK) then
  			Duel.Summon(tp, tc, true, nil)
  		else
  			Duel.MSet(tp, tc, true, nil)
  		end
  	end
  end
  
  
source_text: Free-Range
  During the Main Phase: Immediately after this effect resolves, Normal Summon/Set 1 monster.
target_text: -- Free-Range
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	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)
  	local ph = Duel.GetCurrentPhase()
  	return ph == PHASE_MAIN1 or ph == PHASE_MAIN2
  end
  function s.filter(c)
  	return c:IsSummonable(true, nil) or c:IsMSetable(true, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		if tc:IsSummonable(true, nil) and (not tc:IsMSetable(true, nil) or Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) == POS_FACEUP_ATTACK) then
  			Duel.Summon(tp, tc, true, nil)
  		else
  			Duel.MSet(tp, tc, true, nil)
  		end
  	end
  end
  
  