name: Trickstar
card_text: 2 "Trickstar" monsters
  Each time a "Trickstar" monster(s) is Normal or Special Summoned to a zone(s) this card points to, gain 200 LP. You can discard 1 "Trickstar" card; both players draw 1 card, but if your LP was at least 2000 higher than your opponent's when this effect was activated, you draw 2 cards instead. You can only use this effect of "Trickstar Crimson Heart" once per 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, 2)
  	c:EnableReviveLimit()
  	--recover
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.reccon)
  	e1:SetOperation(s.recop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DRAW)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCost(s.drcost)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c, ec)
  	if c:IsLocation(LOCATION_MZONE) then
  		return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup() and ec:GetLinkedGroup():IsContains(c)
  	else
  		return c:IsPreviousSetCard(SETCARD_ID_0) and c:IsPreviousPosition(POS_FACEUP) and bit.extract(ec:GetLinkedZone(c:GetPreviousControler()), c:GetPreviousSequence()) ~= 0
  	end
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, e:GetHandler())
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Recover(tp, 200, REASON_EFFECT)
  end
  function s.costfilter(c)
  	return c:IsDiscardable() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.costfilter, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = 1
  	if Duel.GetLP(tp) >= Duel.GetLP(1 - tp) + 2000 then
  		ct = 2
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, ct) and Duel.IsPlayerCanDraw(1 - tp, 1)
  	end
  	e:SetLabel(ct)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, PLAYER_ALL, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Draw(tp, e:GetLabel(), REASON_EFFECT)
  	Duel.Draw(1 - tp, 1, REASON_EFFECT)
  end
  
  
source_text: Trickstar
  2 "Trickstar" monsters
  Each time a "Trickstar" monster(s) is Normal or Special Summoned to a zone(s) this card points to, gain 200 LP. You can discard 1 "Trickstar" card; both players draw 1 card, but if your LP was at least 2000 higher than your opponent's when this effect was activated, you draw 2 cards instead. You can only use this effect of "Trickstar Crimson Heart" once per 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, 2)
  	c:EnableReviveLimit()
  	--recover
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.reccon)
  	e1:SetOperation(s.recop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DRAW)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCost(s.drcost)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c, ec)
  	if c:IsLocation(LOCATION_MZONE) then
  		return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup() and ec:GetLinkedGroup():IsContains(c)
  	else
  		return c:IsPreviousSetCard(SETCARD_ID_0) and c:IsPreviousPosition(POS_FACEUP) and bit.extract(ec:GetLinkedZone(c:GetPreviousControler()), c:GetPreviousSequence()) ~= 0
  	end
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, e:GetHandler())
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Recover(tp, 200, REASON_EFFECT)
  end
  function s.costfilter(c)
  	return c:IsDiscardable() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.costfilter, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = 1
  	if Duel.GetLP(tp) >= Duel.GetLP(1 - tp) + 2000 then
  		ct = 2
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, ct) and Duel.IsPlayerCanDraw(1 - tp, 1)
  	end
  	e:SetLabel(ct)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, PLAYER_ALL, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Draw(tp, e:GetLabel(), REASON_EFFECT)
  	Duel.Draw(1 - tp, 1, REASON_EFFECT)
  end
  
  