name: Scrap
card_text: Target 1 "Junk Warrior" you control; if it battles an opponent's monster this turn while you control it, apply these effects.
  ● Your opponent cannot activate cards or effects until the end of the Damage Step.
  ● If it attacks a Defense Position monster, inflict piercing battle damage to your opponent.
  ● Double any battle damage your opponent takes.
  ● It cannot be destroyed by battle.
  ● Destroy the opponent's monster that battled it at the end of the Damage Step.
external_ids: local CARD_ID_0 = 60800381 --Junk Warrior
  
lua: local CARD_ID_0 = 60800381 --Junk Warrior
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() < PHASE_MAIN2
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0) and c:GetFlagEffect(id) == 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if tc:GetFlagEffect(id) == 0 then
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_FIELD)
  			e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  			e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  			e1:SetRange(LOCATION_MZONE)
  			e1:SetTargetRange(0, 1)
  			e1:SetCondition(s.actcon)
  			e1:SetValue(1)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1, true)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_PIERCE)
  			e2:SetCondition(s.effcon)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e2)
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
  			e3:SetCondition(s.damcon)
  			e3:SetValue(aux.ChangeBattleDamage(1, DOUBLE_DAMAGE))
  			e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e3, true)
  			local e4 = Effect.CreateEffect(c)
  			e4:SetType(EFFECT_TYPE_SINGLE)
  			e4:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  			e4:SetCondition(s.effcon)
  			e4:SetValue(1)
  			e4:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e4)
  		end
  		local e5 = Effect.CreateEffect(c)
  		e5:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  		e5:SetCode(EVENT_DAMAGE_STEP_END)
  		e5:SetCondition(s.descon)
  		e5:SetOperation(s.desop)
  		e5:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e5, true)
  	end
  end
  function s.actcon(e)
  	local c = e:GetHandler()
  	return (Duel.GetAttacker() == c or Duel.GetAttackTarget() == c) and c:GetBattleTarget() ~= nil and e:GetOwnerPlayer() == e:GetHandlerPlayer()
  end
  function s.effcon(e)
  	return e:GetOwnerPlayer() == e:GetHandlerPlayer()
  end
  function s.damcon(e)
  	return e:GetHandler():GetBattleTarget() ~= nil
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetBattleTarget()
  	return tc and tc:IsRelateToBattle() and e:GetOwnerPlayer() == tp
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetBattleTarget()
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Destroy(tc, REASON_EFFECT)
  end
  
  
source_text: Scrap
  Target 1 "Junk Warrior" you control; if it battles an opponent's monster this turn while you control it, apply these effects.
  ● Your opponent cannot activate cards or effects until the end of the Damage Step.
  ● If it attacks a Defense Position monster, inflict piercing battle damage to your opponent.
  ● Double any battle damage your opponent takes.
  ● It cannot be destroyed by battle.
  ● Destroy the opponent's monster that battled it at the end of the Damage Step.
target_text: -- Scrap
  local CARD_ID_0 = 60800381 --Junk Warrior
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() < PHASE_MAIN2
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0) and c:GetFlagEffect(id) == 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if tc:GetFlagEffect(id) == 0 then
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_FIELD)
  			e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  			e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  			e1:SetRange(LOCATION_MZONE)
  			e1:SetTargetRange(0, 1)
  			e1:SetCondition(s.actcon)
  			e1:SetValue(1)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1, true)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_PIERCE)
  			e2:SetCondition(s.effcon)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e2)
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
  			e3:SetCondition(s.damcon)
  			e3:SetValue(aux.ChangeBattleDamage(1, DOUBLE_DAMAGE))
  			e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e3, true)
  			local e4 = Effect.CreateEffect(c)
  			e4:SetType(EFFECT_TYPE_SINGLE)
  			e4:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  			e4:SetCondition(s.effcon)
  			e4:SetValue(1)
  			e4:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e4)
  		end
  		local e5 = Effect.CreateEffect(c)
  		e5:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  		e5:SetCode(EVENT_DAMAGE_STEP_END)
  		e5:SetCondition(s.descon)
  		e5:SetOperation(s.desop)
  		e5:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e5, true)
  	end
  end
  function s.actcon(e)
  	local c = e:GetHandler()
  	return (Duel.GetAttacker() == c or Duel.GetAttackTarget() == c) and c:GetBattleTarget() ~= nil and e:GetOwnerPlayer() == e:GetHandlerPlayer()
  end
  function s.effcon(e)
  	return e:GetOwnerPlayer() == e:GetHandlerPlayer()
  end
  function s.damcon(e)
  	return e:GetHandler():GetBattleTarget() ~= nil
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetBattleTarget()
  	return tc and tc:IsRelateToBattle() and e:GetOwnerPlayer() == tp
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetBattleTarget()
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Destroy(tc, REASON_EFFECT)
  end
  
  