name: Decode
card_text: 2+ Cyberse monsters with different Attributes
  Gains 500 ATK for each monster it points to. (Quick Effect): You can pay 1000 LP; draw 1 card, then if your LP are 2000 or less, you can apply this effect.
  ● Banish this card from the field, and if you do, Special Summon 1 Link-3 or lower Cyberse monster from your Extra Deck, except "Decode Talker Heatsoul".
  You can only use this effect of "Decode Talker Heatsoul" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_CYBERSE), 2, 3, s.lcheck)
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DRAW + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMING_MAIN_END + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.drcost)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  end
  function s.lcheck(g)
  	return g:GetClassCount(Card.GetLinkAttribute) == g:GetCount()
  end
  function s.atkval(e, c)
  	return c:GetLinkedGroupCount() * 500
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.cfilter(c, e, tp, mc)
  	return c:IsRace(RACE_CYBERSE)
  		and c:IsType(TYPE_LINK)
  		and c:IsLinkBelow(3)
  		and not c:IsCode(id)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	if
  		Duel.Draw(p, d, REASON_EFFECT) ~= 0
  		and Duel.GetLP(tp) <= 2000
  		and c:IsRelateToEffect(e)
  		and c:IsAbleToRemove()
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.BreakEffect()
  		if Duel.Remove(c, POS_FACEUP, REASON_EFFECT) ~= 0 and c:IsLocation(LOCATION_REMOVED) then
  			local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp)
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Decode
  2+ Cyberse monsters with different Attributes
  Gains 500 ATK for each monster it points to. (Quick Effect): You can pay 1000 LP; draw 1 card, then if your LP are 2000 or less, you can apply this effect.
  ● Banish this card from the field, and if you do, Special Summon 1 Link-3 or lower Cyberse monster from your Extra Deck, except "Decode Talker Heatsoul".
  You can only use this effect of "Decode Talker Heatsoul" once per turn.
target_text: -- Decode
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_CYBERSE), 2, 3, s.lcheck)
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DRAW + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMING_MAIN_END + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.drcost)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  end
  function s.lcheck(g)
  	return g:GetClassCount(Card.GetLinkAttribute) == g:GetCount()
  end
  function s.atkval(e, c)
  	return c:GetLinkedGroupCount() * 500
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.cfilter(c, e, tp, mc)
  	return c:IsRace(RACE_CYBERSE)
  		and c:IsType(TYPE_LINK)
  		and c:IsLinkBelow(3)
  		and not c:IsCode(id)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	if
  		Duel.Draw(p, d, REASON_EFFECT) ~= 0
  		and Duel.GetLP(tp) <= 2000
  		and c:IsRelateToEffect(e)
  		and c:IsAbleToRemove()
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.BreakEffect()
  		if Duel.Remove(c, POS_FACEUP, REASON_EFFECT) ~= 0 and c:IsLocation(LOCATION_REMOVED) then
  			local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp)
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  