name: Onomatopickup
card_text: When this card is activated: You can add 1 "Onomat" card from your Deck to your hand, except "Onomatopickup". You can target 1 "Zubaba", "Gagaga", "Gogogo", or "Dododo" monster you control; all monsters you currently control become that monster's Level until the end of this turn (even if this card leaves the field). You can only use this effect of "Onomatopickup" once per turn. You can only activate 1 "Onomatopickup" per turn.
external_ids: local SETCARD_ID_0 = 0x8f --Zubaba
  local SETCARD_ID_1 = 0x13a --Onomat
  
lua: local SETCARD_ID_0 = 0x8f --Zubaba
  local SETCARD_ID_1 = 0x13a --Onomat
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--level
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsAbleToHand() and c:IsSetCard(SETCARD_ID_1) and not c:IsCode(id)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.filter1(c)
  	return c:IsFaceup() and c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_1, 0x54, 0x59, 0x82)
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:GetLevel() > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter1(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter1, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_MZONE, 0, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter1, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local g = Duel.GetMatchingGroup(s.filter2, tp, LOCATION_MZONE, 0, tc)
  		local lc = g:GetFirst()
  		local lv = tc:GetLevel()
  		while lc do
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_CHANGE_LEVEL)
  			e2:SetValue(lv)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			lc:RegisterEffect(e2)
  			lc = g:GetNext()
  		end
  	end
  end
  
  
source_text: Onomatopickup
  When this card is activated: You can add 1 "Onomat" card from your Deck to your hand, except "Onomatopickup". You can target 1 "Zubaba", "Gagaga", "Gogogo", or "Dododo" monster you control; all monsters you currently control become that monster's Level until the end of this turn (even if this card leaves the field). You can only use this effect of "Onomatopickup" once per turn. You can only activate 1 "Onomatopickup" per turn.
target_text: -- Onomatopickup
  local SETCARD_ID_0 = 0x8f --Zubaba
  local SETCARD_ID_1 = 0x13a --Onomat
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--level
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsAbleToHand() and c:IsSetCard(SETCARD_ID_1) and not c:IsCode(id)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.filter1(c)
  	return c:IsFaceup() and c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_1, 0x54, 0x59, 0x82)
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:GetLevel() > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter1(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter1, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_MZONE, 0, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter1, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local g = Duel.GetMatchingGroup(s.filter2, tp, LOCATION_MZONE, 0, tc)
  		local lc = g:GetFirst()
  		local lv = tc:GetLevel()
  		while lc do
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_CHANGE_LEVEL)
  			e2:SetValue(lv)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			lc:RegisterEffect(e2)
  			lc = g:GetNext()
  		end
  	end
  end
  
  