name: Phantasm
card_text: If all monsters you control are Normal Monsters (min. 1): Target 1 card your opponent controls; destroy it. If "Umi" is on the field, you can activate this card from your hand. You can banish this card from your Graveyard, then target 1 Normal Monster you control; equip that Normal Monster with all "Phantasm Spiral" Equip Spell Cards you control that can equip to it.
external_ids: local CARD_ID_0 = 22702055 --Umi
  local SETCARD_ID_0 = 0xfa --Phantasm
  
lua: local CARD_ID_0 = 22702055 --Umi
  local SETCARD_ID_0 = 0xfa --Phantasm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--act in hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
  	e2:SetCondition(s.handcon)
  	c:RegisterEffect(e2)
  	--equip
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_EQUIP)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCost(aux.bfgcost)
  	e3:SetTarget(s.eqtg)
  	e3:SetOperation(s.eqop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFacedown() or not c:IsType(TYPE_NORMAL)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) > 0 and not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsOnField()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, nil, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  function s.handcon(e)
  	return Duel.IsEnvironment(CARD_ID_0)
  end
  function s.efilter(c, tp)
  	return c:IsFaceup() and c:IsType(TYPE_NORMAL) and Duel.IsExistingMatchingCard(s.eqfilter, tp, LOCATION_SZONE, 0, 1, nil, c)
  end
  function s.eqfilter(c, tc)
  	return c:IsFaceup() and c:IsType(TYPE_EQUIP) and c:IsSetCard(SETCARD_ID_0) and c:CheckEquipTarget(tc)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.efilter(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.efilter, tp, LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.efilter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFacedown() or not tc:IsRelateToEffect(e) then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.eqfilter, tp, LOCATION_SZONE, 0, nil, tc)
  	local eq = g:GetFirst()
  	while eq do
  		Duel.Equip(tp, eq, tc, true, true)
  		eq = g:GetNext()
  	end
  	Duel.EquipComplete()
  end
  
  
source_text: Phantasm
  If all monsters you control are Normal Monsters (min. 1): Target 1 card your opponent controls; destroy it. If "Umi" is on the field, you can activate this card from your hand. You can banish this card from your Graveyard, then target 1 Normal Monster you control; equip that Normal Monster with all "Phantasm Spiral" Equip Spell Cards you control that can equip to it.
target_text: -- Phantasm
  local CARD_ID_0 = 22702055 --Umi
  local SETCARD_ID_0 = 0xfa --Phantasm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--act in hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
  	e2:SetCondition(s.handcon)
  	c:RegisterEffect(e2)
  	--equip
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_EQUIP)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCost(aux.bfgcost)
  	e3:SetTarget(s.eqtg)
  	e3:SetOperation(s.eqop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFacedown() or not c:IsType(TYPE_NORMAL)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) > 0 and not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsOnField()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, nil, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  function s.handcon(e)
  	return Duel.IsEnvironment(CARD_ID_0)
  end
  function s.efilter(c, tp)
  	return c:IsFaceup() and c:IsType(TYPE_NORMAL) and Duel.IsExistingMatchingCard(s.eqfilter, tp, LOCATION_SZONE, 0, 1, nil, c)
  end
  function s.eqfilter(c, tc)
  	return c:IsFaceup() and c:IsType(TYPE_EQUIP) and c:IsSetCard(SETCARD_ID_0) and c:CheckEquipTarget(tc)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.efilter(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.efilter, tp, LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.efilter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFacedown() or not tc:IsRelateToEffect(e) then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.eqfilter, tp, LOCATION_SZONE, 0, nil, tc)
  	local eq = g:GetFirst()
  	while eq do
  		Duel.Equip(tp, eq, tc, true, true)
  		eq = g:GetNext()
  	end
  	Duel.EquipComplete()
  end
  
  