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
aff94e43
Commit
aff94e43
authored
Jul 01, 2025
by
Vury Leo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Tatsunoko
parent
98f9633c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
93 deletions
+161
-93
procedure.lua
procedure.lua
+161
-93
No files found.
procedure.lua
View file @
aff94e43
...
...
@@ -3375,7 +3375,7 @@ end
Synchro
=
{}
-- Use this as the "infinite" maximum count
Synchro.Infinite=
{}
Synchro
.
Infinite
=
math.huge
--- Add Synchro procedure effect to a card using a single params table
--- @param c Card -- the Synchro monster card
...
...
@@ -3419,6 +3419,10 @@ function Synchro.FindValidSelection(candidates,target_level,
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
...
...
@@ -3426,11 +3430,17 @@ function Synchro.FindValidSelection(candidates,target_level,
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
)
-- 2) Find the index of the last
dynamic
card
-- 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
...
...
@@ -3438,6 +3448,14 @@ function Synchro.FindValidSelection(candidates,target_level,
end
end
-- 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
hand_prune_index
=
i
end
end
-- 3) Invoke the core DFS, passing last_dyn along
return
Synchro
.
CanCompleteSelection
(
candidates
,
target_level
,
...
...
@@ -3453,9 +3471,12 @@ function Synchro.FindValidSelection(candidates,target_level,
non_tuner_count
=
0
,
level_mapper
=
base_mapper
,
level_mapper_priority
=
0
,
hand_count_limit
=
0
,
hand_count
=
0
,
},
{
level_prune_index=level_prune_index
level_prune_index
=
level_prune_index
,
hand_prune_index
=
hand_prune_index
,
}
)
end
...
...
@@ -3489,8 +3510,8 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
--- Mono Synchron (priority=2) > Flower Cardian (1) > normal (0)
local
mapper
=
state
.
level_mapper
if
Synchro.ExceedsMax(state.tuner_count,tuner_max)
then return false end
if
Synchro.ExceedsMax(state.non_tuner_count,non_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
index
>#
candidates
then
-- check if target_level achievable exactly
...
...
@@ -3511,88 +3532,111 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_filter,non_t
local
mc
=
candidates
[
index
]
local
tuner_inc
=
tuner_filter
(
mc
,
tc
)
and
1
or
0
local
non_tuner_inc
=
non_tuner_filter
(
mc
,
tc
)
and
1
or
0
local
hand_inc
=
mc
:
IsLocation
(
LOCATION_HAND
)
and
1
or
0
-- include branch
local
variants
=
{}
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
if mc:IsCode(56897896) then
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}
-- build inclusion variants if prune not blocking
-- before/at hand_prune_index: allow any hand inclusion (no limit)
-- after hand_prune_index: enforce state.hand_count + hand_inc <= hand_max
local
can_include
=
(
index
<=
prune_indexes
.
hand_prune_index
)
or
(
state
.
hand_count
+
hand_inc
<=
state
.
hand_count_limit
)
if
can_include
then
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
if
mc
:
IsCode
(
56897896
)
then
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
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
-- 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=sums
1
,
level_mapper=
mono
_mapper,
level_mapper_priority=2,
possible_sums
=
sums
2
,
level_mapper
=
full
_mapper
,
level_mapper_priority
=
2
,
-- stays in Mono mode
})
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
if not mc:IsCode(56897896) 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,level_mapper=mapper})
--- mono is mandatory so it can not be include Normal
--- Tatsunoko never harm to enable
if
not
mc
:
IsCode
(
56897896
,
55863245
)
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
end
-- 2) override if Flower Cardian
if mc:IsCode(57261568,33541430,89818984) then
if state.level_mapper_priority<1 then
local cnt=#selected+1
local sums_ovr={[2*cnt]=true}
-- override if Flower Cardian
if
mc
:
IsCode
(
57261568
,
33541430
,
89818984
)
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
mc
:
IsCode
(
55863245
)
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_ovr,
level_mapper=function() return{2} end,
level_mapper_priority=1
possible_sums
=
sums_tats
,
hand_count_limit
=
1
,
})
end
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,
level_mapper_priority=var.level_mapper_priority,
}
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
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
)
return true
end
table.remove(selected)
end
-- exclude branch
...
...
@@ -3736,18 +3780,6 @@ function Synchro.SynOperation()
end
end
function Synchro.ExceedsMax(count,max)
if max==Synchro.Infinite then return false end
return count>max
end
function Synchro.GetDisplayMax(tuner_max,non_tuner_max)
if tuner_max==Synchro.Infinite or non_tuner_max==Synchro.Infinite then
return 99
end
return tuner_max+non_tuner_max
end
function
Synchro
.
IsSelectionValid
(
selection
,
target_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_max
)
local
states
=
Synchro
.
BuildStatesFromSelection
(
selection
,
...
...
@@ -3755,16 +3787,14 @@ function Synchro.IsSelectionValid(selection,target_level,tuner_filter,non_tuner_
Synchro
.
LevelMapper
,
tc
,
0xff
)
for _,state in ipairs(states)do
if not Synchro.ExceedsMax(state.tuner_count,tuner_max) then
if not Synchro.ExceedsMax(state.non_tuner_count,non_tuner_max) then
if state.possible_sums[target_level]
and state.tuner_count>=tuner_min
and state.non_tuner_count>=non_tuner_min
then
return true
end
end
for
_
,
state
in
ipairs
(
states
)
do
if
state
.
tuner_count
<=
tuner_max
and
state
.
non_tuner_count
<=
non_tuner_max
and
state
.
possible_sums
[
target_level
]
and
state
.
tuner_count
>=
tuner_min
and
state
.
non_tuner_count
>=
non_tuner_min
then
return
true
end
end
...
...
@@ -3827,16 +3857,22 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
non_tuner_count
=
0
,
level_mapper
=
base_mapper
,
level_mapper_priority
=
0
,
hand_count_limit
=
0
,
hand_count
=
0
,
}
}
-- 1) Sort candidates: Mono first, then Flower, then normals
-- 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)
return
c
:
IsCode
(
57261568
,
33541430
,
89818984
)
end
local
function
is_tatsunoko
(
c
)
return
c
:
IsCode
(
55863245
)
end
table.sort
(
selection
,
function
(
a
,
b
)
...
...
@@ -3846,6 +3882,12 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
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
)
...
...
@@ -3856,6 +3898,7 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
for
_
,
st
in
ipairs
(
states
)
do
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
mapper
=
st
.
level_mapper
-- 1) MonoSynchron branch (priority<2 → first Mono; priority==2 → full Mono)
...
...
@@ -3877,6 +3920,8 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
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
...
...
@@ -3889,6 +3934,8 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
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
...
...
@@ -3904,6 +3951,8 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
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
...
...
@@ -3918,12 +3967,31 @@ function Synchro.BuildStatesFromSelection(selection,tuner_filter,non_tuner_filte
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
card
:
IsCode
(
55863245
)
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
if
#
states
==
0
then
break
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