name: Moon
card_text: Activate this card by targeting 1 WIND Xyz Monster you control that has no Xyz Materials. While that monster is on the field, negate the effects of all face-up monsters on the field. When that monster leaves the field, destroy this card. During the End Phase of the turn this card was activated: Attach this card to that monster as an Xyz Material.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--disable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.disable)
  	e2:SetCondition(s.discon)
  	e2:SetCode(EFFECT_DISABLE)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EVENT_LEAVE_FIELD)
  	e3:SetCondition(s.descon)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:GetOverlayCount() == 0 and c:IsAttribute(ATTRIBUTE_WIND)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
  		c:SetCardTarget(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetRange(LOCATION_SZONE)
  		e1:SetCountLimit(1)
  		e1:SetOperation(s.matop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.disable(e, c)
  	return c:IsType(TYPE_EFFECT) or bit.band(c:GetOriginalType(), TYPE_EFFECT) == TYPE_EFFECT
  end
  function s.discon(e)
  	return e:GetHandler():GetFirstCardTarget() ~= nil
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetFirstCardTarget()
  	return tc and eg:IsContains(tc)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  function s.matop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if tc then
  		Duel.Overlay(tc, Group.FromCards(c))
  	end
  end
  
  
source_text: Moon
  Activate this card by targeting 1 WIND Xyz Monster you control that has no Xyz Materials. While that monster is on the field, negate the effects of all face-up monsters on the field. When that monster leaves the field, destroy this card. During the End Phase of the turn this card was activated: Attach this card to that monster as an Xyz Material.
target_text: -- Moon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--disable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.disable)
  	e2:SetCondition(s.discon)
  	e2:SetCode(EFFECT_DISABLE)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EVENT_LEAVE_FIELD)
  	e3:SetCondition(s.descon)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:GetOverlayCount() == 0 and c:IsAttribute(ATTRIBUTE_WIND)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
  		c:SetCardTarget(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetRange(LOCATION_SZONE)
  		e1:SetCountLimit(1)
  		e1:SetOperation(s.matop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.disable(e, c)
  	return c:IsType(TYPE_EFFECT) or bit.band(c:GetOriginalType(), TYPE_EFFECT) == TYPE_EFFECT
  end
  function s.discon(e)
  	return e:GetHandler():GetFirstCardTarget() ~= nil
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetFirstCardTarget()
  	return tc and eg:IsContains(tc)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  function s.matop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if tc then
  		Duel.Overlay(tc, Group.FromCards(c))
  	end
  end
  
  