name: Gogogo
card_text: While another "Gogogo" monster is on the field, your opponent's monsters cannot target "Gogogo" monsters for attacks, also your opponent cannot target "Gogogo" monsters on the field with card effects. An Xyz Monster that was Summoned using only this card and other "Gogogo" monsters as material gains this effect.
  ● When it is Xyz Summoned: You can target 1 face-up Attack Position monster your opponent controls; change it to Defense Position, and if you do, change its DEF to 0.
external_ids: local SETCARD_ID_0 = 0x59 --Gogogo
  
lua: local SETCARD_ID_0 = 0x59 --Gogogo
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--untargetable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetCondition(s.tgcon)
  	e1:SetValue(s.atlimit)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetCondition(s.tgcon)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--effect gain
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_BE_MATERIAL)
  	e3:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e3:SetCondition(s.effcon)
  	e3:SetOperation(s.effop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgcon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, e:GetHandler())
  end
  function s.atlimit(e, c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	local mg = e:GetHandler():GetReasonCard():GetMaterial()
  	return r == REASON_XYZ and mg:IsExists(Card.IsSetCard, mg:GetCount(), nil, 0x59)
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_POSITION + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.poscon)
  	e1:SetTarget(s.postg)
  	e1:SetOperation(s.posop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.filter(c)
  	return c:IsPosition(POS_FACEUP_ATTACK) and c:IsCanChangePosition()
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsDefensePos() or not tc:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.ChangePosition(tc, POS_FACEUP_DEFENSE) == 0 then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SET_DEFENSE_FINAL)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(0)
  	tc:RegisterEffect(e1)
  end
  
  
source_text: Gogogo
  While another "Gogogo" monster is on the field, your opponent's monsters cannot target "Gogogo" monsters for attacks, also your opponent cannot target "Gogogo" monsters on the field with card effects. An Xyz Monster that was Summoned using only this card and other "Gogogo" monsters as material gains this effect.
  ● When it is Xyz Summoned: You can target 1 face-up Attack Position monster your opponent controls; change it to Defense Position, and if you do, change its DEF to 0.
target_text: -- Gogogo
  local SETCARD_ID_0 = 0x59 --Gogogo
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--untargetable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetCondition(s.tgcon)
  	e1:SetValue(s.atlimit)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetCondition(s.tgcon)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--effect gain
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_BE_MATERIAL)
  	e3:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e3:SetCondition(s.effcon)
  	e3:SetOperation(s.effop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgcon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, e:GetHandler())
  end
  function s.atlimit(e, c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	local mg = e:GetHandler():GetReasonCard():GetMaterial()
  	return r == REASON_XYZ and mg:IsExists(Card.IsSetCard, mg:GetCount(), nil, 0x59)
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_POSITION + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.poscon)
  	e1:SetTarget(s.postg)
  	e1:SetOperation(s.posop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.filter(c)
  	return c:IsPosition(POS_FACEUP_ATTACK) and c:IsCanChangePosition()
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsDefensePos() or not tc:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.ChangePosition(tc, POS_FACEUP_DEFENSE) == 0 then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SET_DEFENSE_FINAL)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(0)
  	tc:RegisterEffect(e1)
  end
  
  