name: Swordsoul
card_text: Target 1 face-up monster you control; banish up to 5 "Swordsoul" cards and/or Wyrm monsters from your GY, and if you do, that monster gains 300 ATK for each card banished this way. If this card is banished: You can Special Summon 1 "Swordsoul Token" (Wyrm/Tuner/WATER/Level 4/ATK 0/DEF 0). While that Token is in the Monster Zone, the player who Summoned it cannot Special Summon monsters from the Extra Deck, except Synchro Monsters. You can only use each effect of "Swordsoul Assessment" once per turn.
external_ids: local CARD_ID_0 = 78836196 --Swordsoul Token
  local CARD_ID_1 = 20001444 --Swordsoul Token
  local SETCARD_ID_0 = 0x16b --Swordsoul
  
lua: local CARD_ID_0 = 78836196 --Swordsoul Token
  local CARD_ID_1 = 20001444 --Swordsoul Token
  local SETCARD_ID_0 = 0x16b --Swordsoul
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(aux.dscon)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--token
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_REMOVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return (c:IsSetCard(SETCARD_ID_0) or (c:IsType(TYPE_MONSTER) and c:IsRace(RACE_WYRM))) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil)
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() and g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg = g:Select(tp, 1, 5, nil)
  		local rc = Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(300 * rc)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 4, RACE_WYRM, ATTRIBUTE_WATER)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 4, RACE_WYRM, ATTRIBUTE_WATER) then
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetAbsoluteRange(tp, 1, 0)
  		e1:SetTarget(s.splimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		token:RegisterEffect(e1, true)
  		Duel.SpecialSummonComplete()
  	end
  end
  function s.splimit(e, c)
  	return not c:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
  end
  
  
source_text: Swordsoul
  Target 1 face-up monster you control; banish up to 5 "Swordsoul" cards and/or Wyrm monsters from your GY, and if you do, that monster gains 300 ATK for each card banished this way. If this card is banished: You can Special Summon 1 "Swordsoul Token" (Wyrm/Tuner/WATER/Level 4/ATK 0/DEF 0). While that Token is in the Monster Zone, the player who Summoned it cannot Special Summon monsters from the Extra Deck, except Synchro Monsters. You can only use each effect of "Swordsoul Assessment" once per turn.
target_text: -- Swordsoul
  local CARD_ID_0 = 78836196 --Swordsoul Token
  local CARD_ID_1 = 20001444 --Swordsoul Token
  local SETCARD_ID_0 = 0x16b --Swordsoul
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(aux.dscon)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--token
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_REMOVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return (c:IsSetCard(SETCARD_ID_0) or (c:IsType(TYPE_MONSTER) and c:IsRace(RACE_WYRM))) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil)
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() and g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg = g:Select(tp, 1, 5, nil)
  		local rc = Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(300 * rc)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 4, RACE_WYRM, ATTRIBUTE_WATER)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 4, RACE_WYRM, ATTRIBUTE_WATER) then
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetAbsoluteRange(tp, 1, 0)
  		e1:SetTarget(s.splimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		token:RegisterEffect(e1, true)
  		Duel.SpecialSummonComplete()
  	end
  end
  function s.splimit(e, c)
  	return not c:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
  end
  
  