name: Stronghold
card_text: If a Defense Position monster you control is attacked, you can send this card from your hand to the Graveyard during the Damage Step to have your attacked monster gain 1500 DEF until the End Phase.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--defup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local phase = Duel.GetCurrentPhase()
  	if phase ~= PHASE_DAMAGE or Duel.IsDamageCalculated() then
  		return false
  	end
  	local d = Duel.GetAttackTarget()
  	return d and d:IsControler(tp) and d:IsDefensePos()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	if not d:IsRelateToBattle() then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_DEFENSE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e1:SetValue(1500)
  	d:RegisterEffect(e1)
  end
  
  
source_text: Stronghold
  If a Defense Position monster you control is attacked, you can send this card from your hand to the Graveyard during the Damage Step to have your attacked monster gain 1500 DEF until the End Phase.
target_text: -- Stronghold
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--defup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local phase = Duel.GetCurrentPhase()
  	if phase ~= PHASE_DAMAGE or Duel.IsDamageCalculated() then
  		return false
  	end
  	local d = Duel.GetAttackTarget()
  	return d and d:IsControler(tp) and d:IsDefensePos()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	if not d:IsRelateToBattle() then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_DEFENSE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e1:SetValue(1500)
  	d:RegisterEffect(e1)
  end
  
  