name: Dragunity
card_text: If this face-up card is destroyed while in a Monster Zone, you can equip it to 1 Winged Beast "Dragunity" monster you control, instead of sending it to the GY.
external_ids: local SETCARD_ID_0 = 0x29 --Dragunity
  
lua: local SETCARD_ID_0 = 0x29 --Dragunity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--send replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_TO_GRAVE_REDIRECT_CB)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCondition(s.repcon)
  	e1:SetOperation(s.repop)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsRace(RACE_WINDBEAST)
  end
  function s.repcon(e)
  	local c = e:GetHandler()
  	local tp = c:GetControler()
  	return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_DESTROY) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
  	local tc = g:GetFirst()
  	if Duel.Equip(tp, c, tc, false) then
  		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)
  		e1:SetLabelObject(tc)
  		c:RegisterEffect(e1)
  	end
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  
  
source_text: Dragunity
  If this face-up card is destroyed while in a Monster Zone, you can equip it to 1 Winged Beast "Dragunity" monster you control, instead of sending it to the GY.
target_text: -- Dragunity
  local SETCARD_ID_0 = 0x29 --Dragunity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--send replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_TO_GRAVE_REDIRECT_CB)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCondition(s.repcon)
  	e1:SetOperation(s.repop)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsRace(RACE_WINDBEAST)
  end
  function s.repcon(e)
  	local c = e:GetHandler()
  	local tp = c:GetControler()
  	return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_DESTROY) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
  	local tc = g:GetFirst()
  	if Duel.Equip(tp, c, tc, false) then
  		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)
  		e1:SetLabelObject(tc)
  		c:RegisterEffect(e1)
  	end
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  
  