name: Batteryman
card_text: If all "Batteryman C"(s) you control are in Attack Position, all Machine-Type monsters you control gain 500 ATK for each "Batteryman C" you control. If all "Batteryman C"(s) you control are in Defense Position, all Machine-Type monsters you control gain 500 DEF for each "Batteryman C" you control.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk,def
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsRace, RACE_MACHINE))
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	e2:SetValue(s.defval)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsCode(id)
  end
  function s.atkval(e, c)
  	local g = Duel.GetMatchingGroup(s.filter, c:GetControler(), LOCATION_MZONE, 0, nil)
  	if g:IsExists(Card.IsDefensePos, 1, nil) then
  		return 0
  	end
  	return 500
  end
  function s.defval(e, c)
  	local g = Duel.GetMatchingGroup(s.filter, c:GetControler(), LOCATION_MZONE, 0, nil)
  	if g:IsExists(Card.IsAttackPos, 1, nil) then
  		return 0
  	end
  	return 500
  end
  
  
source_text: Batteryman
  If all "Batteryman C"(s) you control are in Attack Position, all Machine-Type monsters you control gain 500 ATK for each "Batteryman C" you control. If all "Batteryman C"(s) you control are in Defense Position, all Machine-Type monsters you control gain 500 DEF for each "Batteryman C" you control.
target_text: -- Batteryman
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk,def
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsRace, RACE_MACHINE))
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	e2:SetValue(s.defval)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsCode(id)
  end
  function s.atkval(e, c)
  	local g = Duel.GetMatchingGroup(s.filter, c:GetControler(), LOCATION_MZONE, 0, nil)
  	if g:IsExists(Card.IsDefensePos, 1, nil) then
  		return 0
  	end
  	return 500
  end
  function s.defval(e, c)
  	local g = Duel.GetMatchingGroup(s.filter, c:GetControler(), LOCATION_MZONE, 0, nil)
  	if g:IsExists(Card.IsAttackPos, 1, nil) then
  		return 0
  	end
  	return 500
  end
  
  