name: Edge
card_text: During your opponent's Main Phase (Quick Effect): You can reveal this card in your hand; Fusion Summon 1 "Frightfur" Fusion Monster from your Extra Deck, using monsters from your hand or field as Fusion Material, including this card in your hand. If a "Frightfur" Fusion Monster(s) you control would be destroyed by battle or card effect, you can banish this card from your GY instead. You can only use each effect of "Edge Imp Scythe" once per turn.
external_ids: local SETCARD_ID_0 = 0xad --Frightfur
  
lua: local SETCARD_ID_0 = 0xad --Frightfur
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion summon
  	local e1 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		gc = s.gc,
  	})
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	c:RegisterEffect(e1)
  	--Destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetTarget(s.reptg)
  	e2:SetValue(s.repval)
  	c:RegisterEffect(e2)
  end
  
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsMainPhase() and Duel.GetTurnPlayer() == 1 - tp
  end
  
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsPublic()
  	end
  end
  
  function s.fusfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  function s.gc(e)
  	return e:GetHandler()
  end
  
  function s.repfilter(c, tp)
  	return c:IsLocation(LOCATION_MZONE)
  		and c:IsControler(tp)
  		and c:IsFaceup()
  		and c:IsType(TYPE_FUSION)
  		and c:IsSetCard(SETCARD_ID_0)
  		and c:IsReason(REASON_EFFECT + REASON_BATTLE)
  		and not c:IsReason(REASON_REPLACE)
  end
  
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToRemove() and eg:IsExists(s.repfilter, 1, nil, tp)
  	end
  	if Duel.SelectEffectYesNo(tp, e:GetHandler(), 96) then
  		Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_EFFECT)
  		return true
  	else
  		return false
  	end
  end
  
  function s.repval(e, c)
  	return s.repfilter(c, e:GetHandlerPlayer())
  end
  
  
source_text: Edge
  During your opponent's Main Phase (Quick Effect): You can reveal this card in your hand; Fusion Summon 1 "Frightfur" Fusion Monster from your Extra Deck, using monsters from your hand or field as Fusion Material, including this card in your hand. If a "Frightfur" Fusion Monster(s) you control would be destroyed by battle or card effect, you can banish this card from your GY instead. You can only use each effect of "Edge Imp Scythe" once per turn.
target_text: -- Edge
  local SETCARD_ID_0 = 0xad --Frightfur
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion summon
  	local e1 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		gc = s.gc,
  	})
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	c:RegisterEffect(e1)
  	--Destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetTarget(s.reptg)
  	e2:SetValue(s.repval)
  	c:RegisterEffect(e2)
  end
  
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsMainPhase() and Duel.GetTurnPlayer() == 1 - tp
  end
  
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsPublic()
  	end
  end
  
  function s.fusfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  function s.gc(e)
  	return e:GetHandler()
  end
  
  function s.repfilter(c, tp)
  	return c:IsLocation(LOCATION_MZONE)
  		and c:IsControler(tp)
  		and c:IsFaceup()
  		and c:IsType(TYPE_FUSION)
  		and c:IsSetCard(SETCARD_ID_0)
  		and c:IsReason(REASON_EFFECT + REASON_BATTLE)
  		and not c:IsReason(REASON_REPLACE)
  end
  
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToRemove() and eg:IsExists(s.repfilter, 1, nil, tp)
  	end
  	if Duel.SelectEffectYesNo(tp, e:GetHandler(), 96) then
  		Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_EFFECT)
  		return true
  	else
  		return false
  	end
  end
  
  function s.repval(e, c)
  	return s.repfilter(c, e:GetHandlerPlayer())
  end
  
  