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
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-core
Commits
74247b0d
Commit
74247b0d
authored
Dec 24, 2017
by
edo9300
Committed by
mercury233
Dec 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Extra Deck related functions and updated pendulum handling (#127)
parent
b4e29462
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
10 deletions
+73
-10
field.cpp
field.cpp
+17
-10
field.h
field.h
+2
-0
interpreter.cpp
interpreter.cpp
+3
-0
libduel.cpp
libduel.cpp
+48
-0
scriptlib.h
scriptlib.h
+3
-0
No files found.
field.cpp
View file @
74247b0d
...
...
@@ -215,10 +215,13 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence
break
;
}
case
LOCATION_EXTRA
:
{
player
[
playerid
].
list_extra
.
push_back
(
pcard
);
pcard
->
current
.
sequence
=
player
[
playerid
].
list_extra
.
size
()
-
1
;
if
(
player
[
playerid
].
extra_p_count
==
0
||
(
pcard
->
data
.
type
&
TYPE_PENDULUM
)
&&
(
pcard
->
sendto_param
.
position
&
POS_FACEUP
))
player
[
playerid
].
list_extra
.
push_back
(
pcard
);
else
player
[
playerid
].
list_extra
.
insert
(
player
[
playerid
].
list_extra
.
end
()
-
player
[
playerid
].
extra_p_count
,
pcard
);
if
((
pcard
->
data
.
type
&
TYPE_PENDULUM
)
&&
(
pcard
->
sendto_param
.
position
&
POS_FACEUP
))
++
player
[
playerid
].
extra_p_count
;
reset_sequence
(
playerid
,
LOCATION_EXTRA
);
break
;
}
}
...
...
@@ -825,9 +828,9 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32
}
}
void
field
::
shuffle
(
uint8
playerid
,
uint8
location
)
{
if
(
!
(
location
&
(
LOCATION_HAND
|
LOCATION_DECK
)))
if
(
!
(
location
&
(
LOCATION_HAND
|
LOCATION_DECK
|
LOCATION_EXTRA
)))
return
;
card_vector
&
svector
=
(
location
==
LOCATION_HAND
)
?
player
[
playerid
].
list_hand
:
player
[
playerid
].
list_main
;
card_vector
&
svector
=
(
location
==
LOCATION_HAND
)
?
player
[
playerid
].
list_hand
:
(
location
==
LOCATION_DECK
)
?
player
[
playerid
].
list_main
:
player
[
playerid
].
list_extra
;
if
(
svector
.
size
()
==
0
)
return
;
if
(
location
==
LOCATION_HAND
)
{
...
...
@@ -841,8 +844,11 @@ void field::shuffle(uint8 playerid, uint8 location) {
}
}
if
(
location
==
LOCATION_HAND
||
!
(
core
.
duel_options
&
DUEL_PSEUDO_SHUFFLE
))
{
if
(
svector
.
size
()
>
1
)
{
uint32
i
=
0
,
s
=
svector
.
size
(),
r
;
uint32
s
=
svector
.
size
();
if
(
location
==
LOCATION_EXTRA
)
s
=
s
-
player
[
playerid
].
extra_p_count
;
if
(
s
>
1
)
{
uint32
i
=
0
,
r
;
for
(
i
=
0
;
i
<
s
-
1
;
++
i
)
{
r
=
pduel
->
get_next_integer
(
i
,
s
-
1
);
card
*
t
=
svector
[
i
];
...
...
@@ -852,13 +858,14 @@ void field::shuffle(uint8 playerid, uint8 location) {
reset_sequence
(
playerid
,
location
);
}
}
if
(
location
==
LOCATION_HAND
)
{
pduel
->
write_buffer8
(
MSG_SHUFFLE_HAND
);
if
(
location
==
LOCATION_HAND
||
location
==
LOCATION_EXTRA
)
{
pduel
->
write_buffer8
(
(
location
==
LOCATION_HAND
)
?
MSG_SHUFFLE_HAND
:
MSG_SHUFFLE_EXTRA
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer8
(
player
[
playerid
].
list_hand
.
size
());
pduel
->
write_buffer8
(
svector
.
size
());
for
(
auto
cit
=
svector
.
begin
();
cit
!=
svector
.
end
();
++
cit
)
pduel
->
write_buffer32
((
*
cit
)
->
data
.
code
);
core
.
shuffle_hand_check
[
playerid
]
=
FALSE
;
if
(
location
==
LOCATION_HAND
)
core
.
shuffle_hand_check
[
playerid
]
=
FALSE
;
}
else
{
pduel
->
write_buffer8
(
MSG_SHUFFLE_DECK
);
pduel
->
write_buffer8
(
playerid
);
...
...
field.h
View file @
74247b0d
...
...
@@ -839,8 +839,10 @@ public:
#define MSG_SHUFFLE_SET_CARD 36
#define MSG_REVERSE_DECK 37
#define MSG_DECK_TOP 38
#define MSG_SHUFFLE_EXTRA 39
#define MSG_NEW_TURN 40
#define MSG_NEW_PHASE 41
#define MSG_CONFIRM_EXTRATOP 42
#define MSG_MOVE 50
#define MSG_POS_CHANGE 53
#define MSG_SET 54
...
...
interpreter.cpp
View file @
74247b0d
...
...
@@ -399,6 +399,7 @@ static const struct luaL_Reg duellib[] = {
{
"SetChainLimitTillChainEnd"
,
scriptlib
::
duel_set_chain_limit_p
},
{
"GetChainMaterial"
,
scriptlib
::
duel_get_chain_material
},
{
"ConfirmDecktop"
,
scriptlib
::
duel_confirm_decktop
},
{
"ConfirmExtratop"
,
scriptlib
::
duel_confirm_extratop
},
{
"ConfirmCards"
,
scriptlib
::
duel_confirm_cards
},
{
"SortDecktop"
,
scriptlib
::
duel_sort_decktop
},
{
"CheckEvent"
,
scriptlib
::
duel_check_event
},
...
...
@@ -422,6 +423,7 @@ static const struct luaL_Reg duellib[] = {
{
"DiscardHand"
,
scriptlib
::
duel_discard_hand
},
{
"DisableShuffleCheck"
,
scriptlib
::
duel_disable_shuffle_check
},
{
"ShuffleDeck"
,
scriptlib
::
duel_shuffle_deck
},
{
"ShuffleExtra"
,
scriptlib
::
duel_shuffle_extra
},
{
"ShuffleHand"
,
scriptlib
::
duel_shuffle_hand
},
{
"ShuffleSetCard"
,
scriptlib
::
duel_shuffle_setcard
},
{
"ChangeAttacker"
,
scriptlib
::
duel_change_attacker
},
...
...
@@ -465,6 +467,7 @@ static const struct luaL_Reg duellib[] = {
{
"GetFieldGroup"
,
scriptlib
::
duel_get_field_group
},
{
"GetFieldGroupCount"
,
scriptlib
::
duel_get_field_group_count
},
{
"GetDecktopGroup"
,
scriptlib
::
duel_get_decktop_group
},
{
"GetExtraTopGroup"
,
scriptlib
::
duel_get_extratop_group
},
{
"GetMatchingGroup"
,
scriptlib
::
duel_get_matching_group
},
{
"GetMatchingGroupCount"
,
scriptlib
::
duel_get_matching_count
},
{
"GetFirstMatchingCard"
,
scriptlib
::
duel_get_first_matching_card
},
...
...
libduel.cpp
View file @
74247b0d
...
...
@@ -805,6 +805,28 @@ int32 scriptlib::duel_confirm_decktop(lua_State *L) {
pduel
->
game_field
->
add_process
(
PROCESSOR_WAIT
,
0
,
0
,
0
,
0
,
0
);
return
lua_yield
(
L
,
0
);
}
int32
scriptlib
::
duel_confirm_extratop
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
int32
playerid
=
lua_tointeger
(
L
,
1
);
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
uint32
count
=
lua_tointeger
(
L
,
2
);
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
if
(
count
>=
pduel
->
game_field
->
player
[
playerid
].
list_extra
.
size
()
-
pduel
->
game_field
->
player
[
playerid
].
extra_p_count
)
count
=
pduel
->
game_field
->
player
[
playerid
].
list_extra
.
size
()
-
pduel
->
game_field
->
player
[
playerid
].
extra_p_count
;
auto
cit
=
pduel
->
game_field
->
player
[
playerid
].
list_extra
.
rbegin
()
+
pduel
->
game_field
->
player
[
playerid
].
extra_p_count
;
pduel
->
write_buffer8
(
MSG_CONFIRM_EXTRATOP
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer8
(
count
);
for
(
uint32
i
=
0
;
i
<
count
&&
cit
!=
pduel
->
game_field
->
player
[
playerid
].
list_extra
.
rend
();
++
i
,
++
cit
)
{
pduel
->
write_buffer32
((
*
cit
)
->
data
.
code
);
pduel
->
write_buffer8
((
*
cit
)
->
current
.
controler
);
pduel
->
write_buffer8
((
*
cit
)
->
current
.
location
);
pduel
->
write_buffer8
((
*
cit
)
->
current
.
sequence
);
}
pduel
->
game_field
->
add_process
(
PROCESSOR_WAIT
,
0
,
0
,
0
,
0
,
0
);
return
lua_yield
(
L
,
0
);
}
int32
scriptlib
::
duel_confirm_cards
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
int32
playerid
=
lua_tointeger
(
L
,
1
);
...
...
@@ -1287,6 +1309,15 @@ int32 scriptlib::duel_shuffle_deck(lua_State *L) {
pduel
->
game_field
->
shuffle
(
playerid
,
LOCATION_DECK
);
return
0
;
}
int32
scriptlib
::
duel_shuffle_extra
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
uint32
playerid
=
lua_tointeger
(
L
,
1
);
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
pduel
->
game_field
->
shuffle
(
playerid
,
LOCATION_EXTRA
);
return
0
;
}
int32
scriptlib
::
duel_shuffle_hand
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
uint32
playerid
=
lua_tointeger
(
L
,
1
);
...
...
@@ -2033,6 +2064,23 @@ int32 scriptlib::duel_get_decktop_group(lua_State *L) {
interpreter
::
group2value
(
L
,
pgroup
);
return
1
;
}
/**
* \brief Duel.GetExtraTopGroup
* \param playerid, count
* \return Group
*/
int32
scriptlib
::
duel_get_extratop_group
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
uint32
playerid
=
lua_tointeger
(
L
,
1
);
uint32
count
=
lua_tointeger
(
L
,
2
);
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
group
*
pgroup
=
pduel
->
new_group
();
auto
cit
=
pduel
->
game_field
->
player
[
playerid
].
list_extra
.
rbegin
()
+
pduel
->
game_field
->
player
[
playerid
].
extra_p_count
;
for
(
uint32
i
=
0
;
i
<
count
&&
cit
!=
pduel
->
game_field
->
player
[
playerid
].
list_extra
.
rend
();
++
i
,
++
cit
)
pgroup
->
container
.
insert
(
*
cit
);
interpreter
::
group2value
(
L
,
pgroup
);
return
1
;
}
/**
* \brief Duel.GetMatchingGroup
* \param filter_func, self, location1, location2, exception card, (extraargs...)
...
...
scriptlib.h
View file @
74247b0d
...
...
@@ -395,6 +395,7 @@ public:
static
int32
duel_set_chain_limit_p
(
lua_State
*
L
);
static
int32
duel_get_chain_material
(
lua_State
*
L
);
static
int32
duel_confirm_decktop
(
lua_State
*
L
);
static
int32
duel_confirm_extratop
(
lua_State
*
L
);
static
int32
duel_confirm_cards
(
lua_State
*
L
);
static
int32
duel_sort_decktop
(
lua_State
*
L
);
static
int32
duel_check_event
(
lua_State
*
L
);
...
...
@@ -419,6 +420,7 @@ public:
static
int32
duel_discard_hand
(
lua_State
*
L
);
static
int32
duel_disable_shuffle_check
(
lua_State
*
L
);
static
int32
duel_shuffle_deck
(
lua_State
*
L
);
static
int32
duel_shuffle_extra
(
lua_State
*
L
);
static
int32
duel_shuffle_hand
(
lua_State
*
L
);
static
int32
duel_shuffle_setcard
(
lua_State
*
L
);
static
int32
duel_change_attacker
(
lua_State
*
L
);
...
...
@@ -463,6 +465,7 @@ public:
static
int32
duel_get_field_group
(
lua_State
*
L
);
static
int32
duel_get_field_group_count
(
lua_State
*
L
);
static
int32
duel_get_decktop_group
(
lua_State
*
L
);
static
int32
duel_get_extratop_group
(
lua_State
*
L
);
static
int32
duel_get_matching_group
(
lua_State
*
L
);
static
int32
duel_get_matching_count
(
lua_State
*
L
);
static
int32
duel_get_first_matching_card
(
lua_State
*
L
);
...
...
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