name: Eda
card_text: If this card is Normal Summoned or flipped face-up: You can Special Summon 1 Spellcaster monster with 1500 DEF from your hand or Deck in face-down Defense Position, except "Eda the Sun Magician". During your opponent's Main Phase (Quick Effect): You can change 1 face-down Spellcaster monster you control to face-up Attack or Defense Position. You can only use each effect of "Eda the Sun Magician" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--SpecialSummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP)
  	c:RegisterEffect(e2)
  	--change pos
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_POSITION)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.poscon)
  	e3:SetTarget(s.postg)
  	e3:SetOperation(s.posop)
  	c:RegisterEffect(e3)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_SPELLCASTER) and c:IsDefense(1500) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEDOWN_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEDOWN_DEFENSE)
  		Duel.ConfirmCards(1 - tp, tc)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return Duel.GetTurnPlayer() ~= tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.filter(c)
  	return c:IsRace(RACE_SPELLCASTER) and c:IsFacedown()
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, nil, 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local pos = Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEUP_DEFENSE)
  		Duel.ChangePosition(tc, pos)
  	end
  end
  
  
source_text: Eda
  If this card is Normal Summoned or flipped face-up: You can Special Summon 1 Spellcaster monster with 1500 DEF from your hand or Deck in face-down Defense Position, except "Eda the Sun Magician". During your opponent's Main Phase (Quick Effect): You can change 1 face-down Spellcaster monster you control to face-up Attack or Defense Position. You can only use each effect of "Eda the Sun Magician" once per turn.
target_text: -- Eda
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--SpecialSummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP)
  	c:RegisterEffect(e2)
  	--change pos
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_POSITION)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.poscon)
  	e3:SetTarget(s.postg)
  	e3:SetOperation(s.posop)
  	c:RegisterEffect(e3)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_SPELLCASTER) and c:IsDefense(1500) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEDOWN_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEDOWN_DEFENSE)
  		Duel.ConfirmCards(1 - tp, tc)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return Duel.GetTurnPlayer() ~= tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.filter(c)
  	return c:IsRace(RACE_SPELLCASTER) and c:IsFacedown()
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, nil, 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local pos = Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEUP_DEFENSE)
  		Duel.ChangePosition(tc, pos)
  	end
  end
  
  