name: Chimera
card_text: 1 Beast monster + 1 Fiend monster
  This card's name becomes "Chimera the Flying Mythical Beast" while on the field or in the GY. You can only use each of the following effects of "Chimera the King of Phantom Beasts" once per turn. If this card is Fusion Summoned: You can activate this effect; send 1 random card from your opponent's hand to the GY during the End Phase of this turn. During your opponent's turn (Quick Effect): You can banish this card from your GY, then target 1 Beast, Fiend, or Illusion monster in your GY; Special Summon it.
external_ids: local CARD_ID_0 = 4796100 --Chimera the Flying Mythical Beast
  
lua: local CARD_ID_0 = 4796100 --Chimera the Flying Mythical Beast
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--material
  	aux.AddFusionProcFun2(c, aux.FilterBoolFunction(Card.IsRace, RACE_BEAST), aux.FilterBoolFunction(Card.IsRace, RACE_FIEND), true)
  	--change name
  	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_GRAVE + LOCATION_MZONE)
  	--handes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCondition(s.tgcon)
  	e1:SetOperation(s.regop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCondition(s.spcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetOperation(s.tgop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, 1)
  	if #g > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == 1 - tp
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_BEAST + RACE_FIEND + RACE_ILLUSION) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler(), e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Chimera
  1 Beast monster + 1 Fiend monster
  This card's name becomes "Chimera the Flying Mythical Beast" while on the field or in the GY. You can only use each of the following effects of "Chimera the King of Phantom Beasts" once per turn. If this card is Fusion Summoned: You can activate this effect; send 1 random card from your opponent's hand to the GY during the End Phase of this turn. During your opponent's turn (Quick Effect): You can banish this card from your GY, then target 1 Beast, Fiend, or Illusion monster in your GY; Special Summon it.
target_text: -- Chimera
  local CARD_ID_0 = 4796100 --Chimera the Flying Mythical Beast
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--material
  	aux.AddFusionProcFun2(c, aux.FilterBoolFunction(Card.IsRace, RACE_BEAST), aux.FilterBoolFunction(Card.IsRace, RACE_FIEND), true)
  	--change name
  	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_GRAVE + LOCATION_MZONE)
  	--handes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCondition(s.tgcon)
  	e1:SetOperation(s.regop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCondition(s.spcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetOperation(s.tgop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, 1)
  	if #g > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == 1 - tp
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_BEAST + RACE_FIEND + RACE_ILLUSION) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler(), e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  