name: Fabled
card_text: Once per turn: You can discard any number of cards, and if you do, this card gains 1 Level and 400 ATK for each discarded card, until the end of this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--lv atk up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_HANDES + CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTarget(s.tg)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, 1)
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.DiscardHand(tp, aux.TRUE, 1, 60, REASON_EFFECT + REASON_DISCARD)
  	if ct > 0 and c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e1:SetValue(ct * 400)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_UPDATE_LEVEL)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e2:SetValue(ct)
  		c:RegisterEffect(e2)
  	end
  end
  
  
source_text: Fabled
  Once per turn: You can discard any number of cards, and if you do, this card gains 1 Level and 400 ATK for each discarded card, until the end of this turn.
target_text: -- Fabled
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--lv atk up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_HANDES + CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTarget(s.tg)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, 1)
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.DiscardHand(tp, aux.TRUE, 1, 60, REASON_EFFECT + REASON_DISCARD)
  	if ct > 0 and c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e1:SetValue(ct * 400)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_UPDATE_LEVEL)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e2:SetValue(ct)
  		c:RegisterEffect(e2)
  	end
  end
  
  