name: Starry
card_text: Add 1 "Starry Knight" monster, or 1 Level 7 LIGHT Dragon monster, from your Deck to your hand, then, if you control no monsters and your opponent controls a DARK monster, you can Special Summon 1 Level 7 LIGHT Dragon monster from your hand. You can only activate 1 "Starry Knight Balefire" per turn.
external_ids: local SETCARD_ID_0 = 0x159 --Starry
  
lua: local SETCARD_ID_0 = 0x159 --Starry
  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:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsAbleToHand() and (c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) or c:IsRace(RACE_DRAGON) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsLevel(7))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_DARK)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_DRAGON) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsLevel(7) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		Duel.ShuffleHand(tp)
  		if
  			Duel.IsExistingMatchingCard(s.cfilter, tp, 0, LOCATION_MZONE, 1, nil)
  			and Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0
  			and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  		then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sg = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  			Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Starry
  Add 1 "Starry Knight" monster, or 1 Level 7 LIGHT Dragon monster, from your Deck to your hand, then, if you control no monsters and your opponent controls a DARK monster, you can Special Summon 1 Level 7 LIGHT Dragon monster from your hand. You can only activate 1 "Starry Knight Balefire" per turn.
target_text: -- Starry
  local SETCARD_ID_0 = 0x159 --Starry
  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:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsAbleToHand() and (c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) or c:IsRace(RACE_DRAGON) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsLevel(7))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_DARK)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_DRAGON) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsLevel(7) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		Duel.ShuffleHand(tp)
  		if
  			Duel.IsExistingMatchingCard(s.cfilter, tp, 0, LOCATION_MZONE, 1, nil)
  			and Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0
  			and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  		then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sg = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  			Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  