name: Metaphys
card_text: Each turn, 1 Level 5 or higher "Metaphys" monster you Normal Summon can be Summoned without Tributing, but banish it during the End Phase of the next turn. Your opponent cannot activate cards or effects in response to your "Metaphys" monsters' effect activations.
external_ids: local SETCARD_ID_0 = 0x105 --Metaphys
  
lua: local SETCARD_ID_0 = 0x105 --Metaphys
  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)
  	--decrease tribute
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SUMMON_PROC)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_HAND, 0)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.ntcon)
  	e2:SetTarget(s.nttg)
  	e2:SetOperation(s.ntop)
  	c:RegisterEffect(e2)
  	--act limit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetOperation(s.chainop)
  	c:RegisterEffect(e3)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.nttg(e, c)
  	return c:IsLevelAbove(5) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.ntop(e, tp, eg, ep, ev, re, r, rp, c)
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 1))
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetCountLimit(1)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetLabel(Duel.GetTurnCount() + 1)
  	e2:SetLabelObject(c)
  	e2:SetCondition(s.rmcon)
  	e2:SetOperation(s.rmop)
  	e2:SetReset(RESET_PHASE + PHASE_END, 2)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc:GetFlagEffect(id) ~= 0 then
  		return Duel.GetTurnCount() == e:GetLabel()
  	else
  		e:Reset()
  		return false
  	end
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  end
  function s.chainop(e, tp, eg, ep, ev, re, r, rp)
  	if re:GetHandler():IsSetCard(SETCARD_ID_0) and re:IsActiveType(TYPE_MONSTER) and ep == tp then
  		Duel.SetChainLimit(s.chainlm)
  	end
  end
  function s.chainlm(e, rp, tp)
  	return tp == rp
  end
  
  
source_text: Metaphys
  Each turn, 1 Level 5 or higher "Metaphys" monster you Normal Summon can be Summoned without Tributing, but banish it during the End Phase of the next turn. Your opponent cannot activate cards or effects in response to your "Metaphys" monsters' effect activations.
target_text: -- Metaphys
  local SETCARD_ID_0 = 0x105 --Metaphys
  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)
  	--decrease tribute
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SUMMON_PROC)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_HAND, 0)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.ntcon)
  	e2:SetTarget(s.nttg)
  	e2:SetOperation(s.ntop)
  	c:RegisterEffect(e2)
  	--act limit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetOperation(s.chainop)
  	c:RegisterEffect(e3)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.nttg(e, c)
  	return c:IsLevelAbove(5) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.ntop(e, tp, eg, ep, ev, re, r, rp, c)
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 1))
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetCountLimit(1)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetLabel(Duel.GetTurnCount() + 1)
  	e2:SetLabelObject(c)
  	e2:SetCondition(s.rmcon)
  	e2:SetOperation(s.rmop)
  	e2:SetReset(RESET_PHASE + PHASE_END, 2)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc:GetFlagEffect(id) ~= 0 then
  		return Duel.GetTurnCount() == e:GetLabel()
  	else
  		e:Reset()
  		return false
  	end
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  end
  function s.chainop(e, tp, eg, ep, ev, re, r, rp)
  	if re:GetHandler():IsSetCard(SETCARD_ID_0) and re:IsActiveType(TYPE_MONSTER) and ep == tp then
  		Duel.SetChainLimit(s.chainlm)
  	end
  end
  function s.chainlm(e, rp, tp)
  	return tp == rp
  end
  
  