name: Bone
card_text: Discard 1 card. Special Summon 1 Level 4 or lower monster from your opponent's Graveyard to your side of the field, and your opponent Special Summons 1 Level 4 or lower monster from your Graveyard to your opponent's side of the field. Those monsters are destroyed during the End Phase of the next turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) ~= 0
  			and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_GRAVE, 1, nil, e, tp)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingTarget(s.filter, 1 - tp, 0, LOCATION_GRAVE, 1, nil, e, 1 - tp)
  			and Duel.GetLocationCount(1 - tp, LOCATION_MZONE, 1 - tp) > 0
  	end
  	local tg = Group.CreateGroup()
  	for p in aux.TurnPlayers() do
  		Duel.Hint(HINT_SELECTMSG, p, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(p, s.filter, p, 0, LOCATION_GRAVE, 1, 1, nil, e, p)
  		tg:Merge(g)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, tg, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_EFFECT + REASON_DISCARD) == 0 then
  		return
  	end
  	local tg = Duel.GetTargetsRelateToChain()
  	if #tg == 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local fid = c:GetFieldID()
  	local sg = Group.CreateGroup()
  	for p in aux.TurnPlayers() do
  		local tc = tg:Filter(Card.IsControler, nil, 1 - p):GetFirst()
  		if tc and Duel.SpecialSummonStep(tc, 0, p, p, false, false, POS_FACEUP) then
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			tg:RemoveCard(tc)
  			sg:AddCard(tc)
  		end
  	end
  	Duel.SpecialSummonComplete()
  	if #sg == 0 then
  		return
  	end
  	sg:KeepAlive()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCondition(s.descon)
  	e1:SetOperation(s.desop)
  	e1:SetLabel(fid, Duel.GetTurnCount())
  	e1:SetLabelObject(sg)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 2)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.desfilter(c, fid)
  	return c:GetFlagEffectLabel(id) == fid
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local fid, turnc = e:GetLabel()
  	if Duel.GetTurnCount() == turnc then
  		return false
  	end
  	local g = e:GetLabelObject()
  	if not g:IsExists(s.desfilter, 1, nil, fid) then
  		g:DeleteGroup()
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local fid, turnc = e:GetLabel()
  	local g = e:GetLabelObject()
  	local tg = g:Filter(s.desfilter, nil, fid)
  	Duel.Destroy(tg, REASON_EFFECT)
  end
  
  
source_text: Bone
  Discard 1 card. Special Summon 1 Level 4 or lower monster from your opponent's Graveyard to your side of the field, and your opponent Special Summons 1 Level 4 or lower monster from your Graveyard to your opponent's side of the field. Those monsters are destroyed during the End Phase of the next turn.
target_text: -- Bone
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) ~= 0
  			and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_GRAVE, 1, nil, e, tp)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingTarget(s.filter, 1 - tp, 0, LOCATION_GRAVE, 1, nil, e, 1 - tp)
  			and Duel.GetLocationCount(1 - tp, LOCATION_MZONE, 1 - tp) > 0
  	end
  	local tg = Group.CreateGroup()
  	for p in aux.TurnPlayers() do
  		Duel.Hint(HINT_SELECTMSG, p, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(p, s.filter, p, 0, LOCATION_GRAVE, 1, 1, nil, e, p)
  		tg:Merge(g)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, tg, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_EFFECT + REASON_DISCARD) == 0 then
  		return
  	end
  	local tg = Duel.GetTargetsRelateToChain()
  	if #tg == 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local fid = c:GetFieldID()
  	local sg = Group.CreateGroup()
  	for p in aux.TurnPlayers() do
  		local tc = tg:Filter(Card.IsControler, nil, 1 - p):GetFirst()
  		if tc and Duel.SpecialSummonStep(tc, 0, p, p, false, false, POS_FACEUP) then
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			tg:RemoveCard(tc)
  			sg:AddCard(tc)
  		end
  	end
  	Duel.SpecialSummonComplete()
  	if #sg == 0 then
  		return
  	end
  	sg:KeepAlive()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCondition(s.descon)
  	e1:SetOperation(s.desop)
  	e1:SetLabel(fid, Duel.GetTurnCount())
  	e1:SetLabelObject(sg)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 2)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.desfilter(c, fid)
  	return c:GetFlagEffectLabel(id) == fid
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local fid, turnc = e:GetLabel()
  	if Duel.GetTurnCount() == turnc then
  		return false
  	end
  	local g = e:GetLabelObject()
  	if not g:IsExists(s.desfilter, 1, nil, fid) then
  		g:DeleteGroup()
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local fid, turnc = e:GetLabel()
  	local g = e:GetLabelObject()
  	local tg = g:Filter(s.desfilter, nil, fid)
  	Duel.Destroy(tg, REASON_EFFECT)
  end
  
  