name: Unified
card_text: Discard 1 monster, then target 1 face-up monster on the field; its ATK and DEF becomes the discarded monster's ATK and DEF, until the end of this turn. Monsters you control cannot attack directly during the turn you activate this card.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetCondition(aux.dscon)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_ATTACK_ANNOUNCE)
  		ge1:SetOperation(s.check)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  function s.check(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	if Duel.GetAttackTarget() == nil then
  		Duel.RegisterFlagEffect(tc:GetControler(), id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsDiscardable() and c:GetAttack() >= 0 and c:GetDefense() >= 0 and Duel.IsExistingTarget(s.tgfilter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, nil, c)
  end
  function s.tgfilter(c, dc)
  	return c:IsFaceup() and (not c:IsAttack(dc:GetAttack()) or not c:IsDefense(dc:GetDefense()))
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() and s.tgfilter(chkc, e:GetLabelObject())
  	end
  	if chk == 0 then
  		if e:GetLabel() ~= 1 then
  			return false
  		end
  		e:SetLabel(0)
  		return Duel.GetFlagEffect(tp, id) == 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST + REASON_DISCARD)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil, g:GetFirst())
  	e:SetLabelObject(g:GetFirst())
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_OATH + EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local cc = e:GetLabelObject()
  	local atk = cc:GetAttack()
  	local def = cc:GetDefense()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_SET_DEFENSE_FINAL)
  		e2:SetValue(def)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e2)
  	end
  end
  
  
source_text: Unified
  Discard 1 monster, then target 1 face-up monster on the field; its ATK and DEF becomes the discarded monster's ATK and DEF, until the end of this turn. Monsters you control cannot attack directly during the turn you activate this card.
target_text: -- Unified
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetCondition(aux.dscon)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_ATTACK_ANNOUNCE)
  		ge1:SetOperation(s.check)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  function s.check(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	if Duel.GetAttackTarget() == nil then
  		Duel.RegisterFlagEffect(tc:GetControler(), id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsDiscardable() and c:GetAttack() >= 0 and c:GetDefense() >= 0 and Duel.IsExistingTarget(s.tgfilter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, nil, c)
  end
  function s.tgfilter(c, dc)
  	return c:IsFaceup() and (not c:IsAttack(dc:GetAttack()) or not c:IsDefense(dc:GetDefense()))
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() and s.tgfilter(chkc, e:GetLabelObject())
  	end
  	if chk == 0 then
  		if e:GetLabel() ~= 1 then
  			return false
  		end
  		e:SetLabel(0)
  		return Duel.GetFlagEffect(tp, id) == 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST + REASON_DISCARD)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil, g:GetFirst())
  	e:SetLabelObject(g:GetFirst())
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_OATH + EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local cc = e:GetLabelObject()
  	local atk = cc:GetAttack()
  	local def = cc:GetDefense()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_SET_DEFENSE_FINAL)
  		e2:SetValue(def)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e2)
  	end
  end
  
  