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
a8685af9
Commit
a8685af9
authored
Apr 28, 2017
by
mercury233
Committed by
GitHub
Apr 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #89 from edo9300/rock_paper_scissors
Added Duel.RockPaperScissors
parents
c51e8c17
c8ddaa2d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
0 deletions
+56
-0
field.h
field.h
+4
-0
interpreter.cpp
interpreter.cpp
+1
-0
libduel.cpp
libduel.cpp
+8
-0
operations.cpp
operations.cpp
+34
-0
processor.cpp
processor.cpp
+8
-0
scriptlib.h
scriptlib.h
+1
-0
No files found.
field.h
View file @
a8685af9
...
...
@@ -547,6 +547,7 @@ public:
int32
select_tribute_cards
(
int16
step
,
uint8
playerid
,
uint8
cancelable
,
int32
min
,
int32
max
);
int32
toss_coin
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
uint8
playerid
,
uint8
count
);
int32
toss_dice
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
uint8
playerid
,
uint8
count1
,
uint8
count2
);
int32
rock_paper_scissors
(
uint16
step
,
uint8
repeat
);
int32
select_battle_command
(
uint16
step
,
uint8
playerid
);
int32
select_idle_command
(
uint16
step
,
uint8
playerid
);
...
...
@@ -709,6 +710,7 @@ public:
#define PROCESSOR_ANNOUNCE_COIN 116
#define PROCESSOR_TOSS_DICE 117
#define PROCESSOR_TOSS_COIN 118
#define PROCESSOR_ROCK_PAPER_SCISSORS 119
#define PROCESSOR_SELECT_YESNO_S 120
#define PROCESSOR_SELECT_OPTION_S 121
#define PROCESSOR_SELECT_CARD_S 122
...
...
@@ -857,6 +859,8 @@ public:
#define MSG_RELEASE_RELATION 123
#define MSG_TOSS_COIN 130
#define MSG_TOSS_DICE 131
#define MSG_ROCK_PAPER_SCISSORS 132
#define MSG_HAND_RES 133
#define MSG_ANNOUNCE_RACE 140
#define MSG_ANNOUNCE_ATTRIB 141
#define MSG_ANNOUNCE_CARD 142
...
...
interpreter.cpp
View file @
a8685af9
...
...
@@ -489,6 +489,7 @@ static const struct luaL_Reg duellib[] = {
{
"AnnounceCoin"
,
scriptlib
::
duel_announce_coin
},
{
"TossCoin"
,
scriptlib
::
duel_toss_coin
},
{
"TossDice"
,
scriptlib
::
duel_toss_dice
},
{
"RockPaperScissors"
,
scriptlib
::
duel_rock_paper_scissors
},
{
"GetCoinResult"
,
scriptlib
::
duel_get_coin_result
},
{
"GetDiceResult"
,
scriptlib
::
duel_get_dice_result
},
{
"SetCoinResult"
,
scriptlib
::
duel_set_coin_result
},
...
...
libduel.cpp
View file @
a8685af9
...
...
@@ -3044,6 +3044,14 @@ int32 scriptlib::duel_toss_dice(lua_State * L) {
pduel
->
game_field
->
add_process
(
PROCESSOR_TOSS_DICE
,
0
,
pduel
->
game_field
->
core
.
reason_effect
,
0
,
(
pduel
->
game_field
->
core
.
reason_player
<<
16
)
+
playerid
,
count1
+
(
count2
<<
16
));
return
lua_yield
(
L
,
0
);
}
int32
scriptlib
::
duel_rock_paper_scissors
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
uint8
repeat
=
TRUE
;
if
(
lua_gettop
(
L
)
>
0
)
repeat
=
lua_toboolean
(
L
,
1
);
pduel
->
game_field
->
add_process
(
PROCESSOR_ROCK_PAPER_SCISSORS
,
1
,
0
,
0
,
repeat
,
0
);
return
lua_yield
(
L
,
0
);
}
int32
scriptlib
::
duel_get_coin_result
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
for
(
int32
i
=
0
;
i
<
5
;
++
i
)
...
...
operations.cpp
View file @
a8685af9
...
...
@@ -5518,3 +5518,37 @@ int32 field::toss_dice(uint16 step, effect * reason_effect, uint8 reason_player,
}
return
TRUE
;
}
int32
field
::
rock_paper_scissors
(
uint16
step
,
uint8
repeat
)
{
switch
(
step
)
{
case
1
:
{
pduel
->
write_buffer8
(
MSG_ROCK_PAPER_SCISSORS
);
pduel
->
write_buffer8
(
0
);
return
FALSE
;
}
case
2
:
{
core
.
units
.
begin
()
->
arg2
=
returns
.
ivalue
[
0
];
pduel
->
write_buffer8
(
MSG_ROCK_PAPER_SCISSORS
);
pduel
->
write_buffer8
(
1
);
return
FALSE
;
}
case
3
:
{
core
.
units
.
begin
()
->
arg2
=
core
.
units
.
begin
()
->
arg2
+
(
returns
.
ivalue
[
0
]
<<
2
);
pduel
->
write_buffer8
(
MSG_HAND_RES
);
pduel
->
write_buffer8
(
core
.
units
.
begin
()
->
arg2
);
if
((
core
.
units
.
begin
()
->
arg2
&
0x3
)
==
((
core
.
units
.
begin
()
->
arg2
>>
2
)
&
0x3
))
{
if
(
repeat
)
{
core
.
units
.
begin
()
->
step
=
0
;
return
FALSE
;
}
else
returns
.
ivalue
[
0
]
=
PLAYER_NONE
;
}
else
if
(((
core
.
units
.
begin
()
->
arg2
&
0x3
)
==
1
&&
((
core
.
units
.
begin
()
->
arg2
>>
2
)
&
0x3
)
==
2
)
||
((
core
.
units
.
begin
()
->
arg2
&
0x3
)
==
2
&&
((
core
.
units
.
begin
()
->
arg2
>>
2
)
&
0x3
)
==
3
)
||
((
core
.
units
.
begin
()
->
arg2
&
0x3
)
==
3
&&
((
core
.
units
.
begin
()
->
arg2
>>
2
)
&
0x3
)
==
1
))
{
returns
.
ivalue
[
0
]
=
1
;
}
else
{
returns
.
ivalue
[
0
]
=
0
;
}
return
TRUE
;
}
}
}
processor.cpp
View file @
a8685af9
...
...
@@ -617,6 +617,14 @@ int32 field::process() {
it
->
step
++
;
return
pduel
->
bufferlen
;
}
case
PROCESSOR_ROCK_PAPER_SCISSORS
:
{
if
(
rock_paper_scissors
(
it
->
step
,
it
->
arg1
))
{
pduel
->
lua
->
add_param
(
returns
.
ivalue
[
0
],
PARAM_TYPE_INT
);
core
.
units
.
pop_front
();
}
else
it
->
step
++
;
return
pduel
->
bufferlen
;
}
case
PROCESSOR_SELECT_EFFECTYN_S
:
{
if
(
it
->
step
==
0
)
{
add_process
(
PROCESSOR_SELECT_EFFECTYN
,
0
,
it
->
peffect
,
it
->
ptarget
,
it
->
arg1
,
it
->
arg2
);
...
...
scriptlib.h
View file @
a8685af9
...
...
@@ -488,6 +488,7 @@ public:
static
int32
duel_announce_coin
(
lua_State
*
L
);
static
int32
duel_toss_coin
(
lua_State
*
L
);
static
int32
duel_toss_dice
(
lua_State
*
L
);
static
int32
duel_rock_paper_scissors
(
lua_State
*
L
);
static
int32
duel_get_coin_result
(
lua_State
*
L
);
static
int32
duel_get_dice_result
(
lua_State
*
L
);
static
int32
duel_set_coin_result
(
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