name: Nordic
card_text: Banish 1 "Aesir" or "Nordic" monster you control, then target 1 card on the field; destroy it, also during your 2nd End Phase after activation, return the monster you banished to activate this card to the field in face-up Attack Position.
external_ids: local SETCARD_ID_0 = 0x42 --Nordic
  
lua: local SETCARD_ID_0 = 0x42 --Nordic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0, 0x4b) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.Remove(g, 0, REASON_COST + REASON_TEMPORARY)
  	e:SetLabelObject(g:GetFirst())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc ~= e:GetHandler()
  	end
  	if chk == 0 then
  		e:SetLabel(0)
  		return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 and e:GetLabel() == 1 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetCountLimit(1)
  		e1:SetCondition(s.retcon)
  		e1:SetOperation(s.retop)
  		e1:SetLabel(2)
  		e1:SetLabelObject(e:GetLabelObject())
  		e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = e:GetLabel()
  	ct = ct - 1
  	e:SetLabel(ct)
  	if ct == 0 then
  		Duel.ReturnToField(e:GetLabelObject(), POS_FACEUP_ATTACK)
  	end
  end
  
  
source_text: Nordic
  Banish 1 "Aesir" or "Nordic" monster you control, then target 1 card on the field; destroy it, also during your 2nd End Phase after activation, return the monster you banished to activate this card to the field in face-up Attack Position.
target_text: -- Nordic
  local SETCARD_ID_0 = 0x42 --Nordic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0, 0x4b) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.Remove(g, 0, REASON_COST + REASON_TEMPORARY)
  	e:SetLabelObject(g:GetFirst())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc ~= e:GetHandler()
  	end
  	if chk == 0 then
  		e:SetLabel(0)
  		return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 and e:GetLabel() == 1 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetCountLimit(1)
  		e1:SetCondition(s.retcon)
  		e1:SetOperation(s.retop)
  		e1:SetLabel(2)
  		e1:SetLabelObject(e:GetLabelObject())
  		e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = e:GetLabel()
  	ct = ct - 1
  	e:SetLabel(ct)
  	if ct == 0 then
  		Duel.ReturnToField(e:GetLabelObject(), POS_FACEUP_ATTACK)
  	end
  end
  
  