name: CXyz
card_text: 3 Level 5 monsters
  When this card is sent from the field to the Graveyard: Draw 1 card. If this card has "Fairy Cheer Girl" as an Xyz Material, it gains this effect.
  ● When this card destroys an opponent's monster by battle and remains on the field: You can detach 1 Xyz Material from this card; inflict 400 damage to your opponent for each card in your hand.
external_ids: local CARD_ID_0 = 51960178 --Fairy Cheer Girl
  
lua: local CARD_ID_0 = 51960178 --Fairy Cheer Girl
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCondition(s.damcon)
  	e2:SetCost(s.damcost)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	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
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode, 1, nil, CARD_ID_0) and aux.bdocon(e, tp, eg, ep, ev, re, r, rp)
  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)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	local dam = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) * 400
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local dam = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) * 400
  	Duel.Damage(p, dam, REASON_EFFECT)
  end
  
  
source_text: CXyz
  3 Level 5 monsters
  When this card is sent from the field to the Graveyard: Draw 1 card. If this card has "Fairy Cheer Girl" as an Xyz Material, it gains this effect.
  ● When this card destroys an opponent's monster by battle and remains on the field: You can detach 1 Xyz Material from this card; inflict 400 damage to your opponent for each card in your hand.
target_text: -- CXyz
  local CARD_ID_0 = 51960178 --Fairy Cheer Girl
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCondition(s.damcon)
  	e2:SetCost(s.damcost)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	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
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode, 1, nil, CARD_ID_0) and aux.bdocon(e, tp, eg, ep, ev, re, r, rp)
  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)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	local dam = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) * 400
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local dam = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) * 400
  	Duel.Damage(p, dam, REASON_EFFECT)
  end
  
  