name: Fenrir
card_text: Cannot be Normal Summoned/Set. During your Main Phase 2, if an "Aesir" monster is on the field, you can Special Summon this card (from your hand) to your opponent's side of the field in Defense Position. If an "Aesir" monster is not on the field, destroy this card. At the start of your Battle Phase: Change all Defense Position monsters you control to face-up Attack Position. Both players take any battle damage from attacks involving this card.
external_ids: local SETCARD_ID_0 = 0x4b --Aesir
  
lua: local SETCARD_ID_0 = 0x4b --Aesir
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SPSUM_PARAM)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetTargetRange(POS_FACEUP_DEFENSE, 1)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--self destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetCondition(s.descon)
  	c:RegisterEffect(e4)
  	--pos
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_POSITION)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e5:SetCode(EVENT_PHASE + PHASE_BATTLE_START)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCountLimit(1)
  	e5:SetCondition(s.poscon)
  	e5:SetTarget(s.postg)
  	e5:SetOperation(s.posop)
  	c:RegisterEffect(e5)
  	--damage
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_BOTH_BATTLE_DAMAGE)
  	c:RegisterEffect(e6)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return Duel.GetCurrentPhase() == PHASE_MAIN2
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.descon(e)
  	return not Duel.IsExistingMatchingCard(s.filter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(Card.IsDefensePos, tp, LOCATION_MZONE, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsDefensePos, tp, LOCATION_MZONE, 0, nil)
  	if g:GetCount() > 0 then
  		Duel.ChangePosition(g, POS_FACEUP_ATTACK)
  	end
  end
  
  
source_text: Fenrir
  Cannot be Normal Summoned/Set. During your Main Phase 2, if an "Aesir" monster is on the field, you can Special Summon this card (from your hand) to your opponent's side of the field in Defense Position. If an "Aesir" monster is not on the field, destroy this card. At the start of your Battle Phase: Change all Defense Position monsters you control to face-up Attack Position. Both players take any battle damage from attacks involving this card.
target_text: -- Fenrir
  local SETCARD_ID_0 = 0x4b --Aesir
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SPSUM_PARAM)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetTargetRange(POS_FACEUP_DEFENSE, 1)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--self destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetCondition(s.descon)
  	c:RegisterEffect(e4)
  	--pos
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_POSITION)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e5:SetCode(EVENT_PHASE + PHASE_BATTLE_START)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCountLimit(1)
  	e5:SetCondition(s.poscon)
  	e5:SetTarget(s.postg)
  	e5:SetOperation(s.posop)
  	c:RegisterEffect(e5)
  	--damage
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_BOTH_BATTLE_DAMAGE)
  	c:RegisterEffect(e6)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return Duel.GetCurrentPhase() == PHASE_MAIN2
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.descon(e)
  	return not Duel.IsExistingMatchingCard(s.filter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(Card.IsDefensePos, tp, LOCATION_MZONE, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsDefensePos, tp, LOCATION_MZONE, 0, nil)
  	if g:GetCount() > 0 then
  		Duel.ChangePosition(g, POS_FACEUP_ATTACK)
  	end
  end
  
  