name: Lullaby
card_text: Pay 2000 LP and declare 1 Monster Card name; your opponent looks at their Deck, reveals 1 of the declared monsters if there is any, and chooses 1 of these effects to be applied.
  ● The declared monster is added to the hand of the player who activated this card.
  ● The player who activated this card Special Summons the declared monster to their field in Attack Position, ignoring its Summoning conditions.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	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, 2000)
  	end
  	Duel.PayLPCost(tp, 2000)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToHand, tp, 0, LOCATION_DECK, 1, nil) or Duel.IsPlayerCanSpecialSummon(tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CODE)
  	getmetatable(e:GetHandler()).announce_filter = { TYPE_MONSTER, OPCODE_ISTYPE, TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK, OPCODE_ISTYPE, OPCODE_NOT, OPCODE_AND }
  	local ac = Duel.AnnounceCard(tp, table.unpack(getmetatable(e:GetHandler()).announce_filter))
  	Duel.SetTargetParam(ac)
  	Duel.SetOperationInfo(0, CATEGORY_ANNOUNCE, nil, 0, tp, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ac = Duel.GetChainInfo(0, CHAININFO_TARGET_PARAM)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_DECK)
  	if g:GetCount() < 1 then
  		return
  	end
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_CONFIRM)
  	local sg = g:FilterSelect(1 - tp, Card.IsCode, 1, 1, nil, ac)
  	local tc = sg:GetFirst()
  	if tc then
  		Duel.ConfirmCards(tp, sg)
  		local b1 = tc:IsAbleToHand()
  		local b2 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, true, false, POS_FACEUP_ATTACK, tp)
  		local sel = 0
  		if b1 and b2 then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_OPTION)
  			sel = Duel.SelectOption(1 - tp, aux.Stringid(id, 0), aux.Stringid(id, 1)) + 1
  		elseif b1 then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_OPTION)
  			sel = Duel.SelectOption(1 - tp, aux.Stringid(id, 0)) + 1
  		elseif b2 then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_OPTION)
  			sel = Duel.SelectOption(1 - tp, aux.Stringid(id, 1)) + 2
  		end
  		if sel == 1 then
  			Duel.SendtoHand(sg, tp, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, sg)
  		elseif sel == 2 then
  			Duel.SpecialSummon(sg, 0, tp, tp, true, false, POS_FACEUP_ATTACK)
  		end
  	end
  	Duel.ShuffleDeck(1 - tp)
  end
  
  
source_text: Lullaby
  Pay 2000 LP and declare 1 Monster Card name; your opponent looks at their Deck, reveals 1 of the declared monsters if there is any, and chooses 1 of these effects to be applied.
  ● The declared monster is added to the hand of the player who activated this card.
  ● The player who activated this card Special Summons the declared monster to their field in Attack Position, ignoring its Summoning conditions.
target_text: -- Lullaby
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	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, 2000)
  	end
  	Duel.PayLPCost(tp, 2000)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToHand, tp, 0, LOCATION_DECK, 1, nil) or Duel.IsPlayerCanSpecialSummon(tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CODE)
  	getmetatable(e:GetHandler()).announce_filter = { TYPE_MONSTER, OPCODE_ISTYPE, TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK, OPCODE_ISTYPE, OPCODE_NOT, OPCODE_AND }
  	local ac = Duel.AnnounceCard(tp, table.unpack(getmetatable(e:GetHandler()).announce_filter))
  	Duel.SetTargetParam(ac)
  	Duel.SetOperationInfo(0, CATEGORY_ANNOUNCE, nil, 0, tp, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ac = Duel.GetChainInfo(0, CHAININFO_TARGET_PARAM)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_DECK)
  	if g:GetCount() < 1 then
  		return
  	end
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_CONFIRM)
  	local sg = g:FilterSelect(1 - tp, Card.IsCode, 1, 1, nil, ac)
  	local tc = sg:GetFirst()
  	if tc then
  		Duel.ConfirmCards(tp, sg)
  		local b1 = tc:IsAbleToHand()
  		local b2 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, true, false, POS_FACEUP_ATTACK, tp)
  		local sel = 0
  		if b1 and b2 then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_OPTION)
  			sel = Duel.SelectOption(1 - tp, aux.Stringid(id, 0), aux.Stringid(id, 1)) + 1
  		elseif b1 then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_OPTION)
  			sel = Duel.SelectOption(1 - tp, aux.Stringid(id, 0)) + 1
  		elseif b2 then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_OPTION)
  			sel = Duel.SelectOption(1 - tp, aux.Stringid(id, 1)) + 2
  		end
  		if sel == 1 then
  			Duel.SendtoHand(sg, tp, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, sg)
  		elseif sel == 2 then
  			Duel.SpecialSummon(sg, 0, tp, tp, true, false, POS_FACEUP_ATTACK)
  		end
  	end
  	Duel.ShuffleDeck(1 - tp)
  end
  
  