name: Ice
card_text: Target 1 monster in your opponent's GY; Special Summon it to your field, but its effects are negated, then, you can banish 1 monster from both players' fields that have the same Type as each other. You can only activate 1 "Ice Dragon's Prison" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1 - tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, 0, LOCATION_GRAVE, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, 0, LOCATION_GRAVE, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 0, PLAYER_ALL, LOCATION_MZONE)
  end
  function s.rmfilter(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.fselect(g)
  	return g:GetClassCount(Card.GetControler) == g:GetCount() and g:IsExists(s.fcheck, 1, nil, g)
  end
  function s.fcheck(c, g)
  	return g:IsExists(Card.IsRace, 1, c, c:GetRace())
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	local res = false
  	if tc:IsRelateToEffect(e) then
  		res = Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		if res then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetValue(RESET_TURN_SET)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e2)
  		end
  		Duel.SpecialSummonComplete()
  	end
  	if res then
  		local g = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  		if g:CheckSubGroup(s.fselect, 2, 2) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  			local sg = g:SelectSubGroup(tp, s.fselect, false, 2, 2)
  			Duel.HintSelection(sg)
  			Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Ice
  Target 1 monster in your opponent's GY; Special Summon it to your field, but its effects are negated, then, you can banish 1 monster from both players' fields that have the same Type as each other. You can only activate 1 "Ice Dragon's Prison" per turn.
target_text: -- Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1 - tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, 0, LOCATION_GRAVE, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, 0, LOCATION_GRAVE, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 0, PLAYER_ALL, LOCATION_MZONE)
  end
  function s.rmfilter(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.fselect(g)
  	return g:GetClassCount(Card.GetControler) == g:GetCount() and g:IsExists(s.fcheck, 1, nil, g)
  end
  function s.fcheck(c, g)
  	return g:IsExists(Card.IsRace, 1, c, c:GetRace())
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	local res = false
  	if tc:IsRelateToEffect(e) then
  		res = Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		if res then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetValue(RESET_TURN_SET)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e2)
  		end
  		Duel.SpecialSummonComplete()
  	end
  	if res then
  		local g = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  		if g:CheckSubGroup(s.fselect, 2, 2) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  			local sg = g:SelectSubGroup(tp, s.fselect, false, 2, 2)
  			Duel.HintSelection(sg)
  			Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  		end
  	end
  end
  
  