Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
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
nanahira
ygopro-core
Commits
e631d73f
Commit
e631d73f
authored
Jun 21, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add interpreter::check_filter
parent
cbca8ce7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
20 deletions
+24
-20
interpreter.cpp
interpreter.cpp
+17
-14
interpreter.h
interpreter.h
+1
-0
libgroup.cpp
libgroup.cpp
+6
-6
No files found.
interpreter.cpp
View file @
e631d73f
...
...
@@ -404,38 +404,41 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
}
return
OPERATION_FAIL
;
}
int32
interpreter
::
check_
matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
)
{
if
(
!
findex
||
lua_isnil
(
current_state
,
findex
))
int32
interpreter
::
check_
filter
(
lua_State
*
L
,
card
*
pcard
,
int32
findex
,
int32
extraargs
)
{
if
(
!
findex
||
lua_isnil
(
L
,
findex
))
return
TRUE
;
++
no_action
;
++
call_depth
;
luaL_checkstack
(
current_state
,
1
+
extraargs
,
nullptr
);
lua_pushvalue
(
current_state
,
findex
);
interpreter
::
card2value
(
current_state
,
pcard
);
for
(
int32
i
=
0
;
i
<
extraargs
;
++
i
)
lua_pushvalue
(
current_state
,
(
int32
)(
-
extraargs
-
2
));
if
(
lua_pcall
(
current_state
,
1
+
extraargs
,
1
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
"%s"
,
lua_tostring
(
current_state
,
-
1
));
luaL_checkstack
(
L
,
1
+
extraargs
,
nullptr
);
lua_pushvalue
(
L
,
findex
);
card2value
(
L
,
pcard
);
for
(
int32
i
=
0
;
i
<
extraargs
;
++
i
)
lua_pushvalue
(
L
,
(
int32
)(
-
extraargs
-
2
));
if
(
lua_pcall
(
L
,
1
+
extraargs
,
1
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
"%s"
,
lua_tostring
(
L
,
-
1
));
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
L
,
1
);
--
no_action
;
--
call_depth
;
if
(
call_depth
==
0
)
{
if
(
call_depth
==
0
)
{
pduel
->
release_script_group
();
pduel
->
restore_assumes
();
}
return
OPERATION_FAIL
;
}
int32
result
=
lua_toboolean
(
current_state
,
-
1
);
lua_pop
(
current_state
,
1
);
int32
result
=
lua_toboolean
(
L
,
-
1
);
lua_pop
(
L
,
1
);
--
no_action
;
--
call_depth
;
if
(
call_depth
==
0
)
{
if
(
call_depth
==
0
)
{
pduel
->
release_script_group
();
pduel
->
restore_assumes
();
}
return
result
;
}
int32
interpreter
::
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
)
{
return
check_filter
(
current_state
,
pcard
,
findex
,
extraargs
);
}
int32
interpreter
::
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
)
{
if
(
!
findex
||
lua_isnil
(
current_state
,
findex
))
return
0
;
...
...
interpreter.h
View file @
e631d73f
...
...
@@ -70,6 +70,7 @@ public:
int32
call_card_function
(
card
*
pcard
,
const
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_code_function
(
uint32
code
,
const
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
check_condition
(
int32
f
,
uint32
param_count
);
int32
check_filter
(
lua_State
*
L
,
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_function_value
(
int32
f
,
uint32
param_count
);
...
...
libgroup.cpp
View file @
e631d73f
...
...
@@ -167,7 +167,7 @@ int32 scriptlib::group_filter(lua_State *L) {
group
*
new_group
=
pduel
->
new_group
();
uint32
extraargs
=
lua_gettop
(
L
)
-
3
;
for
(
auto
&
pcard
:
cset
)
{
if
(
pduel
->
lua
->
check_
matching
(
pcard
,
2
,
extraargs
))
{
if
(
pduel
->
lua
->
check_
filter
(
L
,
pcard
,
2
,
extraargs
))
{
new_group
->
container
.
insert
(
pcard
);
}
}
...
...
@@ -192,7 +192,7 @@ int32 scriptlib::group_filter_count(lua_State *L) {
uint32
extraargs
=
lua_gettop
(
L
)
-
3
;
uint32
count
=
0
;
for
(
auto
&
pcard
:
cset
)
{
if
(
pduel
->
lua
->
check_
matching
(
pcard
,
2
,
extraargs
))
if
(
pduel
->
lua
->
check_
filter
(
L
,
pcard
,
2
,
extraargs
))
++
count
;
}
lua_pushinteger
(
L
,
count
);
...
...
@@ -222,7 +222,7 @@ int32 scriptlib::group_filter_select(lua_State *L) {
uint32
extraargs
=
lua_gettop
(
L
)
-
6
;
pduel
->
game_field
->
core
.
select_cards
.
clear
();
for
(
auto
&
pcard
:
cset
)
{
if
(
pduel
->
lua
->
check_
matching
(
pcard
,
3
,
extraargs
))
if
(
pduel
->
lua
->
check_
filter
(
L
,
pcard
,
3
,
extraargs
))
pduel
->
game_field
->
core
.
select_cards
.
push_back
(
pcard
);
}
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_CARD
,
0
,
0
,
0
,
playerid
,
min
+
(
max
<<
16
));
...
...
@@ -439,7 +439,7 @@ int32 scriptlib::group_is_exists(lua_State *L) {
return
1
;
}
for
(
auto
&
pcard
:
cset
)
{
if
(
pduel
->
lua
->
check_
matching
(
pcard
,
2
,
extraargs
))
{
if
(
pduel
->
lua
->
check_
filter
(
L
,
pcard
,
2
,
extraargs
))
{
++
fcount
;
if
(
fcount
>=
count
)
{
result
=
TRUE
;
...
...
@@ -692,7 +692,7 @@ int32 scriptlib::group_remove(lua_State *L) {
return
0
;
pgroup
->
is_iterator_dirty
=
true
;
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();)
{
if
((
*
cit
)
!=
pexception
&&
pduel
->
lua
->
check_
matching
(
*
cit
,
2
,
extraargs
))
{
if
((
*
cit
)
!=
pexception
&&
pduel
->
lua
->
check_
filter
(
L
,
*
cit
,
2
,
extraargs
))
{
cit
=
pgroup
->
container
.
erase
(
cit
);
}
else
...
...
@@ -767,7 +767,7 @@ int32 scriptlib::group_search_card(lua_State *L) {
duel
*
pduel
=
pgroup
->
pduel
;
uint32
extraargs
=
lua_gettop
(
L
)
-
2
;
for
(
auto
&
pcard
:
pgroup
->
container
)
{
if
(
pduel
->
lua
->
check_
matching
(
pcard
,
2
,
extraargs
))
{
if
(
pduel
->
lua
->
check_
filter
(
L
,
pcard
,
2
,
extraargs
))
{
interpreter
::
card2value
(
L
,
pcard
);
return
1
;
}
...
...
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