name: Trickstar
card_text: 2+ "Trickstar" monsters
  When this card declares an attack while pointing to a "Trickstar" monster: You can target your banished "Trickstar" cards, up to the number of Link Monsters your opponent controls; add them to your hand, and if you do, this card gains 1000 ATK for each card added, until the end of this turn.
external_ids: local SETCARD_ID_0 = 0xfb --Trickstar
  
lua: local SETCARD_ID_0 = 0xfb --Trickstar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2)
  	c:EnableReviveLimit()
  	--tohand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  end
  function s.lkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetLinkedGroup():IsExists(s.lkfilter, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_REMOVED, 0, 1, nil) and Duel.IsExistingMatchingCard(Card.IsType, tp, 0, LOCATION_MZONE, 1, nil, TYPE_LINK)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local ct = Duel.GetMatchingGroupCount(Card.IsType, tp, 0, LOCATION_MZONE, nil, TYPE_LINK)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_REMOVED, 0, 1, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local rg = tg:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoHand(rg, nil, REASON_EFFECT)
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local og = Duel.GetOperatedGroup()
  		local ct = og:FilterCount(Card.IsLocation, nil, LOCATION_HAND)
  		if ct > 0 then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  			e1:SetValue(ct * 1000)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Trickstar
  2+ "Trickstar" monsters
  When this card declares an attack while pointing to a "Trickstar" monster: You can target your banished "Trickstar" cards, up to the number of Link Monsters your opponent controls; add them to your hand, and if you do, this card gains 1000 ATK for each card added, until the end of this turn.
target_text: -- Trickstar
  local SETCARD_ID_0 = 0xfb --Trickstar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2)
  	c:EnableReviveLimit()
  	--tohand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  end
  function s.lkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetLinkedGroup():IsExists(s.lkfilter, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_REMOVED, 0, 1, nil) and Duel.IsExistingMatchingCard(Card.IsType, tp, 0, LOCATION_MZONE, 1, nil, TYPE_LINK)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local ct = Duel.GetMatchingGroupCount(Card.IsType, tp, 0, LOCATION_MZONE, nil, TYPE_LINK)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_REMOVED, 0, 1, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local rg = tg:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoHand(rg, nil, REASON_EFFECT)
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local og = Duel.GetOperatedGroup()
  		local ct = og:FilterCount(Card.IsLocation, nil, LOCATION_HAND)
  		if ct > 0 then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  			e1:SetValue(ct * 1000)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  