name: Fire
card_text: When this card is activated: You can Ritual Summon 1 Beast-Warrior Ritual Monster from your hand, by Tributing monsters from your hand or field whose total Levels equal or exceed its Level. If this face-up card is sent from the Spell & Trap Zone to the GY: You can target 1 "Fire Fist" monster in your GY; Special Summon it. You can only use this effect of "Fire Formation - Domei" once per turn. You can only activate 1 "Fire Formation - Domei" per turn.
external_ids: local SETCARD_ID_0 = 0x79 --Fire
  
lua: local SETCARD_ID_0 = 0x79 --Fire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_BEASTWARRIOR)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	::cancel::
  	local mg = Duel.GetRitualMaterial(tp)
  	local g = Duel.GetMatchingGroup(aux.RitualUltimateFilter, tp, LOCATION_HAND, 0, nil, s.filter, e, tp, mg, nil, Card.GetLevel, "Greater")
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local tc = g:Select(tp, 1, 1, nil):GetFirst()
  		mg = mg:Filter(Card.IsCanBeRitualMaterial, tc, tc)
  		if tc.mat_filter then
  			mg = mg:Filter(tc.mat_filter, tc, tp)
  		else
  			mg:RemoveCard(tc)
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  		aux.GCheckAdditional = aux.RitualCheckAdditional(tc, tc:GetLevel(), "Greater")
  		local mat = mg:SelectSubGroup(tp, aux.RitualCheck, true, 1, tc:GetLevel(), tp, tc, tc:GetLevel(), "Greater")
  		aux.GCheckAdditional = nil
  		if not mat then
  			goto cancel
  		end
  		tc:SetMaterial(mat)
  		Duel.ReleaseRitualMaterial(mat)
  		Duel.BreakEffect()
  		Duel.SpecialSummon(tc, SUMMON_TYPE_RITUAL, tp, tp, false, true, POS_FACEUP)
  		tc:CompleteProcedure()
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_SZONE) and c:IsPreviousPosition(POS_FACEUP)
  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, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, 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: Fire
  When this card is activated: You can Ritual Summon 1 Beast-Warrior Ritual Monster from your hand, by Tributing monsters from your hand or field whose total Levels equal or exceed its Level. If this face-up card is sent from the Spell & Trap Zone to the GY: You can target 1 "Fire Fist" monster in your GY; Special Summon it. You can only use this effect of "Fire Formation - Domei" once per turn. You can only activate 1 "Fire Formation - Domei" per turn.
target_text: -- Fire
  local SETCARD_ID_0 = 0x79 --Fire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_BEASTWARRIOR)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	::cancel::
  	local mg = Duel.GetRitualMaterial(tp)
  	local g = Duel.GetMatchingGroup(aux.RitualUltimateFilter, tp, LOCATION_HAND, 0, nil, s.filter, e, tp, mg, nil, Card.GetLevel, "Greater")
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local tc = g:Select(tp, 1, 1, nil):GetFirst()
  		mg = mg:Filter(Card.IsCanBeRitualMaterial, tc, tc)
  		if tc.mat_filter then
  			mg = mg:Filter(tc.mat_filter, tc, tp)
  		else
  			mg:RemoveCard(tc)
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  		aux.GCheckAdditional = aux.RitualCheckAdditional(tc, tc:GetLevel(), "Greater")
  		local mat = mg:SelectSubGroup(tp, aux.RitualCheck, true, 1, tc:GetLevel(), tp, tc, tc:GetLevel(), "Greater")
  		aux.GCheckAdditional = nil
  		if not mat then
  			goto cancel
  		end
  		tc:SetMaterial(mat)
  		Duel.ReleaseRitualMaterial(mat)
  		Duel.BreakEffect()
  		Duel.SpecialSummon(tc, SUMMON_TYPE_RITUAL, tp, tp, false, true, POS_FACEUP)
  		tc:CompleteProcedure()
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_SZONE) and c:IsPreviousPosition(POS_FACEUP)
  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, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, 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
  
  