name: Raviel,
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by Tributing 3 Fiend monsters. Each time your opponent Normal Summons a monster: Special Summon 1 "Phantasm Token" (Fiend/DARK/Level 1/ATK 1000/DEF 1000), but it cannot declare an attack. Once per turn: You can Tribute 1 monster; this card gains ATK equal to the Tributed monster's original ATK, until the end of this turn.
external_ids: local CARD_ID_0 = 69890968 --Phantasm Token
  
lua: local CARD_ID_0 = 69890968 --Phantasm Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--token
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EVENT_SUMMON_SUCCESS)
  	e3:SetCondition(s.tkcon)
  	e3:SetTarget(s.tktg)
  	e3:SetOperation(s.tkop)
  	c:RegisterEffect(e3)
  	--atkup
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_ATKCHANGE)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCost(s.atcost)
  	e4:SetOperation(s.atop)
  	c:RegisterEffect(e4)
  end
  function s.rfilter(c, tp)
  	return c:IsRace(RACE_FIEND) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	return rg:CheckSubGroup(aux.mzctcheckrel, 3, 3, tp, REASON_SPSUMMON)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local sg = rg:SelectSubGroup(tp, aux.mzctcheckrel, true, 3, 3, tp, REASON_SPSUMMON)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Release(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.tkcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 1000, 1000, 1, RACE_FIEND, ATTRIBUTE_DARK) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	Duel.SpecialSummon(token, 0, tp, tp, false, false, POS_FACEUP)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	token:RegisterEffect(e1, true)
  end
  function s.atcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, nil, 1, e:GetHandler())
  	end
  	local g = Duel.SelectReleaseGroup(tp, nil, 1, 1, e:GetHandler())
  	local atk = g:GetFirst():GetTextAttack()
  	if atk < 0 then
  		atk = 0
  	end
  	e:SetLabel(atk)
  	Duel.Release(g, REASON_COST)
  end
  function s.atop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(e:GetLabel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Raviel,
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by Tributing 3 Fiend monsters. Each time your opponent Normal Summons a monster: Special Summon 1 "Phantasm Token" (Fiend/DARK/Level 1/ATK 1000/DEF 1000), but it cannot declare an attack. Once per turn: You can Tribute 1 monster; this card gains ATK equal to the Tributed monster's original ATK, until the end of this turn.
target_text: -- Raviel,
  local CARD_ID_0 = 69890968 --Phantasm Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--token
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EVENT_SUMMON_SUCCESS)
  	e3:SetCondition(s.tkcon)
  	e3:SetTarget(s.tktg)
  	e3:SetOperation(s.tkop)
  	c:RegisterEffect(e3)
  	--atkup
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_ATKCHANGE)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCost(s.atcost)
  	e4:SetOperation(s.atop)
  	c:RegisterEffect(e4)
  end
  function s.rfilter(c, tp)
  	return c:IsRace(RACE_FIEND) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	return rg:CheckSubGroup(aux.mzctcheckrel, 3, 3, tp, REASON_SPSUMMON)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local sg = rg:SelectSubGroup(tp, aux.mzctcheckrel, true, 3, 3, tp, REASON_SPSUMMON)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Release(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.tkcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 1000, 1000, 1, RACE_FIEND, ATTRIBUTE_DARK) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	Duel.SpecialSummon(token, 0, tp, tp, false, false, POS_FACEUP)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	token:RegisterEffect(e1, true)
  end
  function s.atcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, nil, 1, e:GetHandler())
  	end
  	local g = Duel.SelectReleaseGroup(tp, nil, 1, 1, e:GetHandler())
  	local atk = g:GetFirst():GetTextAttack()
  	if atk < 0 then
  		atk = 0
  	end
  	e:SetLabel(atk)
  	Duel.Release(g, REASON_COST)
  end
  function s.atop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(e:GetLabel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  