name: 輪廻独断
card_text: 1:1ターンに1度、種族を1つ宣言して発動できる。
  このターン、お互いの墓地のモンスターは宣言した種族になる。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  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)
  	e:SetLabel(rc)
  	local g = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_GRAVE, LOCATION_GRAVE, nil, TYPE_MONSTER)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, g:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CHANGE_RACE)
  	e1:SetTargetRange(LOCATION_GRAVE, LOCATION_GRAVE)
  	e1:SetValue(e:GetLabel())
  	e1:SetCondition(s.condition)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	if EFFECT_CHANGE_GRAVE_RACE == nil then
  		return
  	end
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CHANGE_GRAVE_RACE)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 1)
  	e2:SetValue(e:GetLabel())
  	e2:SetCondition(s.condition)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.condition(e)
  	local tp = e:GetHandlerPlayer()
  	return not Duel.IsPlayerAffectedByEffect(tp, EFFECT_NECRO_VALLEY) and not Duel.IsPlayerAffectedByEffect(1 - tp, EFFECT_NECRO_VALLEY)
  end
  
  
source_text: 輪廻独断
  1:1ターンに1度、種族を1つ宣言して発動できる。
  このターン、お互いの墓地のモンスターは宣言した種族になる。
target_text: -- 輪廻独断
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  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)
  	e:SetLabel(rc)
  	local g = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_GRAVE, LOCATION_GRAVE, nil, TYPE_MONSTER)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, g:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CHANGE_RACE)
  	e1:SetTargetRange(LOCATION_GRAVE, LOCATION_GRAVE)
  	e1:SetValue(e:GetLabel())
  	e1:SetCondition(s.condition)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	if EFFECT_CHANGE_GRAVE_RACE == nil then
  		return
  	end
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CHANGE_GRAVE_RACE)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 1)
  	e2:SetValue(e:GetLabel())
  	e2:SetCondition(s.condition)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.condition(e)
  	local tp = e:GetHandlerPlayer()
  	return not Duel.IsPlayerAffectedByEffect(tp, EFFECT_NECRO_VALLEY) and not Duel.IsPlayerAffectedByEffect(1 - tp, EFFECT_NECRO_VALLEY)
  end
  
  