name: Buzzsaw
card_text: You can target 1 WATER monster you control; Special Summon from your Deck in Defense Position, 1 Fish monster with the same Level as that monster, but with a different name, and if you do, it cannot activate its effects this turn, also, you cannot Special Summon from the Extra Deck for the rest of this turn, except Xyz Monsters. You can only use this effect of "Buzzsaw Shark" once per turn. If this card is used for the Xyz Summon of a WATER monster, it can be treated as a Level 3 or 5 monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--xyzlv
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_XYZ_LEVEL)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(s.xyzlv)
  	e2:SetLabel(3)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetLabel(5)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c, e, tp)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_WATER) and c:IsLevelAbove(1) and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp, c:GetLevel(), c:GetCode())
  end
  function s.spfilter(c, e, tp, lv, code)
  	return c:IsRace(RACE_FISH) and c:IsLevel(lv) and not c:IsCode(code) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local lv = tc:GetLevel()
  		local code = tc:GetCode()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, lv, code)
  		local tc = g:GetFirst()
  		if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_CANNOT_TRIGGER)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			Duel.SpecialSummonComplete()
  		end
  	end
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 0)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	e2:SetTarget(s.splimit)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.splimit(e, c)
  	return not c:IsType(TYPE_XYZ) and c:IsLocation(LOCATION_EXTRA)
  end
  function s.xyzlv(e, c, rc)
  	if rc:IsAttribute(ATTRIBUTE_WATER) then
  		return c:GetLevel() + 0x10000 * e:GetLabel()
  	else
  		return c:GetLevel()
  	end
  end
  
  
source_text: Buzzsaw
  You can target 1 WATER monster you control; Special Summon from your Deck in Defense Position, 1 Fish monster with the same Level as that monster, but with a different name, and if you do, it cannot activate its effects this turn, also, you cannot Special Summon from the Extra Deck for the rest of this turn, except Xyz Monsters. You can only use this effect of "Buzzsaw Shark" once per turn. If this card is used for the Xyz Summon of a WATER monster, it can be treated as a Level 3 or 5 monster.
target_text: -- Buzzsaw
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--xyzlv
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_XYZ_LEVEL)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(s.xyzlv)
  	e2:SetLabel(3)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetLabel(5)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c, e, tp)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_WATER) and c:IsLevelAbove(1) and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp, c:GetLevel(), c:GetCode())
  end
  function s.spfilter(c, e, tp, lv, code)
  	return c:IsRace(RACE_FISH) and c:IsLevel(lv) and not c:IsCode(code) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local lv = tc:GetLevel()
  		local code = tc:GetCode()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, lv, code)
  		local tc = g:GetFirst()
  		if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_CANNOT_TRIGGER)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			Duel.SpecialSummonComplete()
  		end
  	end
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 0)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	e2:SetTarget(s.splimit)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.splimit(e, c)
  	return not c:IsType(TYPE_XYZ) and c:IsLocation(LOCATION_EXTRA)
  end
  function s.xyzlv(e, c, rc)
  	if rc:IsAttribute(ATTRIBUTE_WATER) then
  		return c:GetLevel() + 0x10000 * e:GetLabel()
  	else
  		return c:GetLevel()
  	end
  end
  
  