name: Goblin
card_text: When this card declares an attack, your opponent cannot activate cards or effects. If this card attacks, it is changed to Defense Position at the end of the Battle Phase, and its battle position cannot be changed until the End Phase of your next turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--to defense
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.poscon)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetTargetRange(0, 1)
  	e1:SetValue(s.aclimit)
  	e1:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) or re:GetHandler():IsType(TYPE_MONSTER)
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsAttackPos() then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_CHANGE_POSITION)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 3)
  	c:RegisterEffect(e1)
  end
  
  
source_text: Goblin
  When this card declares an attack, your opponent cannot activate cards or effects. If this card attacks, it is changed to Defense Position at the end of the Battle Phase, and its battle position cannot be changed until the End Phase of your next turn.
target_text: -- Goblin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--to defense
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.poscon)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetTargetRange(0, 1)
  	e1:SetValue(s.aclimit)
  	e1:SetReset(RESET_CHAIN)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) or re:GetHandler():IsType(TYPE_MONSTER)
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsAttackPos() then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_CHANGE_POSITION)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 3)
  	c:RegisterEffect(e1)
  end
  
  