name: Overmind
card_text: 1 Psychic-Type Tuner + 2 or more non-Tuner Psychic-Type monsters
  Once per turn, you can select 1 Psychic-Type monster in your Graveyard, and remove it from play. When this card is sent from the field to the Graveyard, Special Summon as many monsters as possible that were removed from play by this effect.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_PSYCHO), aux.NonTuner(Card.IsRace, RACE_PSYCHO), 2)
  	c:EnableReviveLimit()
  	--remove
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  	local sg = Group.CreateGroup()
  	sg:KeepAlive()
  	e1:SetLabelObject(sg)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	e2:SetLabelObject(sg)
  	c:RegisterEffect(e2)
  end
  function s.rmfilter(c)
  	return c:IsRace(RACE_PSYCHO) and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.rmfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.rmfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.rmfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, tp, LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsRace(RACE_PSYCHO) and Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_REMOVED) then
  		if c:IsRelateToEffect(e) then
  			local sg = e:GetLabelObject()
  			if c:GetFlagEffect(id) == 0 then
  				sg:Clear()
  				c:RegisterFlagEffect(id, RESET_EVENT + 0x1680000, 0, 1)
  			end
  			sg:AddCard(tc)
  			tc:CreateRelation(c, RESET_EVENT + RESETS_STANDARD)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) and e:GetHandler():GetFlagEffect(id) ~= 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_REMOVED)
  end
  function s.spfilter(c, rc, e, tp)
  	return c:IsRelateToCard(rc) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local tg = g:Filter(s.spfilter, nil, e:GetHandler(), e, tp)
  	if ft <= 0 or tg:GetCount() == 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = tg:Select(tp, ft, ft, nil)
  	Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  
source_text: Overmind
  1 Psychic-Type Tuner + 2 or more non-Tuner Psychic-Type monsters
  Once per turn, you can select 1 Psychic-Type monster in your Graveyard, and remove it from play. When this card is sent from the field to the Graveyard, Special Summon as many monsters as possible that were removed from play by this effect.
target_text: -- Overmind
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_PSYCHO), aux.NonTuner(Card.IsRace, RACE_PSYCHO), 2)
  	c:EnableReviveLimit()
  	--remove
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  	local sg = Group.CreateGroup()
  	sg:KeepAlive()
  	e1:SetLabelObject(sg)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	e2:SetLabelObject(sg)
  	c:RegisterEffect(e2)
  end
  function s.rmfilter(c)
  	return c:IsRace(RACE_PSYCHO) and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.rmfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.rmfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.rmfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, tp, LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsRace(RACE_PSYCHO) and Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_REMOVED) then
  		if c:IsRelateToEffect(e) then
  			local sg = e:GetLabelObject()
  			if c:GetFlagEffect(id) == 0 then
  				sg:Clear()
  				c:RegisterFlagEffect(id, RESET_EVENT + 0x1680000, 0, 1)
  			end
  			sg:AddCard(tc)
  			tc:CreateRelation(c, RESET_EVENT + RESETS_STANDARD)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) and e:GetHandler():GetFlagEffect(id) ~= 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_REMOVED)
  end
  function s.spfilter(c, rc, e, tp)
  	return c:IsRelateToCard(rc) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local tg = g:Filter(s.spfilter, nil, e:GetHandler(), e, tp)
  	if ft <= 0 or tg:GetCount() == 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = tg:Select(tp, ft, ft, nil)
  	Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  