name: 連撃の帝王
card_text: 1:1ターンに1度、相手のメインフェイズ及びバトルフェイズにこの効果を発動できる。
  モンスター1体をアドバンス召喚する。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--instant
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SUMMON)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END + TIMING_BATTLE_START + TIMING_BATTLE_END)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.condition)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.activate)
  	c:RegisterEffect(e3)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tn = Duel.GetTurnPlayer()
  	local ph = Duel.GetCurrentPhase()
  	return tn ~= tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE))
  end
  function s.filter(c)
  	return c:IsSummonable(true, nil, 1) or c:IsMSetable(true, nil, 1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local s1 = tc:IsSummonable(true, nil, 1)
  		local s2 = tc:IsMSetable(true, nil, 1)
  		if (s1 and s2 and Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) == POS_FACEUP_ATTACK) or not s2 then
  			Duel.Summon(tp, tc, true, nil, 1)
  		else
  			Duel.MSet(tp, tc, true, nil, 1)
  		end
  	end
  end
  
  
source_text: 連撃の帝王
  1:1ターンに1度、相手のメインフェイズ及びバトルフェイズにこの効果を発動できる。
  モンスター1体をアドバンス召喚する。
target_text: -- 連撃の帝王
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--instant
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SUMMON)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END + TIMING_BATTLE_START + TIMING_BATTLE_END)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.condition)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.activate)
  	c:RegisterEffect(e3)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tn = Duel.GetTurnPlayer()
  	local ph = Duel.GetCurrentPhase()
  	return tn ~= tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE))
  end
  function s.filter(c)
  	return c:IsSummonable(true, nil, 1) or c:IsMSetable(true, nil, 1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local s1 = tc:IsSummonable(true, nil, 1)
  		local s2 = tc:IsMSetable(true, nil, 1)
  		if (s1 and s2 and Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) == POS_FACEUP_ATTACK) or not s2 then
  			Duel.Summon(tp, tc, true, nil, 1)
  		else
  			Duel.MSet(tp, tc, true, nil, 1)
  		end
  	end
  end
  
  