name: Zoodiac
card_text: 5 Level 4 monsters
  Once per turn, you can also Xyz Summon "Zoodiac Boarbow" by using 1 "Zoodiac" monster you control with a different name as material. (Transfer its materials to this card.) Gains ATK/DEF equal to the ATK/DEF of all "Zoodiac" monsters attached to it as material. This card can attack directly. When this card inflicts battle damage to your opponent while it has 12 or more materials: You can send as many cards as possible from your opponent's hand and field to the GY, then change this card to Defense Position.
external_ids: local SETCARD_ID_0 = 0xf1 --Zoodiac
  
lua: local SETCARD_ID_0 = 0xf1 --Zoodiac
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 5, s.ovfilter, aux.Stringid(id, 0), 5, s.xyzop)
  	c:EnableReviveLimit()
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	e2:SetValue(s.defval)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_DAMAGE)
  	e3:SetCondition(s.condition)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  	--direct attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e4)
  end
  function s.ovfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.xyzop(e, tp, chk)
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, EFFECT_FLAG_OATH, 1)
  end
  function s.atkfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:GetAttack() >= 0
  end
  function s.atkval(e, c)
  	local g = e:GetHandler():GetOverlayGroup():Filter(s.atkfilter, nil)
  	return g:GetSum(Card.GetAttack)
  end
  function s.deffilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:GetDefense() >= 0
  end
  function s.defval(e, c)
  	local g = e:GetHandler():GetOverlayGroup():Filter(s.deffilter, nil)
  	return g:GetSum(Card.GetDefense)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and e:GetHandler():GetOverlayCount() >= 12
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND + LOCATION_ONFIELD)
  	if chk == 0 then
  		return g:GetCount() > 0
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, g:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND + LOCATION_ONFIELD)
  	Duel.SendtoGrave(g, REASON_EFFECT)
  	local og = Duel.GetOperatedGroup()
  	if og:GetCount() > 0 then
  		Duel.BreakEffect()
  		local c = e:GetHandler()
  		if c:IsRelateToEffect(e) and c:IsFaceup() then
  			Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  		end
  	end
  end
  
  
source_text: Zoodiac
  5 Level 4 monsters
  Once per turn, you can also Xyz Summon "Zoodiac Boarbow" by using 1 "Zoodiac" monster you control with a different name as material. (Transfer its materials to this card.) Gains ATK/DEF equal to the ATK/DEF of all "Zoodiac" monsters attached to it as material. This card can attack directly. When this card inflicts battle damage to your opponent while it has 12 or more materials: You can send as many cards as possible from your opponent's hand and field to the GY, then change this card to Defense Position.
target_text: -- Zoodiac
  local SETCARD_ID_0 = 0xf1 --Zoodiac
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 5, s.ovfilter, aux.Stringid(id, 0), 5, s.xyzop)
  	c:EnableReviveLimit()
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	e2:SetValue(s.defval)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_DAMAGE)
  	e3:SetCondition(s.condition)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  	--direct attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e4)
  end
  function s.ovfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.xyzop(e, tp, chk)
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, EFFECT_FLAG_OATH, 1)
  end
  function s.atkfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:GetAttack() >= 0
  end
  function s.atkval(e, c)
  	local g = e:GetHandler():GetOverlayGroup():Filter(s.atkfilter, nil)
  	return g:GetSum(Card.GetAttack)
  end
  function s.deffilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:GetDefense() >= 0
  end
  function s.defval(e, c)
  	local g = e:GetHandler():GetOverlayGroup():Filter(s.deffilter, nil)
  	return g:GetSum(Card.GetDefense)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and e:GetHandler():GetOverlayCount() >= 12
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND + LOCATION_ONFIELD)
  	if chk == 0 then
  		return g:GetCount() > 0
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, g:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND + LOCATION_ONFIELD)
  	Duel.SendtoGrave(g, REASON_EFFECT)
  	local og = Duel.GetOperatedGroup()
  	if og:GetCount() > 0 then
  		Duel.BreakEffect()
  		local c = e:GetHandler()
  		if c:IsRelateToEffect(e) and c:IsFaceup() then
  			Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  		end
  	end
  end
  
  