name: Flying
card_text: Once per opponent's turn, if this card would be destroyed by their card effect, it is not destroyed. Once per turn, during their End Phase, if that effect was applied this turn: Apply the following effect.
  ��During your next turn, if this card inflicts battle damage to your opponent by a direct attack, you win the Duel.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.indcon)
  	e1:SetValue(s.valcon)
  	c:RegisterEffect(e1)
  	--add win effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.effcon)
  	e2:SetOperation(s.effop)
  	c:RegisterEffect(e2)
  end
  function s.indcon(e)
  	return Duel.GetTurnPlayer() ~= e:GetHandlerPlayer()
  end
  function s.valcon(e, re, r, rp)
  	local res = false
  	if bit.band(r, REASON_EFFECT) ~= 0 and rp == 1 - e:GetHandlerPlayer() then
  		res = true
  		e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	end
  	return res
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) ~= 0 and Duel.GetTurnPlayer() ~= e:GetHandlerPlayer()
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CLIENT_HINT + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetCondition(s.wincon)
  	e1:SetOperation(s.winop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 2)
  	c:RegisterEffect(e1)
  end
  function s.wincon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and Duel.GetAttackTarget() == nil
  end
  function s.winop(e, tp, eg, ep, ev, re, r, rp)
  	local WIN_REASON_FLYING_ELEPHANT = 0x1e
  	Duel.Win(tp, WIN_REASON_FLYING_ELEPHANT)
  end
  
  
source_text: Flying
  Once per opponent's turn, if this card would be destroyed by their card effect, it is not destroyed. Once per turn, during their End Phase, if that effect was applied this turn: Apply the following effect.
  ��During your next turn, if this card inflicts battle damage to your opponent by a direct attack, you win the Duel.
target_text: -- Flying
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.indcon)
  	e1:SetValue(s.valcon)
  	c:RegisterEffect(e1)
  	--add win effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.effcon)
  	e2:SetOperation(s.effop)
  	c:RegisterEffect(e2)
  end
  function s.indcon(e)
  	return Duel.GetTurnPlayer() ~= e:GetHandlerPlayer()
  end
  function s.valcon(e, re, r, rp)
  	local res = false
  	if bit.band(r, REASON_EFFECT) ~= 0 and rp == 1 - e:GetHandlerPlayer() then
  		res = true
  		e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	end
  	return res
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) ~= 0 and Duel.GetTurnPlayer() ~= e:GetHandlerPlayer()
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CLIENT_HINT + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetCondition(s.wincon)
  	e1:SetOperation(s.winop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 2)
  	c:RegisterEffect(e1)
  end
  function s.wincon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and Duel.GetAttackTarget() == nil
  end
  function s.winop(e, tp, eg, ep, ev, re, r, rp)
  	local WIN_REASON_FLYING_ELEPHANT = 0x1e
  	Duel.Win(tp, WIN_REASON_FLYING_ELEPHANT)
  end
  
  