name: Swordsoul
card_text: 1 Tuner + 1+ non-Tuner Wyrm monsters
  If you Synchro Summon another Wyrm monster, while this monster is on the field: You can draw 1 card. If your opponent Special Summons a monster(s) (except during the Damage Step): You can banish 1 of those monster(s), and if you do, inflict 1200 damage to your opponent. When your opponent activates a Spell/Trap Card or effect (Quick Effect): You can banish that card, and if you do, inflict 1200 damage to your opponent. You can only use each effect of "Swordsoul Sinister Sovereign - Qixing Longyuan" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(Card.IsRace, RACE_WYRM), 1)
  	c:EnableReviveLimit()
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	--remove monster
  	local custom_code = aux.RegisterMergedDelayedEvent_ToSingleCard(c, id, EVENT_SPSUMMON_SUCCESS)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE + CATEGORY_DAMAGE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(custom_code)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.remtg1)
  	e2:SetOperation(s.remop1)
  	c:RegisterEffect(e2)
  	--remove spell/trap
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_REMOVE + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.remcon2)
  	e3:SetTarget(s.remtg2)
  	e3:SetOperation(s.remop2)
  	c:RegisterEffect(e3)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	return eg:GetCount() == 1 and tc ~= e:GetHandler() and tc:IsSummonType(SUMMON_TYPE_SYNCHRO) and tc:IsSummonPlayer(tp) and tc:IsRace(RACE_WYRM)
  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 p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  function s.filter(c, e, tp)
  	return c:IsSummonPlayer(1 - tp) and c:IsLocation(LOCATION_MZONE) and c:IsAbleToRemove() and (not e or c:IsRelateToEffect(e))
  end
  function s.remtg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.filter, 1, nil, nil, tp)
  	end
  	local g = eg:Filter(s.filter, nil, nil, tp)
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 1200)
  end
  function s.remop1(e, tp, eg, ep, ev, re, r, rp)
  	local g = eg:Filter(s.filter, nil, e, tp)
  	local tc = g:GetFirst()
  	if not tc then
  		return
  	end
  	if g:GetCount() > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		tc = g:Select(tp, 1, 1, nil):GetFirst()
  	end
  	if Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and (tc:IsLocation(LOCATION_REMOVED) or tc:IsType(TYPE_TOKEN)) then
  		Duel.Damage(1 - tp, 1200, REASON_EFFECT)
  	end
  end
  function s.remcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return ep == 1 - tp and re:GetHandler():IsRelateToEffect(re) and re:IsActiveType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.remtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return re:GetHandler():IsAbleToRemove()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, eg, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 1200)
  end
  function s.remop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = re:GetHandler()
  	if tc:IsRelateToEffect(re) then
  		if Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_REMOVED) then
  			Duel.Damage(1 - tp, 1200, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Swordsoul
  1 Tuner + 1+ non-Tuner Wyrm monsters
  If you Synchro Summon another Wyrm monster, while this monster is on the field: You can draw 1 card. If your opponent Special Summons a monster(s) (except during the Damage Step): You can banish 1 of those monster(s), and if you do, inflict 1200 damage to your opponent. When your opponent activates a Spell/Trap Card or effect (Quick Effect): You can banish that card, and if you do, inflict 1200 damage to your opponent. You can only use each effect of "Swordsoul Sinister Sovereign - Qixing Longyuan" once per turn.
target_text: -- Swordsoul
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(Card.IsRace, RACE_WYRM), 1)
  	c:EnableReviveLimit()
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	--remove monster
  	local custom_code = aux.RegisterMergedDelayedEvent_ToSingleCard(c, id, EVENT_SPSUMMON_SUCCESS)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE + CATEGORY_DAMAGE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(custom_code)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.remtg1)
  	e2:SetOperation(s.remop1)
  	c:RegisterEffect(e2)
  	--remove spell/trap
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_REMOVE + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.remcon2)
  	e3:SetTarget(s.remtg2)
  	e3:SetOperation(s.remop2)
  	c:RegisterEffect(e3)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	return eg:GetCount() == 1 and tc ~= e:GetHandler() and tc:IsSummonType(SUMMON_TYPE_SYNCHRO) and tc:IsSummonPlayer(tp) and tc:IsRace(RACE_WYRM)
  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 p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  function s.filter(c, e, tp)
  	return c:IsSummonPlayer(1 - tp) and c:IsLocation(LOCATION_MZONE) and c:IsAbleToRemove() and (not e or c:IsRelateToEffect(e))
  end
  function s.remtg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.filter, 1, nil, nil, tp)
  	end
  	local g = eg:Filter(s.filter, nil, nil, tp)
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 1200)
  end
  function s.remop1(e, tp, eg, ep, ev, re, r, rp)
  	local g = eg:Filter(s.filter, nil, e, tp)
  	local tc = g:GetFirst()
  	if not tc then
  		return
  	end
  	if g:GetCount() > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		tc = g:Select(tp, 1, 1, nil):GetFirst()
  	end
  	if Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and (tc:IsLocation(LOCATION_REMOVED) or tc:IsType(TYPE_TOKEN)) then
  		Duel.Damage(1 - tp, 1200, REASON_EFFECT)
  	end
  end
  function s.remcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return ep == 1 - tp and re:GetHandler():IsRelateToEffect(re) and re:IsActiveType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.remtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return re:GetHandler():IsAbleToRemove()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, eg, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 1200)
  end
  function s.remop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = re:GetHandler()
  	if tc:IsRelateToEffect(re) then
  		if Duel.Remove(tc, POS_FACEUP, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_REMOVED) then
  			Duel.Damage(1 - tp, 1200, REASON_EFFECT)
  		end
  	end
  end
  
  