name: CXyz
card_text: 3 Level 5 monsters
  Once per turn, this card cannot be destroyed by battle. If this card has "Comics Hero King Arthur" as an Xyz Material, it gains this effect.
  ● When this card destroys a monster by battle and sends it to the Graveyard: You can detach 1 Xyz Material from this card; banish the destroyed monster, and if you do, inflict damage to your opponent equal to its original ATK.
external_ids: local CARD_ID_0 = 77631175 --Comics Hero King Arthur
  
lua: local CARD_ID_0 = 77631175 --Comics Hero King Arthur
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--battle indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e1:SetCountLimit(1)
  	e1:SetValue(s.valcon)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCondition(s.damcon)
  	e2:SetCost(s.damcost)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.valcon(e, re, r, rp)
  	return bit.band(r, REASON_BATTLE) ~= 0
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return c:GetOverlayGroup():IsExists(Card.IsCode, 1, nil, CARD_ID_0) and c:IsRelateToBattle() and bc:IsLocation(LOCATION_GRAVE) and bc:IsType(TYPE_MONSTER)
  end
  function s.damcost(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.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local bc = e:GetHandler():GetBattleTarget()
  	if chk == 0 then
  		return bc:IsAbleToRemove()
  	end
  	Duel.SetTargetCard(bc)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, bc, 1, bc:GetControler(), LOCATION_GRAVE)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, bc:GetBaseAttack())
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = Duel.GetFirstTarget()
  	if bc:IsRelateToEffect(e) and Duel.Remove(bc, POS_FACEUP, REASON_EFFECT) > 0 then
  		Duel.Damage(1 - tp, bc:GetBaseAttack(), REASON_EFFECT)
  	end
  end
  
  
source_text: CXyz
  3 Level 5 monsters
  Once per turn, this card cannot be destroyed by battle. If this card has "Comics Hero King Arthur" as an Xyz Material, it gains this effect.
  ● When this card destroys a monster by battle and sends it to the Graveyard: You can detach 1 Xyz Material from this card; banish the destroyed monster, and if you do, inflict damage to your opponent equal to its original ATK.
target_text: -- CXyz
  local CARD_ID_0 = 77631175 --Comics Hero King Arthur
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--battle indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e1:SetCountLimit(1)
  	e1:SetValue(s.valcon)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCondition(s.damcon)
  	e2:SetCost(s.damcost)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.valcon(e, re, r, rp)
  	return bit.band(r, REASON_BATTLE) ~= 0
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return c:GetOverlayGroup():IsExists(Card.IsCode, 1, nil, CARD_ID_0) and c:IsRelateToBattle() and bc:IsLocation(LOCATION_GRAVE) and bc:IsType(TYPE_MONSTER)
  end
  function s.damcost(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.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local bc = e:GetHandler():GetBattleTarget()
  	if chk == 0 then
  		return bc:IsAbleToRemove()
  	end
  	Duel.SetTargetCard(bc)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, bc, 1, bc:GetControler(), LOCATION_GRAVE)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, bc:GetBaseAttack())
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = Duel.GetFirstTarget()
  	if bc:IsRelateToEffect(e) and Duel.Remove(bc, POS_FACEUP, REASON_EFFECT) > 0 then
  		Duel.Damage(1 - tp, bc:GetBaseAttack(), REASON_EFFECT)
  	end
  end
  
  