name: Brotherhood
card_text: When this card is Normal Summoned: You can discard 1 card, then target 1 "Fire Formation" Spell/Trap you control; Set 1 "Fire Formation" Spell/Trap with a different name directly from your Deck. If this card is Special Summoned by the effect of a "Fire Fist" monster: You can Set 1 "Fire Formation" Spell/Trap directly from your Deck, with a different name from the cards in your GY. You can only use each effect of "Brotherhood of the Fire Fist - Ram" once per turn.
external_ids: local SETCARD_ID_0 = 0x79 --Fire
  local SETCARD_ID_1 = 0x7c --Fire
  
lua: local SETCARD_ID_0 = 0x79 --Fire
  local SETCARD_ID_1 = 0x7c --Fire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--set
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.setcost1)
  	e1:SetTarget(s.settg1)
  	e1:SetOperation(s.setop1)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.setcon2)
  	e2:SetTarget(s.settg2)
  	e2:SetOperation(s.setop2)
  	c:RegisterEffect(e2)
  end
  function s.setcost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.setfilter1(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and Duel.IsExistingMatchingCard(s.setfilter2, tp, LOCATION_DECK, 0, 1, nil, c:GetCode())
  end
  function s.setfilter2(c, code)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and not c:IsCode(code) and c:IsSSetable()
  end
  function s.settg1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(tp) and s.setfilter1(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.setfilter1, tp, LOCATION_ONFIELD, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.setfilter1, tp, LOCATION_ONFIELD, 0, 1, 1, nil, tp)
  end
  function s.setop1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.setfilter2, tp, LOCATION_DECK, 0, 1, 1, nil, tc:GetCode())
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g:GetFirst())
  		end
  	end
  end
  function s.setcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:GetSpecialSummonInfo(SUMMON_INFO_TYPE) & TYPE_MONSTER ~= 0 and c:IsSpecialSummonSetCard(SETCARD_ID_1)
  end
  function s.setfilter3(c, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable() and not Duel.IsExistingMatchingCard(Card.IsCode, tp, LOCATION_GRAVE, 0, 1, nil, c:GetCode())
  end
  function s.settg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter3, tp, LOCATION_DECK, 0, 1, nil, tp)
  	end
  end
  function s.setop2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter3, tp, LOCATION_DECK, 0, 1, 1, nil, tp)
  	if g:GetCount() > 0 then
  		Duel.SSet(tp, g:GetFirst())
  	end
  end
  
  
source_text: Brotherhood
  When this card is Normal Summoned: You can discard 1 card, then target 1 "Fire Formation" Spell/Trap you control; Set 1 "Fire Formation" Spell/Trap with a different name directly from your Deck. If this card is Special Summoned by the effect of a "Fire Fist" monster: You can Set 1 "Fire Formation" Spell/Trap directly from your Deck, with a different name from the cards in your GY. You can only use each effect of "Brotherhood of the Fire Fist - Ram" once per turn.
target_text: -- Brotherhood
  local SETCARD_ID_0 = 0x79 --Fire
  local SETCARD_ID_1 = 0x7c --Fire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--set
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.setcost1)
  	e1:SetTarget(s.settg1)
  	e1:SetOperation(s.setop1)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.setcon2)
  	e2:SetTarget(s.settg2)
  	e2:SetOperation(s.setop2)
  	c:RegisterEffect(e2)
  end
  function s.setcost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.setfilter1(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and Duel.IsExistingMatchingCard(s.setfilter2, tp, LOCATION_DECK, 0, 1, nil, c:GetCode())
  end
  function s.setfilter2(c, code)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and not c:IsCode(code) and c:IsSSetable()
  end
  function s.settg1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(tp) and s.setfilter1(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.setfilter1, tp, LOCATION_ONFIELD, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.setfilter1, tp, LOCATION_ONFIELD, 0, 1, 1, nil, tp)
  end
  function s.setop1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.setfilter2, tp, LOCATION_DECK, 0, 1, 1, nil, tc:GetCode())
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g:GetFirst())
  		end
  	end
  end
  function s.setcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:GetSpecialSummonInfo(SUMMON_INFO_TYPE) & TYPE_MONSTER ~= 0 and c:IsSpecialSummonSetCard(SETCARD_ID_1)
  end
  function s.setfilter3(c, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable() and not Duel.IsExistingMatchingCard(Card.IsCode, tp, LOCATION_GRAVE, 0, 1, nil, c:GetCode())
  end
  function s.settg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter3, tp, LOCATION_DECK, 0, 1, nil, tp)
  	end
  end
  function s.setop2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter3, tp, LOCATION_DECK, 0, 1, 1, nil, tp)
  	if g:GetCount() > 0 then
  		Duel.SSet(tp, g:GetFirst())
  	end
  end
  
  