name: Morphtronic
card_text: ● While in Attack Position: Once per turn, you can send 1 Equip Card equipped to this card to the Graveyard to inflict 500 damage to your opponent.
  ● While in Defense Position: Once per turn, you can equip 1 face-up Attack Position monster your opponent controls to this card as an Equip Card. (You can only equip 1 monster at a time to this card by this effect.)
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.cona)
  	e1:SetCost(s.costa)
  	e1:SetTarget(s.tga)
  	e1:SetOperation(s.opa)
  	c:RegisterEffect(e1)
  	--equip
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_EQUIP)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.cond)
  	e2:SetTarget(s.tgd)
  	e2:SetOperation(s.opd)
  	c:RegisterEffect(e2)
  end
  function s.cona(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsAttackPos()
  end
  function s.costa(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetEquipGroup():IsExists(Card.IsAbleToGraveAsCost, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = e:GetHandler():GetEquipGroup():FilterSelect(tp, Card.IsAbleToGraveAsCost, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.tga(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(500)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.opa(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  function s.cond(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsDefensePos() and not e:GetHandler():IsHasEffect(id)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsAttackPos() and c:IsAbleToChangeControler()
  end
  function s.tgd(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)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, g, 1, 0, 0)
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c and not c:IsDisabled()
  end
  function s.opd(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttackPos() then
  		if not Duel.Equip(tp, tc, c, false) then
  			return
  		end
  		--Add Equip limit
  		tc:CreateRelation(c, RESET_EVENT + RESETS_STANDARD)
  		e:SetLabelObject(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EQUIP_LIMIT)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.eqlimit)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_EQUIP)
  		e2:SetCode(id)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  	end
  end
  
  
source_text: Morphtronic
  ● While in Attack Position: Once per turn, you can send 1 Equip Card equipped to this card to the Graveyard to inflict 500 damage to your opponent.
  ● While in Defense Position: Once per turn, you can equip 1 face-up Attack Position monster your opponent controls to this card as an Equip Card. (You can only equip 1 monster at a time to this card by this effect.)
target_text: -- Morphtronic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.cona)
  	e1:SetCost(s.costa)
  	e1:SetTarget(s.tga)
  	e1:SetOperation(s.opa)
  	c:RegisterEffect(e1)
  	--equip
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_EQUIP)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.cond)
  	e2:SetTarget(s.tgd)
  	e2:SetOperation(s.opd)
  	c:RegisterEffect(e2)
  end
  function s.cona(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsAttackPos()
  end
  function s.costa(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetEquipGroup():IsExists(Card.IsAbleToGraveAsCost, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = e:GetHandler():GetEquipGroup():FilterSelect(tp, Card.IsAbleToGraveAsCost, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.tga(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(500)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.opa(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  function s.cond(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsDefensePos() and not e:GetHandler():IsHasEffect(id)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsAttackPos() and c:IsAbleToChangeControler()
  end
  function s.tgd(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)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, g, 1, 0, 0)
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c and not c:IsDisabled()
  end
  function s.opd(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttackPos() then
  		if not Duel.Equip(tp, tc, c, false) then
  			return
  		end
  		--Add Equip limit
  		tc:CreateRelation(c, RESET_EVENT + RESETS_STANDARD)
  		e:SetLabelObject(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EQUIP_LIMIT)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.eqlimit)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_EQUIP)
  		e2:SetCode(id)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  	end
  end
  
  