name: Ultimate
card_text: "Flame Swordsman" + "Fighting Flame Dragon"
  You can target 1 monster your opponent controls; destroy it, and if you do, inflict 500 damage to your opponent. This is a Quick Effect if this card is equipped with an Equip Card. At the start of the Damage Step, if this card battles: You can double this card's ATK until the end of this turn, but if you do, destroy it during the End Phase of this turn. You can only use each effect of "Ultimate Flame Swordsman" once per turn.
external_ids: local CARD_ID_0 = 36319131 --Fighting Flame Dragon
  local CARD_ID_1 = 45231177 --Flame Swordsman
  
lua: local CARD_ID_0 = 36319131 --Fighting Flame Dragon
  local CARD_ID_1 = 45231177 --Flame Swordsman
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcCode2(c, CARD_ID_1, CARD_ID_0, true, true)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.descon1)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetCondition(s.descon2)
  	c:RegisterEffect(e2)
  	--attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_ATKCHANGE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_START)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCondition(s.atkcon)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  end
  function s.descon1(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetHandler():GetEquipGroup()
  	return g:GetCount() == 0
  end
  function s.descon2(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetHandler():GetEquipGroup()
  	return g:GetCount() > 0
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, nil, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsType(TYPE_MONSTER) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 then
  		Duel.Damage(1 - tp, 500, REASON_EFFECT)
  	end
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsRelateToBattle()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(c:GetAttack() * 2)
  		c:RegisterEffect(e1)
  		local fid = c:GetFieldID()
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1, fid)
  		local sg = Group.FromCards(c)
  		sg:KeepAlive()
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e2:SetCode(EVENT_PHASE + PHASE_END)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetCountLimit(1)
  		e2:SetLabel(fid)
  		e2:SetLabelObject(sg)
  		e2:SetCondition(s.descon3)
  		e2:SetOperation(s.desop3)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  function s.desfilter(c, fid)
  	return c:GetFlagEffectLabel(id) == fid
  end
  function s.descon3(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	if not g:IsExists(s.desfilter, 1, nil, e:GetLabel()) then
  		g:DeleteGroup()
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop3(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	local dg = g:Filter(s.desfilter, nil, e:GetLabel())
  	g:DeleteGroup()
  	Duel.Destroy(dg, REASON_EFFECT)
  end
  
  
source_text: Ultimate
  "Flame Swordsman" + "Fighting Flame Dragon"
  You can target 1 monster your opponent controls; destroy it, and if you do, inflict 500 damage to your opponent. This is a Quick Effect if this card is equipped with an Equip Card. At the start of the Damage Step, if this card battles: You can double this card's ATK until the end of this turn, but if you do, destroy it during the End Phase of this turn. You can only use each effect of "Ultimate Flame Swordsman" once per turn.
target_text: -- Ultimate
  local CARD_ID_0 = 36319131 --Fighting Flame Dragon
  local CARD_ID_1 = 45231177 --Flame Swordsman
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcCode2(c, CARD_ID_1, CARD_ID_0, true, true)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.descon1)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetCondition(s.descon2)
  	c:RegisterEffect(e2)
  	--attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_ATKCHANGE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_START)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCondition(s.atkcon)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  end
  function s.descon1(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetHandler():GetEquipGroup()
  	return g:GetCount() == 0
  end
  function s.descon2(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetHandler():GetEquipGroup()
  	return g:GetCount() > 0
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, nil, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsType(TYPE_MONSTER) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 then
  		Duel.Damage(1 - tp, 500, REASON_EFFECT)
  	end
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsRelateToBattle()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(c:GetAttack() * 2)
  		c:RegisterEffect(e1)
  		local fid = c:GetFieldID()
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1, fid)
  		local sg = Group.FromCards(c)
  		sg:KeepAlive()
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e2:SetCode(EVENT_PHASE + PHASE_END)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetCountLimit(1)
  		e2:SetLabel(fid)
  		e2:SetLabelObject(sg)
  		e2:SetCondition(s.descon3)
  		e2:SetOperation(s.desop3)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  function s.desfilter(c, fid)
  	return c:GetFlagEffectLabel(id) == fid
  end
  function s.descon3(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	if not g:IsExists(s.desfilter, 1, nil, e:GetLabel()) then
  		g:DeleteGroup()
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop3(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	local dg = g:Filter(s.desfilter, nil, e:GetLabel())
  	g:DeleteGroup()
  	Duel.Destroy(dg, REASON_EFFECT)
  end
  
  