Commit 116bed88 authored by Vury Leo's avatar Vury Leo

init accel synchro

parent bcd7b2ae
--フォーミュラ・シンクロン --フォーミュラ・シンクロン
function c50091196.initial_effect(c) local s,id,o=GetID()
function s.initial_effect(c)
--synchro summon --synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1,1) aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1,1)
Synchro.AddSynchroProcedure(c,{non_tuner_max=1}) Synchro.AddSynchroProcedure(c,{non_tuner_max=1})
c:EnableReviveLimit() c:EnableReviveLimit()
--synchro summon success --synchro summon success
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(50091196,0)) e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_DRAW) e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c50091196.drcon) e1:SetCondition(s.drcon)
e1:SetTarget(c50091196.drtarg) e1:SetTarget(s.drtarg)
e1:SetOperation(c50091196.drop) e1:SetOperation(s.drop)
c:RegisterEffect(e1) c:RegisterEffect(e1)
--synchro effect --synchro effect
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(50091196,1)) e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN) e2:SetCode(EVENT_FREE_CHAIN)
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END) e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e2:SetRange(LOCATION_MZONE) e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN) e2:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
e2:SetCondition(c50091196.sccon) e2:SetCondition(s.sccon)
e2:SetTarget(c50091196.sctarg) e2:SetTarget(s.sctarg)
e2:SetOperation(c50091196.scop) e2:SetOperation(s.scop)
c:RegisterEffect(e2) c:RegisterEffect(e2)
end end
function c50091196.drcon(e,tp,eg,ep,ev,re,r,rp) function s.drcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO) return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
end end
function c50091196.drtarg(e,tp,eg,ep,ev,re,r,rp,chk) function s.drtarg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end
Duel.SetTargetPlayer(tp) Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1) Duel.SetTargetParam(1)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end end
function c50091196.drop(e,tp,eg,ep,ev,re,r,rp) function s.drop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT) Duel.Draw(p,d,REASON_EFFECT)
end end
function c50091196.sccon(e,tp,eg,ep,ev,re,r,rp) function s.sccon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp return Duel.GetTurnPlayer()~=tp
and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2)
end end
function c50091196.sctarg(e,tp,eg,ep,ev,re,r,rp,chk) function s.sctarg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,1,nil,c) end if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,1,nil,c) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end end
function c50091196.scop(e,tp,eg,ep,ev,re,r,rp) function s.scop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
if c:IsControler(1-tp) or not c:IsRelateToEffect(e) or c:IsFacedown() then return end if c:IsControler(1-tp) or not c:IsRelateToEffect(e) or c:IsFacedown() then return end
local g=Duel.GetMatchingGroup(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,nil,c) local g=Duel.GetMatchingGroup(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,nil,c)
if g:GetCount()>0 then if g:GetCount()>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local opt=Duel.SelectOption(tp,1164,1379)
local sg=g:Select(tp,1,1,nil) if opt==0 then
Duel.SynchroSummon(tp,sg:GetFirst(),c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tc=g:Select(tp,1,1,nil):GetFirst()
Duel.SynchroSummon(tp,tc,c)
else
local mg=Duel.GetSynchroMaterial(tp)
local mat=Group.CreateGroup()
local tc=nil
local proc=nil
while #mat==0 do
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
tc=g:Select(tp,1,1,nil):GetFirst()
local procs={tc:IsHasEffect(EFFECT_SPSUMMON_PROC,tp)}
local avaliable_procs={}
for _,proc in ipairs(procs) do
local con=proc:GetCondition()
if con(e,tc,c,mg,1,math.huge) then
table.insert(avaliable_procs,proc)
end
end
if #avaliable_procs==0 then
--- fallback
Duel.SynchroSummon(tp,tc,c)
end
assert(#avaliable_procs>0,"target card does not support new synchro yet")
proc=avaliable_procs[1]
if #avaliable_procs>1 then
local opts={}
for _,avaliable_proc in ipairs(avaliable_procs) do
table.insert(opts,avaliable_proc:GetDescription())
end
local proc_index=Duel.SelectOption(tp,table.unpack(opts))+1
proc=avaliable_procs[proc_index]
end
local target=proc:GetTarget()
if target(proc,tp,eg,ep,ev,re,r,rp,1,tc,c,mg,1,math.huge) then
mat=proc:GetLabelObject()
end
end
assert(tc~=nil)
assert(proc~=nil)
Duel.SynchroSummon(tp,tc,nil,mat,#mat,#mat)
end
end end
end end
...@@ -3404,6 +3404,20 @@ function Synchro.AddSynchroProcedure(c,params) ...@@ -3404,6 +3404,20 @@ function Synchro.AddSynchroProcedure(c,params)
e1:SetOperation(Synchro.SynOperation()) e1:SetOperation(Synchro.SynOperation())
e1:SetValue(SUMMON_TYPE_SYNCHRO) e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1) c:RegisterEffect(e1)
--- accel synchro mode
local e2=Effect.CreateEffect(c)
-- e2:SetDescription(1164)
e2:SetDescription(1379) --- 启用扩展卡包调试模式
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetRange(LOCATION_EXTRA)
e2:SetCondition(Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper))
e2:SetTarget(Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper))
e2:SetOperation(Synchro.SynOperation())
e2:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e2)
end end
-- Entry point: prepares and invokes the DFS -- Entry point: prepares and invokes the DFS
...@@ -3589,33 +3603,64 @@ end ...@@ -3589,33 +3603,64 @@ end
--- Synchro condition generator using tuner/non-tuner min/max counts and filters --- Synchro condition generator using tuner/non-tuner min/max counts and filters
function Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper) function Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper)
--- @param mg Group
return function(e,c,smat,mg,min,max) return function(e,c,smat,mg,min,max)
if c==nil then return true end if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
--- we do not support Accel Synchro yet
local target_level=c:GetLevel()
mg=mg or Duel.GetMatchingGroup(Card.IsCanBeSynchroMaterial,c:GetControler(),LOCATION_MZONE+LOCATION_HAND,0,nil)
local smat_states=nil
local smat_arr=nil
if smat~=nil then if smat~=nil then
return false if not mg:IsContains(smat) then
end return false
if mg~=nil and #mg>0 then end
return false smat_arr={}
table.insert(smat_arr,smat)
smat_states=Synchro.BuildStatesFromSelection(smat_arr,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,base_mapper,c,math.huge)
end end
local target_level=c:GetLevel()
mg=Duel.GetMatchingGroup(Card.IsCanBeSynchroMaterial,c:GetControler(),LOCATION_MZONE+LOCATION_HAND,0,nil)
local candidates={} local candidates={}
for mc in aux.Next(mg) do for mc in aux.Next(mg) do
table.insert(candidates,mc) if mc~=smat then
table.insert(candidates,mc)
end
end
if smat~=nil then
for _,state in ipairs(smat_states) do
if Synchro.FindValidSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,c,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper,smat_arr,state) then
return true
end
end
return false
else
return Synchro.FindValidSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,c,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper)
end end
return Synchro.FindValidSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,c,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper)
end end
end end
function Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper) function Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper)
return function(e,tp,eg,ep,ev,re,r,rp,chk,tc,smat,mg,min,max) return function(e,tp,eg,ep,ev,re,r,rp,chk,tc,smat,mg,min,max)
if mg~=nil and #mg==min then
e:SetLabelObject(mg)
return true
end
mg=mg or Duel.GetMatchingGroup(function(mc) return mc:IsCanBeSynchroMaterial(mc,tc) end,tc:GetOwner(),LOCATION_MZONE+LOCATION_HAND,0,nil) mg=mg or Duel.GetMatchingGroup(function(mc) return mc:IsCanBeSynchroMaterial(mc,tc) end,tc:GetOwner(),LOCATION_MZONE+LOCATION_HAND,0,nil)
local sg=Group.CreateGroup() local sg=Group.CreateGroup()
if smat~=nil then
if not mg:IsContains(smat) then
return false
end
sg:AddCard(smat)
end
local function GroupToArray(group) local function GroupToArray(group)
local arr={} local arr={}
for card in aux.Next(group) do table.insert(arr,card) end for card in aux.Next(group) do table.insert(arr,card) end
...@@ -3708,7 +3753,9 @@ function Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filt ...@@ -3708,7 +3753,9 @@ function Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filt
end end
else else
if sg:IsContains(picked) then if sg:IsContains(picked) then
sg:RemoveCard(picked) if picked~=smat then
sg:RemoveCard(picked)
end
else else
sg:AddCard(picked) sg:AddCard(picked)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment