name: Fairy
card_text: When your opponent's monster declares an attack: Toss a coin and call it. If you call it right, the attacking monster's ATK becomes 0 until the end of the Battle Phase. Once per turn, during your Standby Phase, pay 500 LP, or destroy this card.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk change
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_COIN)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  	--maintain
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e3:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.mtcon)
  	e3:SetOperation(s.mtop)
  	c:RegisterEffect(e3)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return tp ~= Duel.GetTurnPlayer()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetCard(Duel.GetAttacker())
  	Duel.SetOperationInfo(0, CATEGORY_COIN, nil, 0, tp, 1)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	if not a:IsRelateToEffect(e) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_COIN)
  	local coin = Duel.AnnounceCoin(tp)
  	local res = Duel.TossCoin(tp, 1)
  	if coin ~= res then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(0)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_BATTLE)
  		a:RegisterEffect(e1)
  	end
  end
  function s.mtcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.mtop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.CheckLPCost(tp, 500) and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.PayLPCost(tp, 500)
  	else
  		Duel.Destroy(e:GetHandler(), REASON_COST)
  	end
  end
  
  
source_text: Fairy
  When your opponent's monster declares an attack: Toss a coin and call it. If you call it right, the attacking monster's ATK becomes 0 until the end of the Battle Phase. Once per turn, during your Standby Phase, pay 500 LP, or destroy this card.
target_text: -- Fairy
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk change
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_COIN)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  	--maintain
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e3:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.mtcon)
  	e3:SetOperation(s.mtop)
  	c:RegisterEffect(e3)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return tp ~= Duel.GetTurnPlayer()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetCard(Duel.GetAttacker())
  	Duel.SetOperationInfo(0, CATEGORY_COIN, nil, 0, tp, 1)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	if not a:IsRelateToEffect(e) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_COIN)
  	local coin = Duel.AnnounceCoin(tp)
  	local res = Duel.TossCoin(tp, 1)
  	if coin ~= res then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(0)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_BATTLE)
  		a:RegisterEffect(e1)
  	end
  end
  function s.mtcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.mtop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.CheckLPCost(tp, 500) and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.PayLPCost(tp, 500)
  	else
  		Duel.Destroy(e:GetHandler(), REASON_COST)
  	end
  end
  
  