name: Lyrilusc
card_text: 2+ Level 1 monsters
  Gains 200 ATK for each material attached to it. This card can attack directly. While this card has material, it can attack a number of times each Battle Phase, up to the number of materials attached to it. Once per turn (Quick Effect): You can detach 1 material from this card; until the end of this turn, "Lyrilusc" monsters you control cannot be destroyed by battle or card effects, also you take no battle damage.
external_ids: local SETCARD_ID_0 = 0xf7 --Lyrilusc
  
lua: local SETCARD_ID_0 = 0xf7 --Lyrilusc
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, nil, 1, 2, nil, nil, 99)
  	--ATK Up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	--Direct Attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DIRECT_ATTACK)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	c:RegisterEffect(e2)
  	--multi attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_EXTRA_ATTACK)
  	e3:SetValue(s.raval)
  	c:RegisterEffect(e3)
  	--Protection
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_BATTLE_START)
  	e4:SetCountLimit(1)
  	e4:SetCost(s.indcost)
  	e4:SetOperation(s.indop)
  	c:RegisterEffect(e4)
  end
  function s.atkval(e, c)
  	return c:GetOverlayCount() * 200
  end
  function s.raval(e, c)
  	local oc = e:GetHandler():GetOverlayCount()
  	return math.max(0, oc - 1)
  end
  function s.indcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetValue(1)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	Duel.RegisterEffect(e2, tp)
  	local e3 = Effect.CreateEffect(e:GetHandler())
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 0)
  	e3:SetValue(1)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  end
  
  
source_text: Lyrilusc
  2+ Level 1 monsters
  Gains 200 ATK for each material attached to it. This card can attack directly. While this card has material, it can attack a number of times each Battle Phase, up to the number of materials attached to it. Once per turn (Quick Effect): You can detach 1 material from this card; until the end of this turn, "Lyrilusc" monsters you control cannot be destroyed by battle or card effects, also you take no battle damage.
target_text: -- Lyrilusc
  local SETCARD_ID_0 = 0xf7 --Lyrilusc
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, nil, 1, 2, nil, nil, 99)
  	--ATK Up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	--Direct Attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DIRECT_ATTACK)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	c:RegisterEffect(e2)
  	--multi attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_EXTRA_ATTACK)
  	e3:SetValue(s.raval)
  	c:RegisterEffect(e3)
  	--Protection
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_BATTLE_START)
  	e4:SetCountLimit(1)
  	e4:SetCost(s.indcost)
  	e4:SetOperation(s.indop)
  	c:RegisterEffect(e4)
  end
  function s.atkval(e, c)
  	return c:GetOverlayCount() * 200
  end
  function s.raval(e, c)
  	local oc = e:GetHandler():GetOverlayCount()
  	return math.max(0, oc - 1)
  end
  function s.indcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetValue(1)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	Duel.RegisterEffect(e2, tp)
  	local e3 = Effect.CreateEffect(e:GetHandler())
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 0)
  	e3:SetValue(1)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  end
  
  