name: G
card_text: 2+ EARTH monsters
  Co-linked monsters you control are unaffected by monster effects activated on your opponent's field. All monsters your opponent controls that can attack must attack this card. Once per turn: You can discard 1 Cyberse monster; draw 1 card. If this co-linked card is destroyed: You can negate the effects of all face-up cards your opponent currently controls.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkAttribute, ATTRIBUTE_EARTH), 2)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.indtg)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--must attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_MUST_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_MUST_ATTACK_MONSTER)
  	e3:SetValue(s.atklimit)
  	c:RegisterEffect(e3)
  	--draw
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_DRAW)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCost(s.drcost)
  	e4:SetTarget(s.drtg)
  	e4:SetOperation(s.drop)
  	c:RegisterEffect(e4)
  	--disable
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_DISABLE)
  	e5:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e5:SetCode(EVENT_DESTROYED)
  	e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e5:SetCondition(s.discon)
  	e5:SetTarget(s.distg)
  	e5:SetOperation(s.disop)
  	c:RegisterEffect(e5)
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e6:SetCode(EVENT_LEAVE_FIELD_P)
  	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e6:SetLabelObject(e5)
  	e6:SetOperation(s.chk)
  	c:RegisterEffect(e6)
  end
  function s.indtg(e, c)
  	return c:GetMutualLinkedGroupCount() > 0
  end
  function s.efilter(e, te, ev)
  	return te:IsActiveType(TYPE_MONSTER) and te:GetOwnerPlayer() ~= e:GetHandlerPlayer() and Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION) == LOCATION_MZONE
  end
  function s.atklimit(e, c)
  	return c == e:GetHandler()
  end
  function s.costfilter(c)
  	return c:IsRace(RACE_CYBERSE) and c:IsDiscardable()
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.costfilter, 1, 1, REASON_DISCARD + REASON_COST)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  function s.chk(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():SetLabel(e:GetHandler():GetMutualLinkedGroupCount())
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabel() > 0
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_ONFIELD, nil)
  	local tc = g:GetFirst()
  	local c = e:GetHandler()
  	while tc do
  		Duel.NegateRelatedChain(tc, RESET_TURN_SET)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetValue(RESET_TURN_SET)
  		tc:RegisterEffect(e2)
  		tc = g:GetNext()
  	end
  end
  
  
source_text: G
  2+ EARTH monsters
  Co-linked monsters you control are unaffected by monster effects activated on your opponent's field. All monsters your opponent controls that can attack must attack this card. Once per turn: You can discard 1 Cyberse monster; draw 1 card. If this co-linked card is destroyed: You can negate the effects of all face-up cards your opponent currently controls.
target_text: -- G
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkAttribute, ATTRIBUTE_EARTH), 2)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.indtg)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--must attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_MUST_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_MUST_ATTACK_MONSTER)
  	e3:SetValue(s.atklimit)
  	c:RegisterEffect(e3)
  	--draw
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_DRAW)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCost(s.drcost)
  	e4:SetTarget(s.drtg)
  	e4:SetOperation(s.drop)
  	c:RegisterEffect(e4)
  	--disable
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_DISABLE)
  	e5:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e5:SetCode(EVENT_DESTROYED)
  	e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e5:SetCondition(s.discon)
  	e5:SetTarget(s.distg)
  	e5:SetOperation(s.disop)
  	c:RegisterEffect(e5)
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e6:SetCode(EVENT_LEAVE_FIELD_P)
  	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e6:SetLabelObject(e5)
  	e6:SetOperation(s.chk)
  	c:RegisterEffect(e6)
  end
  function s.indtg(e, c)
  	return c:GetMutualLinkedGroupCount() > 0
  end
  function s.efilter(e, te, ev)
  	return te:IsActiveType(TYPE_MONSTER) and te:GetOwnerPlayer() ~= e:GetHandlerPlayer() and Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION) == LOCATION_MZONE
  end
  function s.atklimit(e, c)
  	return c == e:GetHandler()
  end
  function s.costfilter(c)
  	return c:IsRace(RACE_CYBERSE) and c:IsDiscardable()
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.costfilter, 1, 1, REASON_DISCARD + REASON_COST)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  function s.chk(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():SetLabel(e:GetHandler():GetMutualLinkedGroupCount())
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabel() > 0
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_ONFIELD, nil)
  	local tc = g:GetFirst()
  	local c = e:GetHandler()
  	while tc do
  		Duel.NegateRelatedChain(tc, RESET_TURN_SET)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetValue(RESET_TURN_SET)
  		tc:RegisterEffect(e2)
  		tc = g:GetNext()
  	end
  end
  
  