name: Decisive
card_text: This card's name becomes "Great Sand Sea - Gold Golgonda" while on the field or in the GY. Once per turn, if a card(s) you control would be destroyed by battle or card effect, you can send 1 Fusion Monster that mentions "Fallen of Albaz" as material from your Extra Deck to the GY, instead. During the End Phase, if you have "Fallen of Albaz" on your field or in your GY: You can Special Summon 1 "Springans" monster from your hand or Deck. You can only use this effect of "Decisive Battle of Golgonda" once per turn.
external_ids: local CARD_ID_0 = 68468459 --Fallen of Albaz
  local CARD_ID_1 = 60884672 --Great Sand Sea - Gold Golgonda
  local SETCARD_ID_0 = 0x155 --Springans
  
lua: local CARD_ID_0 = 68468459 --Fallen of Albaz
  local CARD_ID_1 = 60884672 --Great Sand Sea - Gold Golgonda
  local SETCARD_ID_0 = 0x155 --Springans
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	aux.EnableChangeCode(c, CARD_ID_1, LOCATION_SZONE + LOCATION_GRAVE)
  	--activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--destroy replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EFFECT_DESTROY_REPLACE)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.reptg)
  	e1:SetValue(s.repval)
  	e1:SetOperation(s.repop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.dfilter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_ONFIELD) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  end
  function s.repfilter(c)
  	return c:IsType(TYPE_FUSION) and aux.IsMaterialListCode(c, CARD_ID_0) and c:IsAbleToGrave()
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.dfilter, 1, nil, tp) and Duel.IsExistingMatchingCard(s.repfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.repval(e, c)
  	return s.dfilter(c, e:GetHandlerPlayer())
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.repfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_REPLACE)
  end
  function s.cfilter(c)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsCode(CARD_ID_0)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Decisive
  This card's name becomes "Great Sand Sea - Gold Golgonda" while on the field or in the GY. Once per turn, if a card(s) you control would be destroyed by battle or card effect, you can send 1 Fusion Monster that mentions "Fallen of Albaz" as material from your Extra Deck to the GY, instead. During the End Phase, if you have "Fallen of Albaz" on your field or in your GY: You can Special Summon 1 "Springans" monster from your hand or Deck. You can only use this effect of "Decisive Battle of Golgonda" once per turn.
target_text: -- Decisive
  local CARD_ID_0 = 68468459 --Fallen of Albaz
  local CARD_ID_1 = 60884672 --Great Sand Sea - Gold Golgonda
  local SETCARD_ID_0 = 0x155 --Springans
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	aux.EnableChangeCode(c, CARD_ID_1, LOCATION_SZONE + LOCATION_GRAVE)
  	--activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--destroy replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EFFECT_DESTROY_REPLACE)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.reptg)
  	e1:SetValue(s.repval)
  	e1:SetOperation(s.repop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.dfilter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_ONFIELD) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  end
  function s.repfilter(c)
  	return c:IsType(TYPE_FUSION) and aux.IsMaterialListCode(c, CARD_ID_0) and c:IsAbleToGrave()
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.dfilter, 1, nil, tp) and Duel.IsExistingMatchingCard(s.repfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.repval(e, c)
  	return s.dfilter(c, e:GetHandlerPlayer())
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.repfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_REPLACE)
  end
  function s.cfilter(c)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsCode(CARD_ID_0)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  