name: Gouki
card_text: 1 "Gouki" Link Monster + 1 Warrior, Dinosaur, or Cyberse monster
  If this card is Fusion Summoned: You can target cards on the field, up to the total Link Rating of the "Gouki" Link Monsters used as material; destroy them. If you used a Link-3 or higher monster as material, neither player can activate those cards or their effects in response to this effect's activation. You can only use this effect of "Gouki The Tyrant Ogre" once per turn. If this card battles, your opponent cannot activate card or effects until the end of the Damage Step.
external_ids: local SETCARD_ID_0 = 0xfc --Gouki
  
lua: local SETCARD_ID_0 = 0xfc --Gouki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, s.matfilter1, aux.FilterBoolFunction(Card.IsRace, RACE_WARRIOR + RACE_DINOSAUR + RACE_CYBERSE), true)
  	--mat check
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_MATERIAL_CHECK)
  	e0:SetValue(s.matcheck)
  	c:RegisterEffect(e0)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	e1:SetLabelObject(e0)
  	c:RegisterEffect(e1)
  	--actlimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(0, 1)
  	e2:SetValue(1)
  	e2:SetCondition(s.actcon)
  	c:RegisterEffect(e2)
  end
  function s.matfilter1(c)
  	return c:IsFusionType(TYPE_LINK) and c:IsFusionSetCard(SETCARD_ID_0)
  end
  function s.matcheck(e, c)
  	local ct = c:GetMaterial():Filter(Card.IsFusionSetCard, nil, 0xfc):GetSum(Card.GetLink)
  	local lim = 0
  	if c:GetMaterial():IsExists(s.limfilter, 1, nil) then
  		lim = 1
  	end
  	e:SetLabel(ct, lim)
  end
  function s.limfilter(c)
  	return c:IsLinkAbove(3)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField()
  	end
  	local ct, lim = e:GetLabelObject():GetLabel()
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	if lim > 0 then
  		g:KeepAlive()
  		Duel.SetChainLimit(s.limit(g))
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(RESET_CHAIN)
  		e1:SetCountLimit(1)
  		e1:SetLabelObject(g)
  		e1:SetOperation(s.retop)
  		e1:SetReset(RESET_CHAIN)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.limit(g)
  	return function(e, lp, tp)
  		return not g:IsContains(e:GetHandler())
  	end
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():DeleteGroup()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToChain, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  function s.actcon(e)
  	return Duel.GetAttacker() == e:GetHandler() or Duel.GetAttackTarget() == e:GetHandler()
  end
  
  
source_text: Gouki
  1 "Gouki" Link Monster + 1 Warrior, Dinosaur, or Cyberse monster
  If this card is Fusion Summoned: You can target cards on the field, up to the total Link Rating of the "Gouki" Link Monsters used as material; destroy them. If you used a Link-3 or higher monster as material, neither player can activate those cards or their effects in response to this effect's activation. You can only use this effect of "Gouki The Tyrant Ogre" once per turn. If this card battles, your opponent cannot activate card or effects until the end of the Damage Step.
target_text: -- Gouki
  local SETCARD_ID_0 = 0xfc --Gouki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, s.matfilter1, aux.FilterBoolFunction(Card.IsRace, RACE_WARRIOR + RACE_DINOSAUR + RACE_CYBERSE), true)
  	--mat check
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_MATERIAL_CHECK)
  	e0:SetValue(s.matcheck)
  	c:RegisterEffect(e0)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	e1:SetLabelObject(e0)
  	c:RegisterEffect(e1)
  	--actlimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(0, 1)
  	e2:SetValue(1)
  	e2:SetCondition(s.actcon)
  	c:RegisterEffect(e2)
  end
  function s.matfilter1(c)
  	return c:IsFusionType(TYPE_LINK) and c:IsFusionSetCard(SETCARD_ID_0)
  end
  function s.matcheck(e, c)
  	local ct = c:GetMaterial():Filter(Card.IsFusionSetCard, nil, 0xfc):GetSum(Card.GetLink)
  	local lim = 0
  	if c:GetMaterial():IsExists(s.limfilter, 1, nil) then
  		lim = 1
  	end
  	e:SetLabel(ct, lim)
  end
  function s.limfilter(c)
  	return c:IsLinkAbove(3)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField()
  	end
  	local ct, lim = e:GetLabelObject():GetLabel()
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	if lim > 0 then
  		g:KeepAlive()
  		Duel.SetChainLimit(s.limit(g))
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(RESET_CHAIN)
  		e1:SetCountLimit(1)
  		e1:SetLabelObject(g)
  		e1:SetOperation(s.retop)
  		e1:SetReset(RESET_CHAIN)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.limit(g)
  	return function(e, lp, tp)
  		return not g:IsContains(e:GetHandler())
  	end
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():DeleteGroup()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToChain, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  function s.actcon(e)
  	return Duel.GetAttacker() == e:GetHandler() or Duel.GetAttackTarget() == e:GetHandler()
  end
  
  