name: Egotistical
card_text: This card cannot be Normal Summoned or Set. This card can only be Special Summoned by sending 1 Beast-Type monster from your hand to the Graveyard. When this card is Special Summoned this way, you can activate 1 of these effects:
  ● Increase the Level of this card by the Level of the Beast-Type monster.
  ● Decrease the Level of this card by the Level of the Beast-Type monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	e1:SetValue(SUMMON_VALUE_SELF)
  	c:RegisterEffect(e1)
  	--lv change
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.lvcon)
  	e2:SetOperation(s.lvop)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  end
  function s.spfilter(c)
  	return c:IsRace(RACE_BEAST) and c:IsAbleToGraveAsCost()
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, c)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND, 0, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local tc = g:SelectUnselect(nil, tp, false, true, 1, 1)
  	if tc then
  		e:SetLabelObject(tc)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local tc = e:GetLabelObject()
  	Duel.SendtoGrave(tc, REASON_SPSUMMON)
  	e:SetLabel(tc:GetLevel())
  end
  function s.lvcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local lv = e:GetLabelObject():GetLabel()
  		local clv = c:GetLevel()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		if lv < clv then
  			if Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2)) == 0 then
  				e1:SetValue(lv)
  			else
  				e1:SetValue(-lv)
  			end
  		else
  			Duel.SelectOption(tp, aux.Stringid(id, 1))
  			e1:SetValue(lv)
  		end
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Egotistical
  This card cannot be Normal Summoned or Set. This card can only be Special Summoned by sending 1 Beast-Type monster from your hand to the Graveyard. When this card is Special Summoned this way, you can activate 1 of these effects:
  ● Increase the Level of this card by the Level of the Beast-Type monster.
  ● Decrease the Level of this card by the Level of the Beast-Type monster.
target_text: -- Egotistical
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	e1:SetValue(SUMMON_VALUE_SELF)
  	c:RegisterEffect(e1)
  	--lv change
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.lvcon)
  	e2:SetOperation(s.lvop)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  end
  function s.spfilter(c)
  	return c:IsRace(RACE_BEAST) and c:IsAbleToGraveAsCost()
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, c)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND, 0, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local tc = g:SelectUnselect(nil, tp, false, true, 1, 1)
  	if tc then
  		e:SetLabelObject(tc)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local tc = e:GetLabelObject()
  	Duel.SendtoGrave(tc, REASON_SPSUMMON)
  	e:SetLabel(tc:GetLevel())
  end
  function s.lvcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local lv = e:GetLabelObject():GetLabel()
  		local clv = c:GetLevel()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		if lv < clv then
  			if Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2)) == 0 then
  				e1:SetValue(lv)
  			else
  				e1:SetValue(-lv)
  			end
  		else
  			Duel.SelectOption(tp, aux.Stringid(id, 1))
  			e1:SetValue(lv)
  		end
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  
  