Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-scripts-888
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vee4
ygopro-scripts-888
Commits
f71be13f
Commit
f71be13f
authored
Jul 02, 2025
by
Vury Leo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
c5f177cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
201 deletions
+98
-201
procedure.lua
procedure.lua
+98
-201
No files found.
procedure.lua
View file @
f71be13f
...
@@ -3480,10 +3480,10 @@ end
...
@@ -3480,10 +3480,10 @@ end
--- @return boolean -- True if a valid selection exists, false otherwise.
--- @return boolean -- True if a valid selection exists, false otherwise.
function
Synchro
.
CanCompleteSelection
(
candidates
,
target_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
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
)
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_max
,
base_mapper
,
selected
,
index
,
state
,
prune_indexes
)
local
mapper
=
state
.
level_mapper
if
state
.
tuner_count
>
tuner_max
then
return
false
end
if
state
.
tuner_count
>
tuner_max
then
return
false
end
if
state
.
non_tuner_count
>
non_tuner_max
then
return
false
end
if
state
.
non_tuner_count
>
non_tuner_max
then
return
false
end
if
(
index
>
prune_indexes
.
hand_prune_index
and
state
.
hand_count
>
state
.
hand_count_limit
)
then
return
false
end
if
index
>#
candidates
then
if
index
>#
candidates
then
-- check if target_level achievable exactly
-- check if target_level achievable exactly
...
@@ -3502,114 +3502,24 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
...
@@ -3502,114 +3502,24 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
end
end
local
mc
=
candidates
[
index
]
local
mc
=
candidates
[
index
]
local
tuner_inc
=
tuner_filter
(
mc
,
tc
)
and
1
or
0
for
_
,
diff
in
ipairs
(
Synchro
.
GenerateVariantForCard
(
local
non_tuner_inc
=
non_tuner_filter
(
mc
,
tc
)
and
1
or
0
state
,
mc
,
#
selected
+
1
,
tc
,
tuner_filter
,
non_tuner_filter
,
prune_level
local
hand_inc
=
mc
:
IsLocation
(
LOCATION_HAND
)
and
1
or
0
))
do
-- apply diff
-- include branch
local
branch_state
=
Synchro
.
ApplyVariantState
(
local
variants
=
{}
state
,
mc
,
diff
,
tuner_filter
,
non_tuner_filter
,
tc
,
prune_level
)
-- build inclusion variants if prune not blocking
table.insert
(
selected
,
mc
)
-- before/at hand_prune_index: allow any hand inclusion (no limit)
if
Synchro
.
CanCompleteSelection
(
-- after hand_prune_index: enforce state.hand_count + hand_inc <= hand_max
candidates
,
target_level
,
local
can_include
=
(
index
<=
prune_indexes
.
hand_prune_index
)
or
(
state
.
hand_count
+
hand_inc
<=
state
.
hand_count_limit
)
tuner_filter
,
non_tuner_filter
,
tc
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_max
,
if
can_include
then
base_mapper
,
selected
,
index
+
1
,
branch_state
,
prune_indexes
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
)
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
local
mono_mapper
=
function
(
c
,
tc_arg
)
if
c
==
firstMono
then
return
{
c
:
GetLevel
()}
else
return
{
1
}
end
end
-- reset your sums_so_far into a single bucket of (#selected)*1+self
local
sums1
=
{[
#
selected
+
mc
:
GetLevel
()]
=
true
}
if
next
(
sums1
)
~=
nil
then
table.insert
(
variants
,{
possible_sums
=
sums1
,
level_mapper
=
mono_mapper
,
level_mapper_priority
=
2
,
})
end
elseif
state
.
level_mapper_priority
==
2
then
-- second (or later) Mono: full override—all cards=Level 1
local
full_mapper
=
function
()
return
{
1
}
end
-- reset your sums_so_far into a single bucket of (#selected+1)*1
local
cnt
=#
selected
+
1
local
sums2
=
{[
cnt
]
=
true
}
table.insert
(
variants
,{
possible_sums
=
sums2
,
level_mapper
=
full_mapper
,
level_mapper_priority
=
2
,
-- stays in Mono mode
})
end
end
--- mono is mandatory so it can not be include Normal
--- Tatsunoko never harm to enable
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
)
if
next
(
sums_norm
)
then
table.insert
(
variants
,{
possible_sums
=
sums_norm
})
end
end
-- override if Flower Cardian
if
Synchro
.
IsFlower
(
mc
)
then
if
state
.
level_mapper_priority
<
1
then
local
cnt
=#
selected
+
1
local
sums_ovr
=
{[
2
*
cnt
]
=
true
}
table.insert
(
variants
,{
possible_sums
=
sums_ovr
,
level_mapper
=
function
()
return
{
2
}
end
,
level_mapper_priority
=
1
})
end
end
-- Tatsunoko effect: include and grant hand material slot
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
)
table.insert
(
variants
,{
possible_sums
=
sums_tats
,
hand_count_limit
=
1
,
})
end
for
_
,
var
in
ipairs
(
variants
)
do
local
new_state
=
{
possible_sums
=
var
.
possible_sums
,
tuner_count
=
state
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
state
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
var
.
level_mapper
or
state
.
level_mapper
,
level_mapper_priority
=
var
.
level_mapper_priority
or
state
.
level_mapper_priority
,
hand_count_limit
=
var
.
hand_count_limit
or
state
.
hand_count_limit
,
hand_count
=
state
.
hand_count
+
hand_inc
,
}
table.insert
(
selected
,
mc
)
if
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
+
1
,
new_state
,
prune_indexes
)
then
table.remove
(
selected
)
return
true
end
table.remove
(
selected
)
table.remove
(
selected
)
return
true
end
end
table.remove
(
selected
)
end
end
-- exclude branch
-- exclude branch
...
@@ -3718,6 +3628,7 @@ function Synchro.SynTarget(tuner_filter,non_tuner_filter,tuner_min,tuner_max,non
...
@@ -3718,6 +3628,7 @@ function Synchro.SynTarget(tuner_filter,non_tuner_filter,tuner_min,tuner_max,non
local
finishable
=
Synchro
.
IsSelectionValid
(
sg_arr
,
target_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_max
)
local
finishable
=
Synchro
.
IsSelectionValid
(
sg_arr
,
target_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_max
)
Duel
.
Hint
(
HINT_SELECTMSG
,
tp
,
HINTMSG_SMATERIAL
)
local
picked
=
Group
.
SelectUnselect
(
addable
,
sg
,
tp
,
finishable
,
true
,
selected_level_min
,
target_level
)
local
picked
=
Group
.
SelectUnselect
(
addable
,
sg
,
tp
,
finishable
,
true
,
selected_level_min
,
target_level
)
if
not
picked
then
if
not
picked
then
...
@@ -3840,100 +3751,17 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
...
@@ -3840,100 +3751,17 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
for
idx
,
card
in
ipairs
(
selection
)
do
for
idx
,
card
in
ipairs
(
selection
)
do
local
next_states
=
{}
local
next_states
=
{}
for
_
,
st
in
ipairs
(
states
)
do
for
_
,
st
in
ipairs
(
states
)
do
local
tuner_inc
=
tuner_filter
(
card
,
tc
)
and
1
or
0
for
_
,
diff
in
ipairs
(
Synchro
.
GenerateVariantForCard
(
local
non_tuner_inc
=
non_tuner_filter
(
card
,
tc
)
and
1
or
0
st
,
card
,
idx
,
tc
,
tuner_filter
,
non_tuner_filter
,
prune_level
local
hand_inc
=
card
:
IsLocation
(
LOCATION_HAND
)
and
1
or
0
))
do
local
mapper
=
st
.
level_mapper
-- merge diff into full state
local
new_state
=
Synchro
.
ApplyVariantState
(
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
st
,
card
,
diff
,
tuner_filter
,
non_tuner_filter
,
tc
,
prune_level
if
Synchro
.
IsMono
(
card
)
then
)
if
st
.
level_mapper_priority
<
2
then
table.insert
(
next_states
,
new_state
)
-- first Mono: that one keeps its real level, others=1
end
local
firstMono
=
card
end
local
mono_mapper
=
function
(
c
,
tc_arg
)
if
c
==
firstMono
then
return
{
c
:
GetLevel
()}
else
return
{
1
}
end
end
local
sums1
=
{[
idx
-
1
+
card
:
GetLevel
()]
=
true
}
table.insert
(
next_states
,{
possible_sums
=
sums1
,
tuner_count
=
st
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
st
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
mono_mapper
,
level_mapper_priority
=
2
,
hand_count_limit
=
st
.
hand_count_limit
,
hand_count
=
st
.
hand_count
+
hand_inc
,
})
elseif
st
.
level_mapper_priority
==
2
then
-- second (or later) Mono: full override—all cards=Level 1
local
full_mapper
=
function
()
return
{
1
}
end
-- reset your sums_so_far into a single bucket of idx*1
local
sums2
=
{[
idx
]
=
true
}
table.insert
(
next_states
,{
possible_sums
=
sums2
,
tuner_count
=
st
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
st
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
full_mapper
,
level_mapper_priority
=
2
,
-- stays in Mono mode
hand_count_limit
=
st
.
hand_count_limit
,
hand_count
=
st
.
hand_count
+
hand_inc
,
})
end
end
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
)
if
next
(
sums_norm
)
~=
nil
then
table.insert
(
next_states
,{
possible_sums
=
sums_norm
,
tuner_count
=
st
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
st
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
mapper
,
level_mapper_priority
=
st
.
level_mapper_priority
,
hand_count_limit
=
st
.
hand_count_limit
,
hand_count
=
st
.
hand_count
+
hand_inc
,
})
end
end
-- override level mapper branch if Flower Cardian
if
Synchro
.
IsFlower
(
card
)
then
if
st
.
level_mapper_priority
<
1
then
local
sums_ovr
=
{[
2
*
idx
]
=
true
}
table.insert
(
next_states
,{
possible_sums
=
sums_ovr
,
tuner_count
=
st
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
st
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
function
()
return
{
2
}
end
,
level_mapper_priority
=
1
,
hand_count_limit
=
st
.
hand_count_limit
,
hand_count
=
st
.
hand_count
+
hand_inc
,
})
end
end
-- increase hand count limit if tatsunoko
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
)
table.insert
(
next_states
,{
possible_sums
=
sums_tats
,
tuner_count
=
st
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
st
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
mapper
,
level_mapper_priority
=
st
.
level_mapper_priority
,
hand_count_limit
=
1
,
hand_count
=
st
.
hand_count
+
hand_inc
,
})
end
end
states
=
next_states
states
=
next_states
...
@@ -3983,3 +3811,72 @@ end
...
@@ -3983,3 +3811,72 @@ end
function
Synchro
.
IsHandAlter
(
c
)
function
Synchro
.
IsHandAlter
(
c
)
return
Synchro
.
IsTatsunoko
(
c
)
return
Synchro
.
IsTatsunoko
(
c
)
end
end
-- Helper to generate only the variant-specific diffs for a card
function
Synchro
.
GenerateVariantForCard
(
st
,
card
,
idx
,
tc
,
tuner_filter
,
non_tuner_filter
,
prune_level
)
local
variants
=
{}
-- MonoSynchron first/second
if
Synchro
.
IsMono
(
card
)
then
if
st
.
level_mapper_priority
<
2
then
local
firstMono
=
card
table.insert
(
variants
,{
possible_sums
=
{[(
idx
-
1
)
+
card
:
GetLevel
()]
=
true
},
level_mapper
=
function
(
c
)
return
(
c
==
firstMono
)
and
{
c
:
GetLevel
()}
or
{
1
}
end
,
level_mapper_priority
=
2
,
})
elseif
st
.
level_mapper_priority
==
2
then
table.insert
(
variants
,{
possible_sums
=
{[
idx
]
=
true
},
level_mapper
=
function
()
return
{
1
}
end
,
})
end
end
-- Normal branch
if
not
(
Synchro
.
IsMono
(
card
)
or
Synchro
.
IsTatsunoko
(
card
))
then
table.insert
(
variants
,{})
end
-- Flower Cardian override
if
Synchro
.
IsFlower
(
card
)
and
st
.
level_mapper_priority
<
1
then
table.insert
(
variants
,{
possible_sums
=
{[
2
*
idx
]
=
true
},
level_mapper
=
function
()
return
{
2
}
end
,
level_mapper_priority
=
1
,
})
end
-- Tatsunoko effect
if
Synchro
.
IsTatsunoko
(
card
)
then
table.insert
(
variants
,{
hand_count_limit
=
1
,
})
end
return
variants
end
-- Helper to apply a diff to a base state
function
Synchro
.
ApplyVariantState
(
st
,
card
,
diff
,
tuner_filter
,
non_tuner_filter
,
tc
,
prune_level
)
-- compute increments using provided filters
local
tuner_inc
=
tuner_filter
(
card
,
tc
)
and
1
or
0
local
non_tuner_inc
=
non_tuner_filter
(
card
,
tc
)
and
1
or
0
local
hand_inc
=
card
:
IsLocation
(
LOCATION_HAND
)
and
1
or
0
local
possible_sums
=
Synchro
.
UpdatepossibleSums
(
st
.
possible_sums
,
st
.
level_mapper
(
card
,
tc
),
prune_level
)
return
{
possible_sums
=
diff
.
possible_sums
or
possible_sums
,
tuner_count
=
st
.
tuner_count
+
tuner_inc
,
non_tuner_count
=
st
.
non_tuner_count
+
non_tuner_inc
,
level_mapper
=
diff
.
level_mapper
or
st
.
level_mapper
,
level_mapper_priority
=
diff
.
level_mapper_priority
or
st
.
level_mapper_priority
,
hand_count_limit
=
diff
.
hand_count_limit
or
st
.
hand_count_limit
,
hand_count
=
st
.
hand_count
+
hand_inc
,
}
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment