name: Artifacts
card_text: Target 2 "Artifact" monsters you control; immediately after this effect resolves, Xyz Summon 1 Xyz Monster using those 2 monsters only, also for the rest of this turn after this card resolves, monsters you control cannot attack, except "Artifact" monsters. If this card in its owner's possession is destroyed by an opponent's card: You can reveal 1 Level 5 LIGHT monster from your hand; draw 1 card.
external_ids: local SETCARD_ID_0 = 0x97 --Artifact
  
lua: local SETCARD_ID_0 = 0x97 --Artifact
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetCondition(s.drcon)
  	e2:SetCost(s.drcost)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, e)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeEffectTarget(e)
  end
  function s.xyzfilter(c, mg)
  	return c:IsXyzSummonable(mg, 2, 2)
  end
  function s.mfilter1(c, mg, exg, tp)
  	return mg:IsExists(s.mfilter2, 1, c, c, exg, tp)
  end
  function s.mfilter2(c, mc, exg, tp)
  	local g = Group.FromCards(c, mc)
  	return exg:IsExists(Card.IsXyzSummonable, 1, nil, g)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local mg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil, e)
  	local exg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, mg)
  	if chk == 0 then
  		return mg:IsExists(s.mfilter1, 1, nil, mg, exg, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local sg1 = mg:FilterSelect(tp, s.mfilter1, 1, 1, nil, mg, exg, tp)
  	local tc1 = sg1:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local sg2 = mg:FilterSelect(tp, s.mfilter2, 1, 1, tc1, tc1, exg, tp)
  	sg1:Merge(sg2)
  	Duel.SetTargetCard(sg1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.tfilter(c, e)
  	return c:IsRelateToEffect(e) and c:IsFaceup()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.attg)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(s.tfilter, nil, e)
  	if g:GetCount() < 2 then
  		return
  	end
  	local xyzg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, g)
  	if xyzg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local xyz = xyzg:Select(tp, 1, 1, nil):GetFirst()
  		Duel.XyzSummon(tp, xyz, g)
  	end
  end
  function s.attg(e, c)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and e:GetHandler():IsPreviousControler(tp)
  end
  function s.cffilter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsLevel(5) and not c:IsPublic()
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cffilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.cffilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  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
  
  
source_text: Artifacts
  Target 2 "Artifact" monsters you control; immediately after this effect resolves, Xyz Summon 1 Xyz Monster using those 2 monsters only, also for the rest of this turn after this card resolves, monsters you control cannot attack, except "Artifact" monsters. If this card in its owner's possession is destroyed by an opponent's card: You can reveal 1 Level 5 LIGHT monster from your hand; draw 1 card.
target_text: -- Artifacts
  local SETCARD_ID_0 = 0x97 --Artifact
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetCondition(s.drcon)
  	e2:SetCost(s.drcost)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, e)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeEffectTarget(e)
  end
  function s.xyzfilter(c, mg)
  	return c:IsXyzSummonable(mg, 2, 2)
  end
  function s.mfilter1(c, mg, exg, tp)
  	return mg:IsExists(s.mfilter2, 1, c, c, exg, tp)
  end
  function s.mfilter2(c, mc, exg, tp)
  	local g = Group.FromCards(c, mc)
  	return exg:IsExists(Card.IsXyzSummonable, 1, nil, g)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local mg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil, e)
  	local exg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, mg)
  	if chk == 0 then
  		return mg:IsExists(s.mfilter1, 1, nil, mg, exg, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local sg1 = mg:FilterSelect(tp, s.mfilter1, 1, 1, nil, mg, exg, tp)
  	local tc1 = sg1:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local sg2 = mg:FilterSelect(tp, s.mfilter2, 1, 1, tc1, tc1, exg, tp)
  	sg1:Merge(sg2)
  	Duel.SetTargetCard(sg1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.tfilter(c, e)
  	return c:IsRelateToEffect(e) and c:IsFaceup()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.attg)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(s.tfilter, nil, e)
  	if g:GetCount() < 2 then
  		return
  	end
  	local xyzg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, g)
  	if xyzg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local xyz = xyzg:Select(tp, 1, 1, nil):GetFirst()
  		Duel.XyzSummon(tp, xyz, g)
  	end
  end
  function s.attg(e, c)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and e:GetHandler():IsPreviousControler(tp)
  end
  function s.cffilter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsLevel(5) and not c:IsPublic()
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cffilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.cffilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  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
  
  