name: Valkyrie's
card_text: If all monsters you control are "Valkyrie" monsters: Target 1 Attack Position "Valkyrie" monster you control and 1 face-up monster your opponent controls; change your monster to Defense Position, and if you do, banish that opponent's monster. You cannot Special Summon monsters the turn you activate this card, except "Valkyrie" monsters. You can only activate 1 "Valkyrie's Embrace" per turn.
external_ids: local SETCARD_ID_0 = 0x122 --Valkyrie
  
lua: local SETCARD_ID_0 = 0x122 --Valkyrie
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.rmcost)
  	e1:SetCondition(s.rmcon)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.rmcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabelObject(e)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.cfilter2(c)
  	return c:IsFacedown() or not c:IsSetCard(SETCARD_ID_0)
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) and not Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsPosition(POS_FACEUP_ATTACK)
  end
  function s.rmfilter(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingTarget(s.rmfilter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g1 = Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g2 = Duel.SelectTarget(tp, s.rmfilter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	e:SetLabelObject(g2:GetFirst())
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g2, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local hc = e:GetLabelObject()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tc = g:GetFirst()
  	if tc == hc then
  		tc = g:GetNext()
  	end
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) and Duel.ChangePosition(tc, POS_FACEUP_DEFENSE) > 0 and hc:IsRelateToEffect(e) then
  		Duel.Remove(hc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  
source_text: Valkyrie's
  If all monsters you control are "Valkyrie" monsters: Target 1 Attack Position "Valkyrie" monster you control and 1 face-up monster your opponent controls; change your monster to Defense Position, and if you do, banish that opponent's monster. You cannot Special Summon monsters the turn you activate this card, except "Valkyrie" monsters. You can only activate 1 "Valkyrie's Embrace" per turn.
target_text: -- Valkyrie's
  local SETCARD_ID_0 = 0x122 --Valkyrie
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.rmcost)
  	e1:SetCondition(s.rmcon)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.rmcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabelObject(e)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.cfilter2(c)
  	return c:IsFacedown() or not c:IsSetCard(SETCARD_ID_0)
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) and not Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsPosition(POS_FACEUP_ATTACK)
  end
  function s.rmfilter(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingTarget(s.rmfilter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g1 = Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g2 = Duel.SelectTarget(tp, s.rmfilter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	e:SetLabelObject(g2:GetFirst())
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g2, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local hc = e:GetLabelObject()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tc = g:GetFirst()
  	if tc == hc then
  		tc = g:GetNext()
  	end
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) and Duel.ChangePosition(tc, POS_FACEUP_DEFENSE) > 0 and hc:IsRelateToEffect(e) then
  		Duel.Remove(hc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  