name: Crystolic
card_text: All "Crystron" monsters you control gain 300 ATK and DEF. Once per turn, during the End Phase: You can draw cards equal to the number of "Crystron" Synchro Monsters you Synchro Summoned this turn.
external_ids: local SETCARD_ID_0 = 0xea --Crystron
  
lua: local SETCARD_ID_0 = 0xea --Crystron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk&def
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetValue(300)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	--draw
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_DRAW)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCode(EVENT_PHASE + PHASE_END)
  	e4:SetRange(LOCATION_FZONE)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.drcon)
  	e4:SetTarget(s.drtg)
  	e4:SetOperation(s.drop)
  	c:RegisterEffect(e4)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = 0
  		s[1] = 0
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_SPSUMMON_SUCCESS)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_PHASE_START + PHASE_DRAW)
  		ge2:SetOperation(s.clearop)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		if tc:IsSetCard(SETCARD_ID_0) and tc:IsSummonType(SUMMON_TYPE_SYNCHRO) then
  			local p = tc:GetSummonPlayer()
  			s[p] = s[p] + 1
  		end
  		tc = eg:GetNext()
  	end
  end
  function s.clearop(e, tp, eg, ep, ev, re, r, rp)
  	s[0] = 0
  	s[1] = 0
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return s[tp] > 0
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, s[tp])
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, s[tp])
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Draw(tp, s[tp], REASON_EFFECT)
  end
  
  
source_text: Crystolic
  All "Crystron" monsters you control gain 300 ATK and DEF. Once per turn, during the End Phase: You can draw cards equal to the number of "Crystron" Synchro Monsters you Synchro Summoned this turn.
target_text: -- Crystolic
  local SETCARD_ID_0 = 0xea --Crystron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk&def
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetValue(300)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	--draw
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_DRAW)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCode(EVENT_PHASE + PHASE_END)
  	e4:SetRange(LOCATION_FZONE)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.drcon)
  	e4:SetTarget(s.drtg)
  	e4:SetOperation(s.drop)
  	c:RegisterEffect(e4)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = 0
  		s[1] = 0
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_SPSUMMON_SUCCESS)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_PHASE_START + PHASE_DRAW)
  		ge2:SetOperation(s.clearop)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		if tc:IsSetCard(SETCARD_ID_0) and tc:IsSummonType(SUMMON_TYPE_SYNCHRO) then
  			local p = tc:GetSummonPlayer()
  			s[p] = s[p] + 1
  		end
  		tc = eg:GetNext()
  	end
  end
  function s.clearop(e, tp, eg, ep, ev, re, r, rp)
  	s[0] = 0
  	s[1] = 0
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return s[tp] > 0
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, s[tp])
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, s[tp])
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Draw(tp, s[tp], REASON_EFFECT)
  end
  
  