name: Hundred
card_text: Once per turn: You can have this card gain Levels equal to the number of cards you control, and if you do, it gains 100 ATK for each Level gained. These changes last until the end of this turn. If this card is sent to the GY: You can target 1 face-up monster you control that was Special Summoned from the Extra Deck; the first time that face-up monster would be destroyed by battle or card effect, it is not destroyed. You can only use this effect of "Hundred Dragon" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--lv/atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.lvtg)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.indtg)
  	e2:SetOperation(s.indop)
  	c:RegisterEffect(e2)
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsLevelAbove(1) and Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0) > 0
  	end
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local lv = Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0)
  	if c:IsFaceup() and c:IsRelateToEffect(e) and c:IsLevelAbove(1) and lv > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		e1:SetValue(lv)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_UPDATE_ATTACK)
  		e2:SetValue(lv * 100)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e2)
  	end
  end
  function s.indfilter(c)
  	return c:IsFaceup() and c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.indtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.indfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.indfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.indfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 2))
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE + EFFECT_FLAG_CLIENT_HINT + EFFECT_FLAG_NO_TURN_RESET)
  		e1:SetRange(LOCATION_ONFIELD)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  		e1:SetCountLimit(1)
  		e1:SetValue(s.indct)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.indct(e, re, r, rp)
  	if bit.band(r, REASON_BATTLE + REASON_EFFECT) ~= 0 then
  		return 1
  	else
  		return 0
  	end
  end
  
  
source_text: Hundred
  Once per turn: You can have this card gain Levels equal to the number of cards you control, and if you do, it gains 100 ATK for each Level gained. These changes last until the end of this turn. If this card is sent to the GY: You can target 1 face-up monster you control that was Special Summoned from the Extra Deck; the first time that face-up monster would be destroyed by battle or card effect, it is not destroyed. You can only use this effect of "Hundred Dragon" once per turn.
target_text: -- Hundred
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--lv/atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.lvtg)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.indtg)
  	e2:SetOperation(s.indop)
  	c:RegisterEffect(e2)
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsLevelAbove(1) and Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0) > 0
  	end
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local lv = Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0)
  	if c:IsFaceup() and c:IsRelateToEffect(e) and c:IsLevelAbove(1) and lv > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		e1:SetValue(lv)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_UPDATE_ATTACK)
  		e2:SetValue(lv * 100)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e2)
  	end
  end
  function s.indfilter(c)
  	return c:IsFaceup() and c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.indtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.indfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.indfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.indfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 2))
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE + EFFECT_FLAG_CLIENT_HINT + EFFECT_FLAG_NO_TURN_RESET)
  		e1:SetRange(LOCATION_ONFIELD)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  		e1:SetCountLimit(1)
  		e1:SetValue(s.indct)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.indct(e, re, r, rp)
  	if bit.band(r, REASON_BATTLE + REASON_EFFECT) ~= 0 then
  		return 1
  	else
  		return 0
  	end
  end
  
  