name: Summon
card_text: Pay 1000 LP; roll a six-sided die and apply the result.
  ● 1 or 2: Immediately after this effect resolves, you can Normal Summon 1 monster.
  ● 3 or 4: You can Special Summon 1 monster from your GY.
  ● 5 or 6: You can Special Summon 1 Level 5 or higher monster from your hand.
  You can only activate 1 "Summon Dice" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DICE + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.filter1(c)
  	return c:IsSummonable(true, nil)
  end
  function s.filter2(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.filter3(c, e, tp)
  	return c:IsLevelAbove(5) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.filter(c, e, tp)
  	return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  		or Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  		or Duel.IsExistingMatchingCard(s.filter3, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DICE, nil, 0, tp, 1)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.TossDice(tp, 1)
  	if d == 1 or d == 2 then
  		local g = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_HAND + LOCATION_MZONE, 0, nil)
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.Summon(tp, tc, true, nil)
  		end
  	elseif d == 3 or d == 4 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter2), tp, LOCATION_GRAVE, 0, nil, e, tp)
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	elseif d == 7 then
  		return
  	else
  		local g = Duel.GetMatchingGroup(s.filter3, tp, LOCATION_HAND, 0, nil, e, tp)
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Summon
  Pay 1000 LP; roll a six-sided die and apply the result.
  ● 1 or 2: Immediately after this effect resolves, you can Normal Summon 1 monster.
  ● 3 or 4: You can Special Summon 1 monster from your GY.
  ● 5 or 6: You can Special Summon 1 Level 5 or higher monster from your hand.
  You can only activate 1 "Summon Dice" per turn.
target_text: -- Summon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DICE + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.filter1(c)
  	return c:IsSummonable(true, nil)
  end
  function s.filter2(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.filter3(c, e, tp)
  	return c:IsLevelAbove(5) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.filter(c, e, tp)
  	return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  		or Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  		or Duel.IsExistingMatchingCard(s.filter3, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DICE, nil, 0, tp, 1)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.TossDice(tp, 1)
  	if d == 1 or d == 2 then
  		local g = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_HAND + LOCATION_MZONE, 0, nil)
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.Summon(tp, tc, true, nil)
  		end
  	elseif d == 3 or d == 4 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter2), tp, LOCATION_GRAVE, 0, nil, e, tp)
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	elseif d == 7 then
  		return
  	else
  		local g = Duel.GetMatchingGroup(s.filter3, tp, LOCATION_HAND, 0, nil, e, tp)
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  