name: Magicore
card_text: Cannot attack unless you control an "Adventurer Token". You can only use each of the following effects of "Magicore Warrior of the Relics" once per turn. If you control an "Adventurer Token": You can Special Summon this card from your hand. At the end of the Battle Phase, if your monster that mentions "Adventurer Token" battled: You can Set 1 Trap that mentions "Adventurer Token" directly from your Deck.
external_ids: local CARD_ID_0 = 3285552 --Adventurer Token
  
lua: local CARD_ID_0 = 3285552 --Adventurer Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--cannot atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_CANNOT_ATTACK)
  	e2:SetCondition(s.atkcon)
  	c:RegisterEffect(e2)
  	--set card
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.setcon)
  	e3:SetTarget(s.settg)
  	e3:SetOperation(s.setop)
  	c:RegisterEffect(e3)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_BATTLED)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  function s.check(c)
  	return c and aux.IsCodeListed(c, CARD_ID_0)
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local a, d = Duel.GetBattleMonster(0)
  	if s.check(a) then
  		Duel.RegisterFlagEffect(0, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  	if s.check(d) then
  		Duel.RegisterFlagEffect(1, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  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 e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.atkcon(e)
  	return not Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.setcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id) > 0
  end
  function s.setfilter(c)
  	return aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_TRAP) and c:IsSSetable()
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SSet(tp, g)
  	end
  end
  
  
source_text: Magicore
  Cannot attack unless you control an "Adventurer Token". You can only use each of the following effects of "Magicore Warrior of the Relics" once per turn. If you control an "Adventurer Token": You can Special Summon this card from your hand. At the end of the Battle Phase, if your monster that mentions "Adventurer Token" battled: You can Set 1 Trap that mentions "Adventurer Token" directly from your Deck.
target_text: -- Magicore
  local CARD_ID_0 = 3285552 --Adventurer Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--cannot atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_CANNOT_ATTACK)
  	e2:SetCondition(s.atkcon)
  	c:RegisterEffect(e2)
  	--set card
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.setcon)
  	e3:SetTarget(s.settg)
  	e3:SetOperation(s.setop)
  	c:RegisterEffect(e3)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_BATTLED)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  function s.check(c)
  	return c and aux.IsCodeListed(c, CARD_ID_0)
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local a, d = Duel.GetBattleMonster(0)
  	if s.check(a) then
  		Duel.RegisterFlagEffect(0, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  	if s.check(d) then
  		Duel.RegisterFlagEffect(1, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  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 e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.atkcon(e)
  	return not Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.setcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id) > 0
  end
  function s.setfilter(c)
  	return aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_TRAP) and c:IsSSetable()
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SSet(tp, g)
  	end
  end
  
  