name: Gouki
card_text: Target 2 "Gouki" monsters in your GY with different Levels; Special Summon them in Defense Position. You can only activate 1 "Gouki Re-Match" per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xfc --Gouki
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xfc --Gouki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:GetLevel() > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE) and c:IsCanBeEffectTarget(e)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil, e, tp)
  	if chk == 0 then
  		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 1 and g:GetClassCount(Card.GetLevel) >= 2
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g1 = g:SelectSubGroup(tp, aux.dlvcheck, false, 2, 2)
  	Duel.SetTargetCard(g1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g1, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	if sg:GetCount() > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if sg:GetCount() > ft then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		sg = sg:Select(tp, ft, ft, nil)
  	end
  	Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  end
  
  
source_text: Gouki
  Target 2 "Gouki" monsters in your GY with different Levels; Special Summon them in Defense Position. You can only activate 1 "Gouki Re-Match" per turn.
target_text: -- Gouki
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xfc --Gouki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:GetLevel() > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE) and c:IsCanBeEffectTarget(e)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil, e, tp)
  	if chk == 0 then
  		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 1 and g:GetClassCount(Card.GetLevel) >= 2
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g1 = g:SelectSubGroup(tp, aux.dlvcheck, false, 2, 2)
  	Duel.SetTargetCard(g1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g1, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	if sg:GetCount() > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if sg:GetCount() > ft then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		sg = sg:Select(tp, ft, ft, nil)
  	end
  	Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  end
  
  