name: Evil★Twin
card_text: 1 "Ki-sikil" monster
  You can only Link Summon "Evil★Twin Ki-sikil Deal" once per turn. You can send 1 "Lil-la" monster from your Deck or Extra Deck to the GY; apply this effect this turn.
  ● Each time your opponent activates a card or effect in response to your "Ki-sikil" or "Lil-la" monster effect activation, draw 1 card when that card/effect resolves.
  You can only use this effect of "Evil★Twin Ki-sikil Deal" once per turn.
external_ids: local SETCARD_ID_0 = 0x152 --Ki-sikil
  local SETCARD_ID_1 = 0x153 --Lil-la
  
lua: local SETCARD_ID_0 = 0x152 --Ki-sikil
  local SETCARD_ID_1 = 0x153 --Lil-la
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, s.matfilter, 1, 1)
  	--splimit
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e0:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e0:SetCondition(s.condition)
  	e0:SetOperation(s.regop)
  	c:RegisterEffect(e0)
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.matfilter(c)
  	return c:IsLinkSetCard(SETCARD_ID_1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsCode(id) and bit.band(sumtype, SUMMON_TYPE_LINK) == SUMMON_TYPE_LINK
  end
  function s.costfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAIN_SOLVED)
  	e1:SetCondition(s.drcon)
  	e1:SetOperation(s.drop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsChainDisablable(ev) then
  		return false
  	end
  	local te, p = Duel.GetChainInfo(ev - 1, CHAININFO_TRIGGERING_EFFECT, CHAININFO_TRIGGERING_PLAYER)
  	local tc = te:GetHandler()
  	return te and tc:IsSetCard(SETCARD_ID_1, 0x153) and te:IsActiveType(TYPE_MONSTER) and p == tp and rp == 1 - tp
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Draw(tp, 1, REASON_EFFECT)
  end
  
  
source_text: Evil★Twin
  1 "Ki-sikil" monster
  You can only Link Summon "Evil★Twin Ki-sikil Deal" once per turn. You can send 1 "Lil-la" monster from your Deck or Extra Deck to the GY; apply this effect this turn.
  ● Each time your opponent activates a card or effect in response to your "Ki-sikil" or "Lil-la" monster effect activation, draw 1 card when that card/effect resolves.
  You can only use this effect of "Evil★Twin Ki-sikil Deal" once per turn.
target_text: -- Evil★Twin
  local SETCARD_ID_0 = 0x152 --Ki-sikil
  local SETCARD_ID_1 = 0x153 --Lil-la
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, s.matfilter, 1, 1)
  	--splimit
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e0:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e0:SetCondition(s.condition)
  	e0:SetOperation(s.regop)
  	c:RegisterEffect(e0)
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.matfilter(c)
  	return c:IsLinkSetCard(SETCARD_ID_1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsCode(id) and bit.band(sumtype, SUMMON_TYPE_LINK) == SUMMON_TYPE_LINK
  end
  function s.costfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAIN_SOLVED)
  	e1:SetCondition(s.drcon)
  	e1:SetOperation(s.drop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsChainDisablable(ev) then
  		return false
  	end
  	local te, p = Duel.GetChainInfo(ev - 1, CHAININFO_TRIGGERING_EFFECT, CHAININFO_TRIGGERING_PLAYER)
  	local tc = te:GetHandler()
  	return te and tc:IsSetCard(SETCARD_ID_1, 0x153) and te:IsActiveType(TYPE_MONSTER) and p == tp and rp == 1 - tp
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Draw(tp, 1, REASON_EFFECT)
  end
  
  