name: Scareclaw
card_text: Target 1 "Primitive Planet Reichphobia" you control or in your GY; return it to the hand, then, if you control "Visas Starfrost", you can change 1 face-up monster your opponent controls to face-down Defense Position. If 3 or more Defense Position monsters are on the field: You can banish this card from your GY; add 1 "Scareclaw" card from your GY to your hand. You can only use this effect of "Scareclaw Decline" once per turn.
external_ids: local CARD_ID_0 = 56063182 --Primitive Planet Reichphobia
  local CARD_ID_1 = 56099748 --Visas Starfrost
  local SETCARD_ID_0 = 0x17a --Scareclaw
  
lua: local CARD_ID_0 = 56063182 --Primitive Planet Reichphobia
  local CARD_ID_1 = 56099748 --Visas Starfrost
  local SETCARD_ID_0 = 0x17a --Scareclaw
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_POSITION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.thcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsCode(CARD_ID_0) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_ONFIELD + LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.actcfilter(c, tp)
  	return c:IsFaceup() and c:IsCode(CARD_ID_1)
  end
  function s.actfilter(c, tp)
  	return c:IsFaceup() and c:IsCanTurnSet()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if
  		tc:IsRelateToEffect(e)
  		and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0
  		and tc:IsLocation(LOCATION_HAND)
  		and Duel.IsExistingMatchingCard(s.actcfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  		and Duel.IsExistingMatchingCard(s.actfilter, tp, 0, LOCATION_MZONE, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  		local g = Duel.SelectMatchingCard(tp, s.actfilter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  		if #g > 0 then
  			Duel.BreakEffect()
  			Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
  		end
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsDefensePos, tp, LOCATION_MZONE, LOCATION_MZONE, 3, nil)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_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, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Scareclaw
  Target 1 "Primitive Planet Reichphobia" you control or in your GY; return it to the hand, then, if you control "Visas Starfrost", you can change 1 face-up monster your opponent controls to face-down Defense Position. If 3 or more Defense Position monsters are on the field: You can banish this card from your GY; add 1 "Scareclaw" card from your GY to your hand. You can only use this effect of "Scareclaw Decline" once per turn.
target_text: -- Scareclaw
  local CARD_ID_0 = 56063182 --Primitive Planet Reichphobia
  local CARD_ID_1 = 56099748 --Visas Starfrost
  local SETCARD_ID_0 = 0x17a --Scareclaw
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_POSITION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.thcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsCode(CARD_ID_0) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_ONFIELD + LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.actcfilter(c, tp)
  	return c:IsFaceup() and c:IsCode(CARD_ID_1)
  end
  function s.actfilter(c, tp)
  	return c:IsFaceup() and c:IsCanTurnSet()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if
  		tc:IsRelateToEffect(e)
  		and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0
  		and tc:IsLocation(LOCATION_HAND)
  		and Duel.IsExistingMatchingCard(s.actcfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  		and Duel.IsExistingMatchingCard(s.actfilter, tp, 0, LOCATION_MZONE, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  		local g = Duel.SelectMatchingCard(tp, s.actfilter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  		if #g > 0 then
  			Duel.BreakEffect()
  			Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
  		end
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsDefensePos, tp, LOCATION_MZONE, LOCATION_MZONE, 3, nil)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_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, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  	end
  end
  
  