name: Number
card_text: 4 Level 5 monsters
  When this card is Special Summoned: You can target 1 Spell/Trap Card on the field; destroy that target. If this card has "Number 104: Masquerade" as an Xyz material, it gains this effect.
  ● Once per turn, during either player's turn, when a monster effect is activated on your opponent's side of the field: You can detach 1 Xyz Material from this card; negate the activation, then you can send 1 random card from your opponent's hand to the Graveyard, and if you do, halve your opponent's Life Points.
external_ids: local CARD_ID_0 = 2061963 --Number 104: Masquerade
  
lua: local CARD_ID_0 = 2061963 --Number 104: Masquerade
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 4)
  	c:EnableReviveLimit()
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--negate activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_NEGATE + CATEGORY_HANDES)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetCondition(s.condition)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 104
  function s.desfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(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.condition(e, tp, eg, ep, ev, re, r, rp)
  	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  		and ep ~= tp
  		and loc == LOCATION_MZONE
  		and re:IsActiveType(TYPE_MONSTER)
  		and Duel.IsChainNegatable(ev)
  		and e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode, 1, nil, CARD_ID_0)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and Duel.GetFieldGroupCount(1 - tp, LOCATION_HAND, 0) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  		local g = Duel.GetFieldGroup(1 - tp, LOCATION_HAND, 0):RandomSelect(1 - tp, 1)
  		Duel.SendtoGrave(g, REASON_EFFECT)
  		Duel.SetLP(1 - tp, math.ceil(Duel.GetLP(1 - tp) / 2))
  	end
  end
  
  
source_text: Number
  4 Level 5 monsters
  When this card is Special Summoned: You can target 1 Spell/Trap Card on the field; destroy that target. If this card has "Number 104: Masquerade" as an Xyz material, it gains this effect.
  ● Once per turn, during either player's turn, when a monster effect is activated on your opponent's side of the field: You can detach 1 Xyz Material from this card; negate the activation, then you can send 1 random card from your opponent's hand to the Graveyard, and if you do, halve your opponent's Life Points.
target_text: -- Number
  local CARD_ID_0 = 2061963 --Number 104: Masquerade
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 4)
  	c:EnableReviveLimit()
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--negate activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_NEGATE + CATEGORY_HANDES)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetCondition(s.condition)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 104
  function s.desfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(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.condition(e, tp, eg, ep, ev, re, r, rp)
  	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  		and ep ~= tp
  		and loc == LOCATION_MZONE
  		and re:IsActiveType(TYPE_MONSTER)
  		and Duel.IsChainNegatable(ev)
  		and e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode, 1, nil, CARD_ID_0)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and Duel.GetFieldGroupCount(1 - tp, LOCATION_HAND, 0) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  		local g = Duel.GetFieldGroup(1 - tp, LOCATION_HAND, 0):RandomSelect(1 - tp, 1)
  		Duel.SendtoGrave(g, REASON_EFFECT)
  		Duel.SetLP(1 - tp, math.ceil(Duel.GetLP(1 - tp) / 2))
  	end
  end
  
  