name: Fabled
card_text: 1 "Fabled" Tuner + 1+ non-Tuner monsters
  Your opponent cannot target other "Fabled" Synchro Monsters you control with card effects. You can only use each of the following effects of "Fabled Gammajin" once per turn. If this card is Synchro Summoned: You can Special Summon 1 "Fabled" monster from your hand or Deck. If this card is sent to the GY: You can draw cards equal to the number of "Fabled" Synchro Monsters you control, then discard 1 card.
external_ids: local SETCARD_ID_0 = 0x35 --Fabled
  
lua: local SETCARD_ID_0 = 0x35 --Fabled
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.tglimit)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_DRAW | CATEGORY_HANDES)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + o)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.tglimit(e, c)
  	return c ~= e:GetHandler() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SYNCHRO) and c:IsFaceup()
  end
  function s.drfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SYNCHRO) and c:IsFaceup()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.drfilter, tp, LOCATION_MZONE, 0, nil)
  	if chk == 0 then
  		return ct > 0 and Duel.IsPlayerCanDraw(tp, ct)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, ct, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.drfilter, tp, LOCATION_MZONE, 0, nil)
  	if ct == 0 then
  		return
  	end
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	if Duel.Draw(p, ct, REASON_EFFECT) > 0 then
  		Duel.BreakEffect()
  		Duel.DiscardHand(p, nil, 1, 1, REASON_EFFECT + REASON_DISCARD)
  	end
  end
  
  
source_text: Fabled
  1 "Fabled" Tuner + 1+ non-Tuner monsters
  Your opponent cannot target other "Fabled" Synchro Monsters you control with card effects. You can only use each of the following effects of "Fabled Gammajin" once per turn. If this card is Synchro Summoned: You can Special Summon 1 "Fabled" monster from your hand or Deck. If this card is sent to the GY: You can draw cards equal to the number of "Fabled" Synchro Monsters you control, then discard 1 card.
target_text: -- Fabled
  local SETCARD_ID_0 = 0x35 --Fabled
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.tglimit)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_DRAW | CATEGORY_HANDES)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + o)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.tglimit(e, c)
  	return c ~= e:GetHandler() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SYNCHRO) and c:IsFaceup()
  end
  function s.drfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SYNCHRO) and c:IsFaceup()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.drfilter, tp, LOCATION_MZONE, 0, nil)
  	if chk == 0 then
  		return ct > 0 and Duel.IsPlayerCanDraw(tp, ct)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, ct, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.drfilter, tp, LOCATION_MZONE, 0, nil)
  	if ct == 0 then
  		return
  	end
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	if Duel.Draw(p, ct, REASON_EFFECT) > 0 then
  		Duel.BreakEffect()
  		Duel.DiscardHand(p, nil, 1, 1, REASON_EFFECT + REASON_DISCARD)
  	end
  end
  
  