name: Wrecker
card_text: Once per turn, during the Standby Phase: You can pay 500 LP; send the top card of your Deck to the Graveyard, and if you do, this card gains ATK and DEF equal to that monster's Level x 200 if it was a monster. If this card in your possession is destroyed by your opponent's card (by battle or card effect) and sent to your Graveyard: You can add 1 monster with the lowest Level from your Graveyard to your hand (your choice, if tied).
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--deckdes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_FIELD)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.ddcost)
  	e1:SetTarget(s.ddtg)
  	e1:SetOperation(s.ddop)
  	c:RegisterEffect(e1)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.ddcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 500)
  	end
  	Duel.PayLPCost(tp, 500)
  end
  function s.ddtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeck(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, nil, 0, tp, 1)
  end
  function s.ddop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	Duel.DiscardDeck(tp, 1, REASON_EFFECT)
  	local c = e:GetHandler()
  	local tc = Duel.GetOperatedGroup():GetFirst()
  	if tc and c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsType(TYPE_MONSTER) and tc:IsLocation(LOCATION_GRAVE) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(tc:GetLevel() * 200)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_UPDATE_DEFENSE)
  		c:RegisterEffect(e2)
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousControler(tp) and rp == 1 - tp and c:IsReason(REASON_DESTROY)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:GetLevel() > 0 and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_GRAVE, 0, nil)
  	if #g == 0 then
  		return
  	end
  	local sg = g:GetMinGroup(Card.GetLevel)
  	if sg:GetCount() > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		sg = sg:Select(tp, 1, 1, nil)
  	end
  	Duel.SendtoHand(sg, nil, REASON_EFFECT)
  end
  
  
source_text: Wrecker
  Once per turn, during the Standby Phase: You can pay 500 LP; send the top card of your Deck to the Graveyard, and if you do, this card gains ATK and DEF equal to that monster's Level x 200 if it was a monster. If this card in your possession is destroyed by your opponent's card (by battle or card effect) and sent to your Graveyard: You can add 1 monster with the lowest Level from your Graveyard to your hand (your choice, if tied).
target_text: -- Wrecker
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--deckdes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_FIELD)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.ddcost)
  	e1:SetTarget(s.ddtg)
  	e1:SetOperation(s.ddop)
  	c:RegisterEffect(e1)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.ddcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 500)
  	end
  	Duel.PayLPCost(tp, 500)
  end
  function s.ddtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeck(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, nil, 0, tp, 1)
  end
  function s.ddop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	Duel.DiscardDeck(tp, 1, REASON_EFFECT)
  	local c = e:GetHandler()
  	local tc = Duel.GetOperatedGroup():GetFirst()
  	if tc and c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsType(TYPE_MONSTER) and tc:IsLocation(LOCATION_GRAVE) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(tc:GetLevel() * 200)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_UPDATE_DEFENSE)
  		c:RegisterEffect(e2)
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousControler(tp) and rp == 1 - tp and c:IsReason(REASON_DESTROY)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:GetLevel() > 0 and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_GRAVE, 0, nil)
  	if #g == 0 then
  		return
  	end
  	local sg = g:GetMinGroup(Card.GetLevel)
  	if sg:GetCount() > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		sg = sg:Select(tp, 1, 1, nil)
  	end
  	Duel.SendtoHand(sg, nil, REASON_EFFECT)
  end
  
  