name: Raijin
card_text: 1 Level 5 or higher LIGHT Warrior monster + 1 EARTH Warrior monster
  If this card attacks a Defense Position monster, inflict piercing battle damage. If this card battles a monster without a Level, any battle damage this card inflicts to your opponent is doubled. During the End Phase, if this card is in the GY because it was destroyed by battle or card effect and sent there this turn: You can target 2 Level 7 or lower Warrior monsters in your GY; Special Summon them. You can only use this effect of "Raijin the Breakbolt Star" once per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, s.ffilter1, s.ffilter2, true)
  	--pierce
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e1)
  	--double battle damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
  	e2:SetCondition(s.damcon)
  	e2:SetValue(aux.ChangeBattleDamage(1, DOUBLE_DAMAGE))
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetOperation(s.regop)
  	c:RegisterEffect(e3)
  end
  function s.ffilter1(c)
  	return c:IsLevelAbove(5) and c:IsRace(RACE_WARRIOR) and c:IsFusionAttribute(ATTRIBUTE_LIGHT)
  end
  function s.ffilter2(c)
  	return c:IsRace(RACE_WARRIOR) and c:IsFusionAttribute(ATTRIBUTE_EARTH)
  end
  function s.damcon(e)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return bc and not bc:IsLevelAbove(0)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsReason(REASON_DESTROY) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  		e1:SetCountLimit(1, id)
  		e1:SetRange(LOCATION_GRAVE)
  		e1:SetTarget(s.sptg)
  		e1:SetOperation(s.spop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.filter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and c:IsLevelBelow(7) and c:IsRace(RACE_WARRIOR)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) >= 2 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 2, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 2, 2, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 2, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if g:GetCount() > ft then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		g = g:Select(tp, ft, ft, nil)
  	end
  	local tc = g:GetFirst()
  	while tc do
  		Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		tc = g:GetNext()
  	end
  	Duel.SpecialSummonComplete()
  end
  
  
source_text: Raijin
  1 Level 5 or higher LIGHT Warrior monster + 1 EARTH Warrior monster
  If this card attacks a Defense Position monster, inflict piercing battle damage. If this card battles a monster without a Level, any battle damage this card inflicts to your opponent is doubled. During the End Phase, if this card is in the GY because it was destroyed by battle or card effect and sent there this turn: You can target 2 Level 7 or lower Warrior monsters in your GY; Special Summon them. You can only use this effect of "Raijin the Breakbolt Star" once per turn.
target_text: -- Raijin
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, s.ffilter1, s.ffilter2, true)
  	--pierce
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e1)
  	--double battle damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
  	e2:SetCondition(s.damcon)
  	e2:SetValue(aux.ChangeBattleDamage(1, DOUBLE_DAMAGE))
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetOperation(s.regop)
  	c:RegisterEffect(e3)
  end
  function s.ffilter1(c)
  	return c:IsLevelAbove(5) and c:IsRace(RACE_WARRIOR) and c:IsFusionAttribute(ATTRIBUTE_LIGHT)
  end
  function s.ffilter2(c)
  	return c:IsRace(RACE_WARRIOR) and c:IsFusionAttribute(ATTRIBUTE_EARTH)
  end
  function s.damcon(e)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return bc and not bc:IsLevelAbove(0)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsReason(REASON_DESTROY) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  		e1:SetCountLimit(1, id)
  		e1:SetRange(LOCATION_GRAVE)
  		e1:SetTarget(s.sptg)
  		e1:SetOperation(s.spop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.filter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and c:IsLevelBelow(7) and c:IsRace(RACE_WARRIOR)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) >= 2 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 2, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 2, 2, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 2, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if g:GetCount() > ft then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		g = g:Select(tp, ft, ft, nil)
  	end
  	local tc = g:GetFirst()
  	while tc do
  		Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		tc = g:GetNext()
  	end
  	Duel.SpecialSummonComplete()
  end
  
  