name: Amazement
card_text: Target 1 monster your opponent controls equipped with your "Attraction" Trap(s); equip this card to it. While this card is equipped to a monster, take control of the equipped monster. While you control the equipped monster, it gains 500 ATK, you cannot activate its effects, also it is treated as an "Amazement" monster. You can only activate 1 "Amazement Family Faces" per turn.
external_ids: local SETCARD_ID_0 = 0x15c --Attraction
  
lua: local SETCARD_ID_0 = 0x15c --Attraction
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_EQUIP + CATEGORY_CONTROL)
  	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:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--control
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetCode(EFFECT_SET_CONTROL)
  	e2:SetValue(s.cval)
  	c:RegisterEffect(e2)
  	--atk
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_EQUIP)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(500)
  	e3:SetCondition(s.con)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_CANNOT_TRIGGER)
  	c:RegisterEffect(e4)
  	local e5 = e3:Clone()
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCode(EFFECT_ADD_SETCODE)
  	e5:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  	e5:SetValue(0x15b)
  	c:RegisterEffect(e5)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c = e:GetHandler()
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_REMAIN_FIELD)
  	e1:SetProperty(EFFECT_FLAG_OATH + EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_CHAIN)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_DISABLED)
  	e2:SetOperation(s.tgop)
  	e2:SetLabel(cid)
  	e2:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  	if cid ~= e:GetLabel() then
  		return
  	end
  	if e:GetOwner():IsRelateToChain(ev) then
  		e:GetOwner():CancelToGrave(false)
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_TRAP) and c:IsControler(tp)
  end
  function s.filter(c, tp)
  	return c:IsFaceup() and c:GetEquipGroup():IsExists(s.cfilter, 1, nil, tp) and c:IsControlerCanBeChanged()
  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(1 - tp) and s.filter(chkc, tp)
  	end
  	if chk == 0 then
  		return e:IsCostChecked() and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil, tp)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		if c:IsRelateToEffect(e) and not c:IsStatus(STATUS_LEAVE_CONFIRMED) then
  			Duel.Equip(tp, c, tc)
  			--Add Equip limit
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EQUIP_LIMIT)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e1:SetValue(s.eqlimit)
  			c:RegisterEffect(e1)
  		end
  	elseif c:IsRelateToEffect(e) and not c:IsStatus(STATUS_LEAVE_CONFIRMED) then
  		c:CancelToGrave(false)
  	end
  end
  function s.eqlimit(e, c)
  	local tp = e:GetHandlerPlayer()
  	return e:GetHandler():GetEquipTarget() == c or c:IsControler(1 - tp) and c:GetEquipGroup():IsExists(s.cfilter, 1, nil, tp)
  end
  function s.cval(e, c)
  	return e:GetHandlerPlayer()
  end
  function s.con(e)
  	return e:GetHandler():GetEquipTarget():IsControler(e:GetHandlerPlayer())
  end
  
  
source_text: Amazement
  Target 1 monster your opponent controls equipped with your "Attraction" Trap(s); equip this card to it. While this card is equipped to a monster, take control of the equipped monster. While you control the equipped monster, it gains 500 ATK, you cannot activate its effects, also it is treated as an "Amazement" monster. You can only activate 1 "Amazement Family Faces" per turn.
target_text: -- Amazement
  local SETCARD_ID_0 = 0x15c --Attraction
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_EQUIP + CATEGORY_CONTROL)
  	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:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--control
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_EQUIP)
  	e2:SetCode(EFFECT_SET_CONTROL)
  	e2:SetValue(s.cval)
  	c:RegisterEffect(e2)
  	--atk
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_EQUIP)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(500)
  	e3:SetCondition(s.con)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_CANNOT_TRIGGER)
  	c:RegisterEffect(e4)
  	local e5 = e3:Clone()
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCode(EFFECT_ADD_SETCODE)
  	e5:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  	e5:SetValue(0x15b)
  	c:RegisterEffect(e5)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c = e:GetHandler()
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_REMAIN_FIELD)
  	e1:SetProperty(EFFECT_FLAG_OATH + EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_CHAIN)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_DISABLED)
  	e2:SetOperation(s.tgop)
  	e2:SetLabel(cid)
  	e2:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  	if cid ~= e:GetLabel() then
  		return
  	end
  	if e:GetOwner():IsRelateToChain(ev) then
  		e:GetOwner():CancelToGrave(false)
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_TRAP) and c:IsControler(tp)
  end
  function s.filter(c, tp)
  	return c:IsFaceup() and c:GetEquipGroup():IsExists(s.cfilter, 1, nil, tp) and c:IsControlerCanBeChanged()
  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(1 - tp) and s.filter(chkc, tp)
  	end
  	if chk == 0 then
  		return e:IsCostChecked() and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil, tp)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		if c:IsRelateToEffect(e) and not c:IsStatus(STATUS_LEAVE_CONFIRMED) then
  			Duel.Equip(tp, c, tc)
  			--Add Equip limit
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EQUIP_LIMIT)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e1:SetValue(s.eqlimit)
  			c:RegisterEffect(e1)
  		end
  	elseif c:IsRelateToEffect(e) and not c:IsStatus(STATUS_LEAVE_CONFIRMED) then
  		c:CancelToGrave(false)
  	end
  end
  function s.eqlimit(e, c)
  	local tp = e:GetHandlerPlayer()
  	return e:GetHandler():GetEquipTarget() == c or c:IsControler(1 - tp) and c:GetEquipGroup():IsExists(s.cfilter, 1, nil, tp)
  end
  function s.cval(e, c)
  	return e:GetHandlerPlayer()
  end
  function s.con(e)
  	return e:GetHandler():GetEquipTarget():IsControler(e:GetHandlerPlayer())
  end
  
  