name: Vanquish
card_text: Pay 500 LP, then target 1 "Vanquish Soul" monster in your GY; either add it to your hand or Special Summon it in Defense Position. You can only activate 1 "Vanquish Soul - Continue?" per turn.
external_ids: local SETCARD_ID_0 = 0x195 --Vanquish
  
lua: local SETCARD_ID_0 = 0x195 --Vanquish
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_ACTION + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(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.filter(c, e, tp, ft)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp, ft)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, ft)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if aux.NecroValleyNegateCheck(tc) then
  			return
  		end
  		if not aux.NecroValleyFilter()(tc) then
  			return
  		end
  		if
  			Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  			and (not tc:IsAbleToHand() or Duel.SelectOption(tp, 1190, 1152) == 1)
  		then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		else
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Vanquish
  Pay 500 LP, then target 1 "Vanquish Soul" monster in your GY; either add it to your hand or Special Summon it in Defense Position. You can only activate 1 "Vanquish Soul - Continue?" per turn.
target_text: -- Vanquish
  local SETCARD_ID_0 = 0x195 --Vanquish
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_ACTION + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(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.filter(c, e, tp, ft)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp, ft)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, ft)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if aux.NecroValleyNegateCheck(tc) then
  			return
  		end
  		if not aux.NecroValleyFilter()(tc) then
  			return
  		end
  		if
  			Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  			and (not tc:IsAbleToHand() or Duel.SelectOption(tp, 1190, 1152) == 1)
  		then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		else
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  
  