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
3
Merge Requests
3
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
MyCard
ygopro-scripts-888
Commits
e31bc28c
Commit
e31bc28c
authored
Jun 25, 2025
by
Vury Leo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lint
parent
4451e60b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
115 deletions
+126
-115
c29071332.lua
c29071332.lua
+1
-1
procedure.lua
procedure.lua
+125
-114
No files found.
c29071332.lua
View file @
e31bc28c
--アームズ・エイド
--アームズ・エイド
function
c29071332
.
initial_effect
(
c
)
function
c29071332
.
initial_effect
(
c
)
--synchro summon
--synchro summon
aux
.
AddSynchroProcedure
(
c
,
nil
,
aux
.
NonTuner
(
nil
),
1
)
Synchro
.
AddSynchroProcedure
(
c
)
c
:
EnableReviveLimit
()
c
:
EnableReviveLimit
()
--equip
--equip
local
e1
=
Effect
.
CreateEffect
(
c
)
local
e1
=
Effect
.
CreateEffect
(
c
)
...
...
procedure.lua
View file @
e31bc28c
...
@@ -3454,12 +3454,12 @@ Synchro.Infinite={}
...
@@ -3454,12 +3454,12 @@ Synchro.Infinite={}
--- @param params? table -- parameters table with keys: f1,f2,minc,maxc
--- @param params? table -- parameters table with keys: f1,f2,minc,maxc
function
Synchro
.
AddSynchroProcedure
(
c
,
params
)
function
Synchro
.
AddSynchroProcedure
(
c
,
params
)
params
=
params
or
{}
params
=
params
or
{}
local
tuner
Filter
=
params
.
tunerF
ilter
or
function
(
mc
,
tc
)
return
mc
:
IsType
(
TYPE_TUNER
)
end
local
tuner
_filter
=
params
.
tuner_f
ilter
or
function
(
mc
,
tc
)
return
mc
:
IsType
(
TYPE_TUNER
)
end
local
non
TunerFilter
=
params
.
nonTunerF
ilter
or
function
(
mc
,
tc
)
return
not
mc
:
IsType
(
TYPE_TUNER
)
end
local
non
_tuner_filter
=
params
.
non_tuner_f
ilter
or
function
(
mc
,
tc
)
return
not
mc
:
IsType
(
TYPE_TUNER
)
end
local
tuner
Min
=
params
.
tunerM
in
or
1
local
tuner
_min
=
params
.
tuner_m
in
or
1
local
tuner
Max
=
params
.
tunerM
ax
or
1
local
tuner
_max
=
params
.
tuner_m
ax
or
1
local
non
TunerMin
=
params
.
nonTunerM
in
or
1
local
non
_tuner_min
=
params
.
non_tuner_m
in
or
1
local
non
TunerMax
=
params
.
nonTunerM
ax
or
Synchro
.
Infinite
local
non
_tuner_max
=
params
.
non_tuner_m
ax
or
Synchro
.
Infinite
local
e1
=
Effect
.
CreateEffect
(
c
)
local
e1
=
Effect
.
CreateEffect
(
c
)
e1
:
SetDescription
(
1164
)
e1
:
SetDescription
(
1164
)
...
@@ -3467,8 +3467,8 @@ function Synchro.AddSynchroProcedure(c,params)
...
@@ -3467,8 +3467,8 @@ function Synchro.AddSynchroProcedure(c,params)
e1
:
SetCode
(
EFFECT_SPSUMMON_PROC
)
e1
:
SetCode
(
EFFECT_SPSUMMON_PROC
)
e1
:
SetProperty
(
EFFECT_FLAG_CANNOT_DISABLE
+
EFFECT_FLAG_UNCOPYABLE
)
e1
:
SetProperty
(
EFFECT_FLAG_CANNOT_DISABLE
+
EFFECT_FLAG_UNCOPYABLE
)
e1
:
SetRange
(
LOCATION_EXTRA
)
e1
:
SetRange
(
LOCATION_EXTRA
)
e1
:
SetCondition
(
Synchro
.
SynCondition
(
tuner
Filter
,
nonTunerFilter
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
))
e1
:
SetCondition
(
Synchro
.
SynCondition
(
tuner
_filter
,
non_tuner_filter
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
))
e1
:
SetTarget
(
Synchro
.
SynTarget
(
tuner
Filter
,
nonTunerFilter
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
))
e1
:
SetTarget
(
Synchro
.
SynTarget
(
tuner
_filter
,
non_tuner_filter
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
))
e1
:
SetOperation
(
Synchro
.
SynOperation
())
e1
:
SetOperation
(
Synchro
.
SynOperation
())
e1
:
SetValue
(
SUMMON_TYPE_SYNCHRO
)
e1
:
SetValue
(
SUMMON_TYPE_SYNCHRO
)
c
:
RegisterEffect
(
e1
)
c
:
RegisterEffect
(
e1
)
...
@@ -3478,84 +3478,73 @@ end
...
@@ -3478,84 +3478,73 @@ end
--- satisfying tuner/non-tuner counts and total level, supporting multiple possible levels per card.
--- satisfying tuner/non-tuner counts and total level, supporting multiple possible levels per card.
---
---
--- @param candidates Card[] -- Array of candidate material cards.
--- @param candidates Card[] -- Array of candidate material cards.
--- @param target
L
evel integer -- Required total level for Synchro Summon.
--- @param target
_l
evel integer -- Required total level for Synchro Summon.
--- @param tuner
Filter fun(card:Card,targetCard
:Card):boolean
--- @param tuner
_filter fun(card:Card,tc
:Card):boolean
--- -- Function to identify tuner materials.
--- -- Function to identify tuner materials.
--- @param non
TunerFilter fun(card:Card,targetCard
:Card):boolean
--- @param non
_tuner_filter fun(card:Card,tc
:Card):boolean
--- -- Function to identify non-tuner materials.
--- -- Function to identify non-tuner materials.
--- @param t
argetCard
Card -- The Synchro monster being summoned.
--- @param t
c
Card -- The Synchro monster being summoned.
--- @param tuner
M
in integer -- Minimum number of tuner materials required.
--- @param tuner
_m
in integer -- Minimum number of tuner materials required.
--- @param tuner
M
ax integer|table -- Maximum number of tuner materials allowed.
--- @param tuner
_m
ax integer|table -- Maximum number of tuner materials allowed.
--- @param non
TunerM
in integer -- Minimum number of non-tuner materials required.
--- @param non
_tuner_m
in integer -- Minimum number of non-tuner materials required.
--- @param non
TunerM
ax integer|table -- Maximum number of non-tuner materials allowed.
--- @param non
_tuner_m
ax integer|table -- Maximum number of non-tuner materials allowed.
--- @param levelMapper fun(card:Card,t
argetCard
:Card):integer[]
--- @param levelMapper fun(card:Card,t
c
:Card):integer[]
--- -- Function returning possible levels for a card.
--- -- Function returning possible levels for a card.
--- @param selected? Card[] -- Currently selected material cards.
--- @param selected? Card[] -- Currently selected material cards.
--- @param index? integer -- Current index in candidates for DFS (default 1).
--- @param index? integer -- Current index in candidates for DFS (default 1).
--- @param state? table -- DFS state table containing:
--- @param state? table -- DFS state table containing:
--- -- sum (integer): current total level sum,
--- -- sum (integer): current total level sum,
--- -- tuner
C
ount (integer): current tuner count,
--- -- tuner
_c
ount (integer): current tuner count,
--- -- non
TunerC
ount (integer): current non-tuner count.
--- -- non
_tuner_c
ount (integer): current non-tuner count.
--- @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
,
tunerFilter
,
nonTunerFilter
,
targetCard
,
function
Synchro
.
CanCompleteSelection
(
candidates
,
target
_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner
Min
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
,
levelMapper
,
selected
,
index
,
state
)
tuner
_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
,
levelMapper
,
selected
,
index
,
state
)
index
=
index
or
1
index
=
index
or
1
selected
=
selected
or
{}
selected
=
selected
or
{}
state
=
state
or
{
state
=
state
or
{
possible
Sums
=
{[
0
]
=
true
},
possible
_sums
=
{[
0
]
=
true
},
tuner
Count
=
0
,
tuner
_count
=
0
,
non
TunerCount
=
0
,
non
_tuner_count
=
0
,
}
}
if
Synchro
.
ExceedsMax
(
state
.
tuner
Count
,
tunerM
ax
)
then
return
false
end
if
Synchro
.
ExceedsMax
(
state
.
tuner
_count
,
tuner_m
ax
)
then
return
false
end
if
Synchro
.
ExceedsMax
(
state
.
non
TunerCount
,
nonTunerM
ax
)
then
return
false
end
if
Synchro
.
ExceedsMax
(
state
.
non
_tuner_count
,
non_tuner_m
ax
)
then
return
false
end
if
index
>#
candidates
then
if
index
>#
candidates
then
-- check if target
L
evel achievable exactly
-- check if target
_l
evel achievable exactly
if
state
.
possible
Sums
[
targetL
evel
]
and
if
state
.
possible
_sums
[
target_l
evel
]
and
state
.
tuner
Count
>=
tunerM
in
and
state
.
tuner
_count
>=
tuner_m
in
and
state
.
non
TunerCount
>=
nonTunerM
in
then
state
.
non
_tuner_count
>=
non_tuner_m
in
then
return
true
return
true
end
end
return
false
return
false
end
end
local
card
=
candidates
[
index
]
local
mc
=
candidates
[
index
]
local
lvls
=
levelMapper
(
card
,
targetCard
)
local
lvls
=
levelMapper
(
mc
,
tc
)
local
tuner
Inc
=
tunerFilter
(
card
,
targetCard
)
and
1
or
0
local
tuner
_inc
=
tuner_filter
(
mc
,
tc
)
and
1
or
0
local
non
TunerInc
=
nonTunerFilter
(
card
,
targetCard
)
and
1
or
0
local
non
_tuner_inc
=
non_tuner_filter
(
mc
,
tc
)
and
1
or
0
local
new
PossibleSums
=
Synchro
.
UpdatePossibleSums
(
state
.
possibleSums
,
lvls
,
targetL
evel
)
local
new
possible_sums
=
Synchro
.
Updatepossible_sums
(
state
.
possible_sums
,
lvls
,
target_l
evel
)
if
next
(
newPossibleSums
)
then
if
next
(
newpossible_sums
)
then
-- push state
local
new_state
=
{
local
prevPossibleSums
=
state
.
possibleSums
possible_sums
=
newpossible_sums
,
local
prevTunerCount
=
state
.
tunerCount
tuner_count
=
state
.
tuner_count
+
tuner_inc
,
local
prevNonTunerCount
=
state
.
nonTunerCount
non_tuner_count
=
state
.
non_tuner_count
+
non_tuner_inc
,
}
state
.
possibleSums
=
newPossibleSums
table.insert
(
selected
,
mc
)
state
.
tunerCount
=
state
.
tunerCount
+
tunerInc
if
Synchro
.
CanCompleteSelection
(
candidates
,
target_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
state
.
nonTunerCount
=
state
.
nonTunerCount
+
nonTunerInc
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_max
,
levelMapper
,
selected
,
index
+
1
,
new_state
)
then
table.insert
(
selected
,
card
)
if
Synchro
.
CanCompleteSelection
(
candidates
,
targetLevel
,
tunerFilter
,
nonTunerFilter
,
targetCard
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerMax
,
levelMapper
,
selected
,
index
+
1
,
state
)
then
table.remove
(
selected
)
table.remove
(
selected
)
-- pop state
state
.
possibleSums
=
prevPossibleSums
state
.
tunerCount
=
prevTunerCount
state
.
nonTunerCount
=
prevNonTunerCount
return
true
return
true
end
end
table.remove
(
selected
)
table.remove
(
selected
)
-- pop state
state
.
possibleSums
=
prevPossibleSums
state
.
tunerCount
=
prevTunerCount
state
.
nonTunerCount
=
prevNonTunerCount
end
end
-- Option: exclude this card
-- Option: exclude this card
if
Synchro
.
CanCompleteSelection
(
candidates
,
target
Level
,
tunerFilter
,
nonTunerFilter
,
targetCard
,
if
Synchro
.
CanCompleteSelection
(
candidates
,
target
_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner
Min
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
,
levelMapper
,
selected
,
index
+
1
,
state
)
then
tuner
_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
,
levelMapper
,
selected
,
index
+
1
,
state
)
then
return
true
return
true
end
end
...
@@ -3563,23 +3552,23 @@ function Synchro.CanCompleteSelection(candidates,targetLevel,tunerFilter,nonTune
...
@@ -3563,23 +3552,23 @@ function Synchro.CanCompleteSelection(candidates,targetLevel,tunerFilter,nonTune
end
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
Filter
,
nonTunerFilter
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
)
function
Synchro
.
SynCondition
(
tuner
_filter
,
non_tuner_filter
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
)
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
local
target
L
evel
=
c
:
GetLevel
()
local
target
_l
evel
=
c
:
GetLevel
()
mg
=
mg
or
Duel
.
GetMatchingGroup
(
Card
.
IsCanBeSynchroMaterial
,
c
:
GetControler
(),
LOCATION_MZONE
+
LOCATION_HAND
,
0
,
nil
)
mg
=
mg
or
Duel
.
GetMatchingGroup
(
Card
.
IsCanBeSynchroMaterial
,
c
:
GetControler
(),
LOCATION_MZONE
+
LOCATION_HAND
,
0
,
nil
)
local
candidates
=
{}
local
candidates
=
{}
for
card
in
aux
.
Next
(
mg
)
do
for
mc
in
aux
.
Next
(
mg
)
do
table.insert
(
candidates
,
card
)
table.insert
(
candidates
,
mc
)
end
end
return
Synchro
.
CanCompleteSelection
(
candidates
,
target
Level
,
tunerFilter
,
nonTunerFilter
,
c
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
,
Synchro
.
LevelMapper
)
return
Synchro
.
CanCompleteSelection
(
candidates
,
target
_level
,
tuner_filter
,
non_tuner_filter
,
c
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
,
Synchro
.
LevelMapper
)
end
end
end
end
function
Synchro
.
SynTarget
(
tuner
Filter
,
nonTunerFilter
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
)
function
Synchro
.
SynTarget
(
tuner
_filter
,
non_tuner_filter
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
)
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
)
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
()
...
@@ -3594,12 +3583,12 @@ function Synchro.SynTarget(tunerFilter,nonTunerFilter,tunerMin,tunerMax,nonTuner
...
@@ -3594,12 +3583,12 @@ function Synchro.SynTarget(tunerFilter,nonTunerFilter,tunerMin,tunerMax,nonTuner
local
addable
=
Group
.
CreateGroup
()
local
addable
=
Group
.
CreateGroup
()
local
sg_arr
=
GroupToArray
(
sg
)
local
sg_arr
=
GroupToArray
(
sg
)
local
cg_arr
=
GroupToArray
(
mg
-
sg
)
local
cg_arr
=
GroupToArray
(
mg
-
sg
)
local
target
L
evel
=
tc
:
GetLevel
()
local
target
_l
evel
=
tc
:
GetLevel
()
for
_
,
candidate
in
ipairs
(
cg_arr
)
do
for
_
,
candidate
in
ipairs
(
cg_arr
)
do
-- simulate adding candidate to sg_arr
-- simulate adding candidate to sg_arr
local
test
S
election
=
{}
local
test
_s
election
=
{}
for
_
,
card
in
ipairs
(
sg_arr
)
do
table.insert
(
test
S
election
,
card
)
end
for
_
,
card
in
ipairs
(
sg_arr
)
do
table.insert
(
test
_s
election
,
card
)
end
table.insert
(
test
S
election
,
candidate
)
table.insert
(
test
_s
election
,
candidate
)
-- build rest_candidates without candidate
-- build rest_candidates without candidate
local
rest_candidates
=
{}
local
rest_candidates
=
{}
...
@@ -3611,18 +3600,18 @@ function Synchro.SynTarget(tunerFilter,nonTunerFilter,tunerMin,tunerMax,nonTuner
...
@@ -3611,18 +3600,18 @@ function Synchro.SynTarget(tunerFilter,nonTunerFilter,tunerMin,tunerMax,nonTuner
if
Synchro
.
CanCompleteSelection
(
if
Synchro
.
CanCompleteSelection
(
rest_candidates
,
rest_candidates
,
target
L
evel
,
target
_l
evel
,
tuner
F
ilter
,
tuner
_f
ilter
,
non
TunerF
ilter
,
non
_tuner_f
ilter
,
tc
,
tc
,
tuner
M
in
,
tuner
_m
in
,
tuner
M
ax
,
tuner
_m
ax
,
non
TunerM
in
,
non
_tuner_m
in
,
non
TunerM
ax
,
non
_tuner_m
ax
,
Synchro
.
LevelMapper
,
Synchro
.
LevelMapper
,
test
S
election
,
test
_s
election
,
1
,
1
,
Synchro
.
BuildStateFromSelection
(
test
Selection
,
tunerFilter
,
nonTunerFilter
,
Synchro
.
LevelMapper
,
tc
,
targetL
evel
)
Synchro
.
BuildStateFromSelection
(
test
_selection
,
tuner_filter
,
non_tuner_filter
,
Synchro
.
LevelMapper
,
tc
,
target_l
evel
)
)
then
)
then
addable
:
AddCard
(
candidate
)
addable
:
AddCard
(
candidate
)
end
end
...
@@ -3632,9 +3621,9 @@ function Synchro.SynTarget(tunerFilter,nonTunerFilter,tunerMin,tunerMax,nonTuner
...
@@ -3632,9 +3621,9 @@ function Synchro.SynTarget(tunerFilter,nonTunerFilter,tunerMin,tunerMax,nonTuner
break
break
end
end
local
finishable
=
Synchro
.
IsSelectionValid
(
sg_arr
,
target
Level
,
tunerFilter
,
nonTunerFilter
,
tc
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
)
local
finishable
=
Synchro
.
IsSelectionValid
(
sg_arr
,
target
_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
)
local
picked
=
Group
.
SelectUnselect
(
addable
,
sg
,
tp
,
finishable
,
true
,
tuner
Min
+
nonTunerMin
,
Synchro
.
GetDisplayMax
(
tunerMax
,
nonTunerM
ax
))
local
picked
=
Group
.
SelectUnselect
(
addable
,
sg
,
tp
,
finishable
,
true
,
tuner
_min
+
non_tuner_min
,
Synchro
.
GetDisplayMax
(
tuner_max
,
non_tuner_m
ax
))
if
not
picked
then
if
not
picked
then
-- user clicked Complete
-- user clicked Complete
...
@@ -3675,22 +3664,22 @@ function Synchro.ExceedsMax(count,max)
...
@@ -3675,22 +3664,22 @@ function Synchro.ExceedsMax(count,max)
return
count
>
max
return
count
>
max
end
end
function
Synchro
.
GetDisplayMax
(
tuner
Max
,
nonTunerM
ax
)
function
Synchro
.
GetDisplayMax
(
tuner
_max
,
non_tuner_m
ax
)
if
tuner
Max
==
Synchro
.
Infinite
or
nonTunerM
ax
==
Synchro
.
Infinite
then
if
tuner
_max
==
Synchro
.
Infinite
or
non_tuner_m
ax
==
Synchro
.
Infinite
then
return
99
return
99
end
end
return
tuner
Max
+
nonTunerM
ax
return
tuner
_max
+
non_tuner_m
ax
end
end
function
Synchro
.
IsSelectionValid
(
selection
,
target
Level
,
tunerFilter
,
nonTunerFilter
,
targetCard
,
tunerMin
,
tunerMax
,
nonTunerMin
,
nonTunerM
ax
)
function
Synchro
.
IsSelectionValid
(
selection
,
target
_level
,
tuner_filter
,
non_tuner_filter
,
tc
,
tuner_min
,
tuner_max
,
non_tuner_min
,
non_tuner_m
ax
)
local
state
=
Synchro
.
BuildStateFromSelection
(
selection
,
tuner
Filter
,
nonTunerFilter
,
Synchro
.
LevelMapper
,
targetCard
,
targetL
evel
)
local
state
=
Synchro
.
BuildStateFromSelection
(
selection
,
tuner
_filter
,
non_tuner_filter
,
Synchro
.
LevelMapper
,
tc
,
target_l
evel
)
-- check if target
L
evel achievable exactly
-- check if target
_l
evel achievable exactly
if
Synchro
.
ExceedsMax
(
state
.
tuner
Count
,
tunerM
ax
)
then
return
false
end
if
Synchro
.
ExceedsMax
(
state
.
tuner
_count
,
tuner_m
ax
)
then
return
false
end
if
Synchro
.
ExceedsMax
(
state
.
non
TunerCount
,
nonTunerM
ax
)
then
return
false
end
if
Synchro
.
ExceedsMax
(
state
.
non
_tuner_count
,
non_tuner_m
ax
)
then
return
false
end
if
state
.
possible
Sums
[
targetL
evel
]
and
if
state
.
possible
_sums
[
target_l
evel
]
and
state
.
tuner
Count
>=
tunerM
in
and
state
.
tuner
_count
>=
tuner_m
in
and
state
.
non
TunerCount
>=
nonTunerM
in
then
state
.
non
_tuner_count
>=
non_tuner_m
in
then
return
true
return
true
end
end
return
false
return
false
...
@@ -3698,16 +3687,16 @@ end
...
@@ -3698,16 +3687,16 @@ end
--- Returns a list of possible levels this card can be treated as when used as Synchro material.
--- Returns a list of possible levels this card can be treated as when used as Synchro material.
--- @param card Card -- The candidate material card.
--- @param card Card -- The candidate material card.
--- @param t
argetCard
Card -- The Synchro monster being summoned.
--- @param t
c
Card -- The Synchro monster being summoned.
--- @return integer[] -- Array of possible level integers (e.g., {1} or {1,2}).
--- @return integer[] -- Array of possible level integers (e.g., {1} or {1,2}).
function
Synchro
.
LevelMapper
(
card
,
t
argetCard
)
function
Synchro
.
LevelMapper
(
card
,
t
c
)
Debug
.
Message
(
string.format
(
"lvel mapper for %d"
,
card
:
GetCode
()))
Debug
.
Message
(
string.format
(
"lvel mapper for %d"
,
card
:
GetCode
()))
local
levelDict
=
{}
local
levelDict
=
{}
local
effs
=
{
card
:
IsHasEffect
(
EFFECT_SYNCHRO_LEVEL
)}
local
effs
=
{
card
:
IsHasEffect
(
EFFECT_SYNCHRO_LEVEL
)}
Debug
.
Message
(
string.format
(
"lvel mapper for %d, effs %d"
,
card
:
GetCode
(),
#
effs
))
Debug
.
Message
(
string.format
(
"lvel mapper for %d, effs %d"
,
card
:
GetCode
(),
#
effs
))
if
#
effs
>
0
then
if
#
effs
>
0
then
local
val
=
effs
[
1
]:
GetValue
()(
effs
[
1
],
t
argetCard
)
local
val
=
effs
[
1
]:
GetValue
()(
effs
[
1
],
t
c
)
Debug
.
Message
(
string.format
(
"lvel mapper for %d, effs %d"
,
card
:
GetCode
(),
#
effs
))
Debug
.
Message
(
string.format
(
"lvel mapper for %d, effs %d"
,
card
:
GetCode
(),
#
effs
))
if
type
(
val
)
==
"table"
then
if
type
(
val
)
==
"table"
then
for
_
,
v
in
ipairs
(
val
)
do
for
_
,
v
in
ipairs
(
val
)
do
...
@@ -3735,12 +3724,12 @@ function Synchro.LevelMapper(card,targetCard)
...
@@ -3735,12 +3724,12 @@ function Synchro.LevelMapper(card,targetCard)
return
levels
return
levels
end
end
function
Synchro
.
Update
PossibleSums
(
possibleSums
,
cardLevels
,
targetL
evel
)
function
Synchro
.
Update
possible_sums
(
possible_sums
,
cardLevels
,
target_l
evel
)
local
newSums
=
{}
local
newSums
=
{}
for
sum
,
_
in
pairs
(
possible
S
ums
)
do
for
sum
,
_
in
pairs
(
possible
_s
ums
)
do
for
_
,
lvl
in
ipairs
(
cardLevels
)
do
for
_
,
lvl
in
ipairs
(
cardLevels
)
do
local
newSum
=
sum
+
lvl
local
newSum
=
sum
+
lvl
if
newSum
<=
targetL
evel
then
if
newSum
<=
target_l
evel
then
newSums
[
newSum
]
=
true
newSums
[
newSum
]
=
true
end
end
end
end
...
@@ -3748,24 +3737,24 @@ function Synchro.UpdatePossibleSums(possibleSums, cardLevels, targetLevel)
...
@@ -3748,24 +3737,24 @@ function Synchro.UpdatePossibleSums(possibleSums, cardLevels, targetLevel)
return
newSums
return
newSums
end
end
function
Synchro
.
BuildStateFromSelection
(
sg_arr
,
tuner
Filter
,
nonTunerFilter
,
levelMapper
,
targetCard
,
targetL
evel
)
function
Synchro
.
BuildStateFromSelection
(
sg_arr
,
tuner
_filter
,
non_tuner_filter
,
levelMapper
,
tc
,
target_l
evel
)
local
possible
S
ums
=
{[
0
]
=
true
}
local
possible
_s
ums
=
{[
0
]
=
true
}
local
tuner
C
ount
=
0
local
tuner
_c
ount
=
0
local
non
TunerC
ount
=
0
local
non
_tuner_c
ount
=
0
for
_
,
card
in
ipairs
(
sg_arr
)
do
for
_
,
card
in
ipairs
(
sg_arr
)
do
local
levels
=
levelMapper
(
card
,
t
argetCard
)
local
levels
=
levelMapper
(
card
,
t
c
)
possible
Sums
=
Synchro
.
UpdatePossibleSums
(
possibleSums
,
levels
,
targetL
evel
)
possible
_sums
=
Synchro
.
Updatepossible_sums
(
possible_sums
,
levels
,
target_l
evel
)
if
next
(
possible
S
ums
)
==
nil
then
if
next
(
possible
_s
ums
)
==
nil
then
-- no possible sums from current selection, invalid state
-- no possible sums from current selection, invalid state
assert
(
false
)
assert
(
false
)
return
{}
return
{}
end
end
if
tuner
Filter
(
card
,
targetCard
)
then
if
tuner
_filter
(
card
,
tc
)
then
tuner
Count
=
tunerC
ount
+
1
tuner
_count
=
tuner_c
ount
+
1
elseif
non
TunerFilter
(
card
,
targetCard
)
then
elseif
non
_tuner_filter
(
card
,
tc
)
then
non
TunerCount
=
nonTunerC
ount
+
1
non
_tuner_count
=
non_tuner_c
ount
+
1
else
else
assert
(
false
)
assert
(
false
)
return
{}
-- invalid material type
return
{}
-- invalid material type
...
@@ -3773,8 +3762,30 @@ function Synchro.BuildStateFromSelection(sg_arr, tunerFilter, nonTunerFilter, le
...
@@ -3773,8 +3762,30 @@ function Synchro.BuildStateFromSelection(sg_arr, tunerFilter, nonTunerFilter, le
end
end
return
{
return
{
possible
Sums
=
possibleS
ums
,
possible
_sums
=
possible_s
ums
,
tuner
Count
=
tunerC
ount
,
tuner
_count
=
tuner_c
ount
,
non
TunerCount
=
nonTunerC
ount
,
non
_tuner_count
=
non_tuner_c
ount
,
}
}
end
end
function
Synchro
.
DeepcopyState
(
base_state
)
local
new_state
=
{}
-- Copy primitive flags and counters
new_state
.
tuner_count
=
base_state
and
base_state
.
tuner_count
or
0
new_state
.
non_tuner_count
=
base_state
and
base_state
.
non_tuner_count
or
0
-- Copy or create possible sums table
if
base_state
and
base_state
.
possible_sums
then
new_state
.
possible_sums
=
{}
for
k
,
v
in
pairs
(
base_state
.
possible_sums
)
do
new_state
.
possible_sums
[
k
]
=
v
end
else
new_state
.
possible_sums
=
{[
0
]
=
true
}
end
-- Copy other as needed
return
new_state
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