name: Ecole
card_text: If the turn player Summons exactly 1 monster: Destroy it, and if you do, the controller of that monster Special Summons 1 "Mask Token" (Spellcaster/DARK/Level 1/ATK ?/DEF ?) to their field, which cannot attack directly, with ATK/DEF equal to what the destroyed monster had on the field. You can only use this effect of "Ecole de Zone" once per turn. If this face-up card leaves the field, destroy all "Mask Tokens" on the field.
external_ids: local CARD_ID_0 = 60514626 --Mask Token
  
lua: local CARD_ID_0 = 60514626 --Mask Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--token
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetRange(LOCATION_FZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.tkcon)
  	e1:SetTarget(s.tktg)
  	e1:SetOperation(s.tkop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e4:SetCode(EVENT_LEAVE_FIELD_P)
  	e4:SetOperation(s.desop)
  	c:RegisterEffect(e4)
  end
  function s.tkcon(e, tp, eg, ep, ev, re, r, rp)
  	if #eg ~= 1 then
  		return false
  	end
  	local tc = eg:GetFirst()
  	return tc:IsSummonPlayer(Duel.GetTurnPlayer())
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local tc = eg:GetFirst()
  	Duel.SetTargetCard(eg)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, tc, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = eg:GetFirst()
  	local p = tc:GetControler()
  	if
  		tc:IsRelateToEffect(e)
  		and Duel.Destroy(tc, REASON_EFFECT) ~= 0
  		and Duel.GetLocationCount(p, LOCATION_MZONE) > 0
  		and Duel.IsPlayerCanSpecialSummonMonster(p, id + 1, 0, TYPES_TOKEN_MONSTER, -2, -2, 1, RACE_SPELLCASTER, ATTRIBUTE_DARK)
  	then
  		local atk = tc:GetPreviousAttackOnField()
  		local def = tc:GetPreviousDefenseOnField()
  		local token = Duel.CreateToken(tp, id + 1)
  		if Duel.SpecialSummonStep(token, 0, p, p, false, false, POS_FACEUP) then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_SET_ATTACK)
  			e1:SetValue(atk)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			token:RegisterEffect(e1)
  			local e2 = e1:Clone()
  			e2:SetCode(EFFECT_SET_DEFENSE)
  			e2:SetValue(def)
  			token:RegisterEffect(e2)
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  			e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  			token:RegisterEffect(e3)
  		end
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsFacedown() then
  		return
  	end
  	local g = Duel.GetMatchingGroup(Card.IsCode, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil, id + 1)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  
source_text: Ecole
  If the turn player Summons exactly 1 monster: Destroy it, and if you do, the controller of that monster Special Summons 1 "Mask Token" (Spellcaster/DARK/Level 1/ATK ?/DEF ?) to their field, which cannot attack directly, with ATK/DEF equal to what the destroyed monster had on the field. You can only use this effect of "Ecole de Zone" once per turn. If this face-up card leaves the field, destroy all "Mask Tokens" on the field.
target_text: -- Ecole
  local CARD_ID_0 = 60514626 --Mask Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--token
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetRange(LOCATION_FZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.tkcon)
  	e1:SetTarget(s.tktg)
  	e1:SetOperation(s.tkop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e4:SetCode(EVENT_LEAVE_FIELD_P)
  	e4:SetOperation(s.desop)
  	c:RegisterEffect(e4)
  end
  function s.tkcon(e, tp, eg, ep, ev, re, r, rp)
  	if #eg ~= 1 then
  		return false
  	end
  	local tc = eg:GetFirst()
  	return tc:IsSummonPlayer(Duel.GetTurnPlayer())
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local tc = eg:GetFirst()
  	Duel.SetTargetCard(eg)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, tc, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = eg:GetFirst()
  	local p = tc:GetControler()
  	if
  		tc:IsRelateToEffect(e)
  		and Duel.Destroy(tc, REASON_EFFECT) ~= 0
  		and Duel.GetLocationCount(p, LOCATION_MZONE) > 0
  		and Duel.IsPlayerCanSpecialSummonMonster(p, id + 1, 0, TYPES_TOKEN_MONSTER, -2, -2, 1, RACE_SPELLCASTER, ATTRIBUTE_DARK)
  	then
  		local atk = tc:GetPreviousAttackOnField()
  		local def = tc:GetPreviousDefenseOnField()
  		local token = Duel.CreateToken(tp, id + 1)
  		if Duel.SpecialSummonStep(token, 0, p, p, false, false, POS_FACEUP) then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_SET_ATTACK)
  			e1:SetValue(atk)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			token:RegisterEffect(e1)
  			local e2 = e1:Clone()
  			e2:SetCode(EFFECT_SET_DEFENSE)
  			e2:SetValue(def)
  			token:RegisterEffect(e2)
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  			e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  			token:RegisterEffect(e3)
  		end
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsFacedown() then
  		return
  	end
  	local g = Duel.GetMatchingGroup(Card.IsCode, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil, id + 1)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  