--輪廻独断
--Declaration of Rebirth
local s,id=GetID()
function s.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetTarget(s.target)
	c:RegisterEffect(e1)
	--Change Type
	local e2=Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetRange(LOCATION_SZONE)
	e2:SetTargetRange(LOCATION_GRAVE,LOCATION_GRAVE)
	e2:SetCode(EFFECT_CHANGE_RACE)
	e2:SetValue(s.value)
	c:RegisterEffect(e2)
	e1:SetLabelObject(e2)
	--Zombie World-like effect
	local e3=Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(4064256)
	e3:SetRange(LOCATION_SZONE)
	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e3:SetTargetRange(1,1)
	e3:SetLabelObject(e2)
	e3:SetValue(s.val)
	c:RegisterEffect(e3)
end
function s.val(e,c,re,chk)
	if chk==0 then return true end
	return e:GetLabelObject():GetLabel()
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return true end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RACE)
	local rc=Duel.AnnounceRace(tp,1,RACE_ALL)
	if e:GetLabelObject() then e:GetLabelObject():SetLabel(rc) end
	e:GetHandler():SetHint(CHINT_RACE,rc)
end
function s.value(e,c)
	return e:GetLabel()
end