name: Puzzlomino,
card_text: 2 monsters with different Levels
  If a monster is Special Summoned face-up to a zone this card points to while you control this monster (except during the Damage Step): You can declare a Level from 1 to 8; that monster becomes that Level until the end of the turn. You can target 2 monsters with the same Level (1 from each field); destroy them. You can only use each effect of "Puzzlomino, the Drop-n-Deleter" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, s.mfilter, 2, 2, s.lcheck)
  	c:EnableReviveLimit()
  	--level
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.lvcon)
  	e1:SetTarget(s.lvtg)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.mfilter(c)
  	return c:IsLevelAbove(0)
  end
  function s.lcheck(g, lc)
  	return g:GetClassCount(Card.GetLevel) == g:GetCount()
  end
  function s.cfilter(c, lg)
  	return c:IsFaceup() and c:IsLevelAbove(0) and lg:IsContains(c)
  end
  function s.lvcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return not eg:IsContains(c) and eg:IsExists(s.cfilter, 1, nil, c:GetLinkedGroup())
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c = e:GetHandler()
  	local g = eg:Filter(s.cfilter, nil, c:GetLinkedGroup())
  	g:KeepAlive()
  	local ct = {}
  	for i = 1, 8 do
  		if not g:IsExists(Card.IsLevel, 1, nil, i) then
  			table.insert(ct, i)
  		end
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINGMSG_LVRANK)
  	local lv = Duel.AnnounceNumber(tp, table.unpack(ct))
  	e:SetLabel(lv)
  	e:SetLabelObject(g)
  end
  function s.efilter(c, lv)
  	return c:IsFaceup() and c:IsLevelAbove(0) and not c:IsLevel(lv)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local lv = e:GetLabel()
  	local g = e:GetLabelObject()
  	local tg = g:Filter(s.efilter, nil, lv)
  	local tc = tg:GetFirst()
  	if #g > 2 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  		tc = tg:Select(tp, 1, 1, nil):GetFirst()
  	end
  	g:DeleteGroup()
  	if tc then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(lv)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.tgfilter1(c, e, tp)
  	return c:IsFaceup() and c:IsLevelAbove(0) and Duel.IsExistingMatchingCard(s.tgfilter2, tp, 0, LOCATION_MZONE, 1, nil, e, c:GetLevel())
  end
  function s.tgfilter2(c, e, lv)
  	return c:IsFaceup() and c:IsLevelAbove(0) and c:IsLevel(lv) and c:IsCanBeEffectTarget(e)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter1, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g1 = Duel.SelectTarget(tp, s.tgfilter1, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g2 = Duel.SelectTarget(tp, s.tgfilter2, tp, 0, LOCATION_MZONE, 1, 1, nil, e, g1:GetFirst():GetLevel())
  	g1:Merge(g2)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g1, 2, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tg = g:Filter(Card.IsRelateToEffect, nil, e)
  	if tg:GetCount() > 0 then
  		Duel.Destroy(tg, REASON_EFFECT)
  	end
  end
  
  
source_text: Puzzlomino,
  2 monsters with different Levels
  If a monster is Special Summoned face-up to a zone this card points to while you control this monster (except during the Damage Step): You can declare a Level from 1 to 8; that monster becomes that Level until the end of the turn. You can target 2 monsters with the same Level (1 from each field); destroy them. You can only use each effect of "Puzzlomino, the Drop-n-Deleter" once per turn.
target_text: -- Puzzlomino,
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, s.mfilter, 2, 2, s.lcheck)
  	c:EnableReviveLimit()
  	--level
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.lvcon)
  	e1:SetTarget(s.lvtg)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.mfilter(c)
  	return c:IsLevelAbove(0)
  end
  function s.lcheck(g, lc)
  	return g:GetClassCount(Card.GetLevel) == g:GetCount()
  end
  function s.cfilter(c, lg)
  	return c:IsFaceup() and c:IsLevelAbove(0) and lg:IsContains(c)
  end
  function s.lvcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return not eg:IsContains(c) and eg:IsExists(s.cfilter, 1, nil, c:GetLinkedGroup())
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c = e:GetHandler()
  	local g = eg:Filter(s.cfilter, nil, c:GetLinkedGroup())
  	g:KeepAlive()
  	local ct = {}
  	for i = 1, 8 do
  		if not g:IsExists(Card.IsLevel, 1, nil, i) then
  			table.insert(ct, i)
  		end
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINGMSG_LVRANK)
  	local lv = Duel.AnnounceNumber(tp, table.unpack(ct))
  	e:SetLabel(lv)
  	e:SetLabelObject(g)
  end
  function s.efilter(c, lv)
  	return c:IsFaceup() and c:IsLevelAbove(0) and not c:IsLevel(lv)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local lv = e:GetLabel()
  	local g = e:GetLabelObject()
  	local tg = g:Filter(s.efilter, nil, lv)
  	local tc = tg:GetFirst()
  	if #g > 2 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  		tc = tg:Select(tp, 1, 1, nil):GetFirst()
  	end
  	g:DeleteGroup()
  	if tc then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(lv)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.tgfilter1(c, e, tp)
  	return c:IsFaceup() and c:IsLevelAbove(0) and Duel.IsExistingMatchingCard(s.tgfilter2, tp, 0, LOCATION_MZONE, 1, nil, e, c:GetLevel())
  end
  function s.tgfilter2(c, e, lv)
  	return c:IsFaceup() and c:IsLevelAbove(0) and c:IsLevel(lv) and c:IsCanBeEffectTarget(e)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter1, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g1 = Duel.SelectTarget(tp, s.tgfilter1, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g2 = Duel.SelectTarget(tp, s.tgfilter2, tp, 0, LOCATION_MZONE, 1, 1, nil, e, g1:GetFirst():GetLevel())
  	g1:Merge(g2)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g1, 2, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tg = g:Filter(Card.IsRelateToEffect, nil, e)
  	if tg:GetCount() > 0 then
  		Duel.Destroy(tg, REASON_EFFECT)
  	end
  end
  
  