name: Dinowrestler
card_text: This Attack Position card cannot be destroyed by battle. If this card is attacked, change it to Defense Position at the end of the Damage Step. During the Standby Phase, if this card is in Defense Position: You can Special Summon 1 "Dinowrestler Capoeiraptor" from your Deck. You can only use this effect of "Dinowrestler Capoeiraptor" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetValue(1)
  	e1:SetCondition(s.indcon)
  	c:RegisterEffect(e1)
  	--position
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_POSITION)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_DAMAGE_STEP_END)
  	e2:SetCondition(s.poscon)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.indcon(e)
  	return e:GetHandler():IsAttackPos()
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler() == Duel.GetAttackTarget() and e:GetHandler():IsRelateToBattle()
  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
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsDefensePos()
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Dinowrestler
  This Attack Position card cannot be destroyed by battle. If this card is attacked, change it to Defense Position at the end of the Damage Step. During the Standby Phase, if this card is in Defense Position: You can Special Summon 1 "Dinowrestler Capoeiraptor" from your Deck. You can only use this effect of "Dinowrestler Capoeiraptor" once per turn.
target_text: -- Dinowrestler
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetValue(1)
  	e1:SetCondition(s.indcon)
  	c:RegisterEffect(e1)
  	--position
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_POSITION)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_DAMAGE_STEP_END)
  	e2:SetCondition(s.poscon)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.indcon(e)
  	return e:GetHandler():IsAttackPos()
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler() == Duel.GetAttackTarget() and e:GetHandler():IsRelateToBattle()
  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
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsDefensePos()
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  