name: Submarineroid
card_text: This card can attack your opponent directly, but when it does so using this effect, the battle damage inflicted to your opponent is the original ATK of this card. At the end of the Damage Step, if this card battled: You can change this card to Defense Position.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e1)
  	--damage reduce
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
  	e2:SetCondition(s.rdcon)
  	e2:SetValue(s.rval)
  	c:RegisterEffect(e2)
  	--pos
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_POSITION)
  	e3:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_SINGLE)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetCondition(s.poscon)
  	e3:SetOperation(s.posop)
  	c:RegisterEffect(e3)
  end
  function s.rdcon(e)
  	local c = e:GetHandler()
  	local tp = e:GetHandlerPlayer()
  	return Duel.GetAttackTarget() == nil and c:GetEffectCount(EFFECT_DIRECT_ATTACK) < 2 and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  end
  function s.rval(e, damp)
  	if damp == 1 - e:GetHandlerPlayer() then
  		return e:GetHandler():GetBaseAttack()
  	else
  		return -1
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsRelateToBattle() and c:IsAttackPos()
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.ChangePosition(e:GetHandler(), POS_FACEUP_DEFENSE)
  	end
  end
  
  
source_text: Submarineroid
  This card can attack your opponent directly, but when it does so using this effect, the battle damage inflicted to your opponent is the original ATK of this card. At the end of the Damage Step, if this card battled: You can change this card to Defense Position.
target_text: -- Submarineroid
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e1)
  	--damage reduce
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
  	e2:SetCondition(s.rdcon)
  	e2:SetValue(s.rval)
  	c:RegisterEffect(e2)
  	--pos
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_POSITION)
  	e3:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_SINGLE)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetCondition(s.poscon)
  	e3:SetOperation(s.posop)
  	c:RegisterEffect(e3)
  end
  function s.rdcon(e)
  	local c = e:GetHandler()
  	local tp = e:GetHandlerPlayer()
  	return Duel.GetAttackTarget() == nil and c:GetEffectCount(EFFECT_DIRECT_ATTACK) < 2 and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  end
  function s.rval(e, damp)
  	if damp == 1 - e:GetHandlerPlayer() then
  		return e:GetHandler():GetBaseAttack()
  	else
  		return -1
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsRelateToBattle() and c:IsAttackPos()
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.ChangePosition(e:GetHandler(), POS_FACEUP_DEFENSE)
  	end
  end
  
  