name: Scrap
card_text: Activate only during damage calculation, if a Defense Position "Scrap" monster on the field is being attacked. It gains 2000 DEF and is destroyed at the end of the Battle Phase.
external_ids: local SETCARD_ID_0 = 0x24 --Scrap
  
lua: local SETCARD_ID_0 = 0x24 --Scrap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	return d and d:IsDefensePos() and d:IsSetCard(SETCARD_ID_0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	if d:IsRelateToBattle() then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_DEFENSE)
  		e1:SetValue(2000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		d:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  		e2:SetCountLimit(1)
  		e2:SetOperation(s.desop)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_BATTLE)
  		d:RegisterEffect(e2)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  
  
source_text: Scrap
  Activate only during damage calculation, if a Defense Position "Scrap" monster on the field is being attacked. It gains 2000 DEF and is destroyed at the end of the Battle Phase.
target_text: -- Scrap
  local SETCARD_ID_0 = 0x24 --Scrap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	return d and d:IsDefensePos() and d:IsSetCard(SETCARD_ID_0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	if d:IsRelateToBattle() then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_DEFENSE)
  		e1:SetValue(2000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		d:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  		e2:SetCountLimit(1)
  		e2:SetOperation(s.desop)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_BATTLE)
  		d:RegisterEffect(e2)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  
  