Commit c5f177cc authored by Vury Leo's avatar Vury Leo

no hard code

parent aff94e43
......@@ -3410,40 +3410,13 @@ function Synchro.FindValidSelection(candidates,target_level,
tuner_min,tuner_max,
non_tuner_min,non_tuner_max,
base_mapper,pre_select,state)
-- 1) Sort candidates: Mono first, then Flower, then normals
local function is_mono(c)
return c:IsCode(56897896)
end
local function is_flower(c)
return c:IsCode(57261568,33541430,89818984)
end
local function is_tatsunoko(c)
return c:IsCode(55863245)
end
table.sort(candidates,function(a,b)
if is_mono(a)~=is_mono(b) then
return is_mono(a) -- monos first
end
if is_flower(a)~=is_flower(b) then
return is_flower(a) -- then flowers
end
if is_tatsunoko(a)~=is_tatsunoko(b) then
return is_tatsunoko(a) -- then tatsunoko
end
if tuner_filter(a,tc)~=tuner_filter(b,tc) then
return tuner_filter(a,tc) -- then tuner
end
-- otherwise normals: sort descending by level
return a:GetLevel()>b:GetLevel()
end)
Synchro.SortMaterials(candidates,tc,tuner_filter)
-- 2) Find the index of the last level card
local level_prune_index=0
for i, c in ipairs(candidates) do
if is_mono(c) or is_flower(c) then
if Synchro.IsLevelAlter(c) then
level_prune_index=i
end
end
......@@ -3451,7 +3424,7 @@ function Synchro.FindValidSelection(candidates,target_level,
-- 3) Find the index of the last hand card
local hand_prune_index=0
for i, c in ipairs(candidates) do
if is_tatsunoko(c) then
if Synchro.IsHandAlter(c) then
hand_prune_index=i
end
end
......@@ -3507,7 +3480,6 @@ end
--- @return boolean -- True if a valid selection exists, false otherwise.
function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_tuner_filter,tc,
tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper,selected,index,state,prune_indexes)
--- Mono Synchron (priority=2) > Flower Cardian (1) > normal (0)
local mapper = state.level_mapper
if state.tuner_count>tuner_max then return false end
......@@ -3544,7 +3516,8 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
if can_include then
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
if mc:IsCode(56897896) then
if Synchro.IsMono(mc) then
--- Mono Synchron (priority=2) > Flower Cardian (1) > normal (0)
if state.level_mapper_priority<2 then
-- first Mono: that one keeps its real level, others=1
local firstMono=mc
......@@ -3580,7 +3553,7 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
--- mono is mandatory so it can not be include Normal
--- Tatsunoko never harm to enable
if not mc:IsCode(56897896,55863245) then
if not (Synchro.IsMono(mc) or Synchro.IsTatsunoko(mc)) then
-- 1) Normal include branch
local lvls=mapper(mc,tc)
local sums_norm=Synchro.UpdatepossibleSums(state.possible_sums,lvls,prune_level)
......@@ -3590,7 +3563,7 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
end
-- override if Flower Cardian
if mc:IsCode(57261568,33541430,89818984) then
if Synchro.IsFlower(mc) then
if state.level_mapper_priority<1 then
local cnt=#selected+1
local sums_ovr={[2*cnt]=true}
......@@ -3603,7 +3576,7 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
end
-- Tatsunoko effect: include and grant hand material slot
if mc:IsCode(55863245) then
if Synchro.IsTatsunoko(mc) then
-- include Tatsunoko's own level contributions
local lvls=mapper(mc,tc)
local sums_tats=Synchro.UpdatepossibleSums(state.possible_sums,lvls,prune_level)
......@@ -3862,35 +3835,7 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
}
}
-- 1) Sort candidates: Mono first, then Flower, then Tatsunoko then normals
local function is_mono(c)
return c:IsCode(56897896)
end
local function is_flower(c)
return c:IsCode(57261568,33541430,89818984)
end
local function is_tatsunoko(c)
return c:IsCode(55863245)
end
table.sort(selection,function(a,b)
if is_mono(a)~=is_mono(b) then
return is_mono(a) -- monos first
end
if is_flower(a)~=is_flower(b) then
return is_flower(a) -- then flowers
end
if is_tatsunoko(a)~=is_tatsunoko(b) then
return is_tatsunoko(a) -- then tatsunoko
end
if tuner_filter(a,tc)~=tuner_filter(b,tc) then
return tuner_filter(a,tc) -- then tuner
end
-- otherwise normals: sort descending by level
return a:GetLevel()>b:GetLevel()
end)
Synchro.SortMaterials(selection,tc,tuner_filter)
for idx,card in ipairs(selection)do
local next_states={}
......@@ -3902,7 +3847,7 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
local mapper=st.level_mapper
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
if card:IsCode(56897896) then
if Synchro.IsMono(card) then
if st.level_mapper_priority<2 then
-- first Mono: that one keeps its real level, others=1
local firstMono=card
......@@ -3940,7 +3885,7 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
end
end
if not card:IsCode(56897896) then
if not (Synchro.IsMono(card) or Synchro.IsTatsunoko(card)) then
-- normal branch
local lvls=mapper(card,tc)
local sums_norm=Synchro.UpdatepossibleSums(st.possible_sums,lvls,prune_level)
......@@ -3958,7 +3903,7 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
end
-- override level mapper branch if Flower Cardian
if card:IsCode(57261568,33541430,89818984) then
if Synchro.IsFlower(card) then
if st.level_mapper_priority<1 then
local sums_ovr={[2*idx]=true}
table.insert(next_states,{
......@@ -3974,7 +3919,7 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
end
-- increase hand count limit if tatsunoko
if card:IsCode(55863245) then
if Synchro.IsTatsunoko(card) then
-- include Tatsunoko's own level contributions
local lvls=mapper(card,tc)
local sums_tats=Synchro.UpdatepossibleSums(st.possible_sums,lvls,prune_level)
......@@ -3999,3 +3944,42 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
return states
end
function Synchro.IsMono(c)
return c:IsCode(56897896)
end
function Synchro.IsFlower(c)
return c:IsCode(57261568,33541430,89818984)
end
function Synchro.IsTatsunoko(c)
return c:IsCode(55863245)
end
function Synchro.SortMaterials(materials,tc,tuner_filter)
table.sort(materials,function(a,b)
if Synchro.IsMono(a)~=Synchro.IsMono(b) then
return Synchro.IsMono(a) -- monos first
end
if Synchro.IsFlower(a)~=Synchro.IsFlower(b) then
return Synchro.IsFlower(a) -- then flowers
end
if Synchro.IsTatsunoko(a)~=Synchro.IsTatsunoko(b) then
return Synchro.IsTatsunoko(a) -- then tatsunoko
end
if tuner_filter(a,tc)~=tuner_filter(b,tc) then
return tuner_filter(a,tc) -- then tuner
end
-- otherwise normals: sort descending by level
return a:GetLevel()>b:GetLevel()
end)
end
function Synchro.IsLevelAlter(c)
return Synchro.IsMono(c) or Synchro.IsFlower(c)
end
function Synchro.IsHandAlter(c)
return Synchro.IsTatsunoko(c)
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