name: Labrynth
card_text: Gains 400 ATK for each Normal Trap with a different name in your GY. Your opponent's monsters cannot target Fiend monsters for attacks, except "Labrynth Archfiend". You can only use each of the following effects of "Labrynth Archfiend" once per turn. If a Trap Card is activated (except during the Damage Step): You can Special Summon this card from your hand. If this card is Special Summoned: You can Set 1 Normal Trap from your Deck that can only be activated when an attack is declared.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.sttg)
  	e2:SetOperation(s.stop)
  	c:RegisterEffect(e2)
  	--atk up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetValue(s.atkval)
  	c:RegisterEffect(e3)
  	--battle target
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(0, LOCATION_MZONE)
  	e4:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e4:SetValue(s.atklimit)
  	c:RegisterEffect(e4)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_TRAP)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.stfilter(c)
  	local te = c:GetActivateEffect()
  	return c:GetType() == TYPE_TRAP and te and te:GetCode() == EVENT_ATTACK_ANNOUNCE and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.stfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.stfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SSet(tp, g:GetFirst())
  	end
  end
  function s.atkfilter(c)
  	return c:GetType() == TYPE_TRAP
  end
  function s.atkval(e, c)
  	local g = Duel.GetMatchingGroup(s.atkfilter, e:GetHandlerPlayer(), LOCATION_GRAVE, 0, nil)
  	return g:GetClassCount(Card.GetCode) * 400
  end
  function s.atklimit(e, c)
  	return c:IsFaceup() and not c:IsCode(id) and c:IsRace(RACE_FIEND)
  end
  
  
source_text: Labrynth
  Gains 400 ATK for each Normal Trap with a different name in your GY. Your opponent's monsters cannot target Fiend monsters for attacks, except "Labrynth Archfiend". You can only use each of the following effects of "Labrynth Archfiend" once per turn. If a Trap Card is activated (except during the Damage Step): You can Special Summon this card from your hand. If this card is Special Summoned: You can Set 1 Normal Trap from your Deck that can only be activated when an attack is declared.
target_text: -- Labrynth
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.sttg)
  	e2:SetOperation(s.stop)
  	c:RegisterEffect(e2)
  	--atk up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetValue(s.atkval)
  	c:RegisterEffect(e3)
  	--battle target
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(0, LOCATION_MZONE)
  	e4:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e4:SetValue(s.atklimit)
  	c:RegisterEffect(e4)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_TRAP)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.stfilter(c)
  	local te = c:GetActivateEffect()
  	return c:GetType() == TYPE_TRAP and te and te:GetCode() == EVENT_ATTACK_ANNOUNCE and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.stfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.stfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SSet(tp, g:GetFirst())
  	end
  end
  function s.atkfilter(c)
  	return c:GetType() == TYPE_TRAP
  end
  function s.atkval(e, c)
  	local g = Duel.GetMatchingGroup(s.atkfilter, e:GetHandlerPlayer(), LOCATION_GRAVE, 0, nil)
  	return g:GetClassCount(Card.GetCode) * 400
  end
  function s.atklimit(e, c)
  	return c:IsFaceup() and not c:IsCode(id) and c:IsRace(RACE_FIEND)
  end
  
  