Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
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
love_飞影
Neos
Commits
d51ac1c0
Commit
d51ac1c0
authored
Nov 06, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MsgStartAdapter impl
parent
ea97b52a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
6 deletions
+154
-6
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+68
-3
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+2
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
+25
-2
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/start.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/start.ts
+58
-0
No files found.
neos-protobuf
@
867be3ce
Subproject commit
6ecf0f70f5ba7917191907e7730ccac2a59d28e9
Subproject commit
867be3cee1dfe449735e81a85aa887724e8067cb
src/api/ocgcore/idl/ocgcore.ts
View file @
d51ac1c0
...
...
@@ -458,7 +458,7 @@ export namespace ygopro {
}
}
export
class
YgoStocMsg
extends
pb_1
.
Message
{
#
one_of_decls
:
number
[][]
=
[[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
]];
#
one_of_decls
:
number
[][]
=
[[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
]];
constructor
(
data
?:
|
any
[]
...
...
@@ -475,6 +475,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -488,6 +489,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -501,6 +503,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -514,6 +517,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -527,6 +531,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -540,6 +545,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -553,6 +559,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -566,6 +573,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -579,6 +587,7 @@ export namespace ygopro {
stoc_select_tp
?:
StocSelectTp
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -592,6 +601,7 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
StocDeckCount
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
...
...
@@ -605,6 +615,21 @@ export namespace ygopro {
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
StocDuelStart
;
stoc_game_msg
?:
never
;
}
|
{
stoc_join_game
?:
never
;
stoc_chat
?:
never
;
stoc_hs_player_enter
?:
never
;
stoc_type_change
?:
never
;
stoc_hs_player_change
?:
never
;
stoc_hs_watch_change
?:
never
;
stoc_select_hand
?:
never
;
stoc_hand_result
?:
never
;
stoc_select_tp
?:
never
;
stoc_deck_count
?:
never
;
stoc_duel_start
?:
never
;
stoc_game_msg
?:
StocGameMessage
;
}
))
)
{
...
...
@@ -660,6 +685,9 @@ export namespace ygopro {
if
(
"
stoc_duel_start
"
in
data
&&
data
.
stoc_duel_start
!=
undefined
)
{
this
.
stoc_duel_start
=
data
.
stoc_duel_start
;
}
if
(
"
stoc_game_msg
"
in
data
&&
data
.
stoc_game_msg
!=
undefined
)
{
this
.
stoc_game_msg
=
data
.
stoc_game_msg
;
}
}
}
get
stoc_join_game
()
{
...
...
@@ -801,6 +829,19 @@ export namespace ygopro {
get
has_stoc_duel_start
()
{
return
pb_1
.
Message
.
getField
(
this
,
11
)
!=
null
;
}
get
stoc_game_msg
()
{
return
pb_1
.
Message
.
getWrapperField
(
this
,
StocGameMessage
,
12
)
as
StocGameMessage
;
}
set
stoc_game_msg
(
value
:
StocGameMessage
)
{
pb_1
.
Message
.
setOneofWrapperField
(
this
,
12
,
this
.
#
one_of_decls
[
0
],
value
);
}
get
has_stoc_game_msg
()
{
return
pb_1
.
Message
.
getField
(
this
,
12
)
!=
null
;
}
get
msg
()
{
const
cases
:
{
[
index
:
number
]:
...
...
@@ -815,7 +856,8 @@ export namespace ygopro {
|
"
stoc_hand_result
"
|
"
stoc_select_tp
"
|
"
stoc_deck_count
"
|
"
stoc_duel_start
"
;
|
"
stoc_duel_start
"
|
"
stoc_game_msg
"
;
}
=
{
0
:
"
none
"
,
1
:
"
stoc_join_game
"
,
...
...
@@ -829,9 +871,13 @@ export namespace ygopro {
9
:
"
stoc_select_tp
"
,
10
:
"
stoc_deck_count
"
,
11
:
"
stoc_duel_start
"
,
12
:
"
stoc_game_msg
"
,
};
return
cases
[
pb_1
.
Message
.
computeOneofCase
(
this
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
])
pb_1
.
Message
.
computeOneofCase
(
this
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
]
)
];
}
static
fromObject
(
data
:
{
...
...
@@ -852,6 +898,7 @@ export namespace ygopro {
stoc_select_tp
?:
ReturnType
<
typeof
StocSelectTp
.
prototype
.
toObject
>
;
stoc_deck_count
?:
ReturnType
<
typeof
StocDeckCount
.
prototype
.
toObject
>
;
stoc_duel_start
?:
ReturnType
<
typeof
StocDuelStart
.
prototype
.
toObject
>
;
stoc_game_msg
?:
ReturnType
<
typeof
StocGameMessage
.
prototype
.
toObject
>
;
}):
YgoStocMsg
{
const
message
=
new
YgoStocMsg
({});
if
(
data
.
stoc_join_game
!=
null
)
{
...
...
@@ -903,6 +950,9 @@ export namespace ygopro {
data
.
stoc_duel_start
);
}
if
(
data
.
stoc_game_msg
!=
null
)
{
message
.
stoc_game_msg
=
StocGameMessage
.
fromObject
(
data
.
stoc_game_msg
);
}
return
message
;
}
toObject
()
{
...
...
@@ -924,6 +974,7 @@ export namespace ygopro {
stoc_select_tp
?:
ReturnType
<
typeof
StocSelectTp
.
prototype
.
toObject
>
;
stoc_deck_count
?:
ReturnType
<
typeof
StocDeckCount
.
prototype
.
toObject
>
;
stoc_duel_start
?:
ReturnType
<
typeof
StocDuelStart
.
prototype
.
toObject
>
;
stoc_game_msg
?:
ReturnType
<
typeof
StocGameMessage
.
prototype
.
toObject
>
;
}
=
{};
if
(
this
.
stoc_join_game
!=
null
)
{
data
.
stoc_join_game
=
this
.
stoc_join_game
.
toObject
();
...
...
@@ -958,6 +1009,9 @@ export namespace ygopro {
if
(
this
.
stoc_duel_start
!=
null
)
{
data
.
stoc_duel_start
=
this
.
stoc_duel_start
.
toObject
();
}
if
(
this
.
stoc_game_msg
!=
null
)
{
data
.
stoc_game_msg
=
this
.
stoc_game_msg
.
toObject
();
}
return
data
;
}
serialize
():
Uint8Array
;
...
...
@@ -1008,6 +1062,10 @@ export namespace ygopro {
writer
.
writeMessage
(
11
,
this
.
stoc_duel_start
,
()
=>
this
.
stoc_duel_start
.
serialize
(
writer
)
);
if
(
this
.
has_stoc_game_msg
)
writer
.
writeMessage
(
12
,
this
.
stoc_game_msg
,
()
=>
this
.
stoc_game_msg
.
serialize
(
writer
)
);
if
(
!
w
)
return
writer
.
getResultBuffer
();
}
static
deserialize
(
bytes
:
Uint8Array
|
pb_1
.
BinaryReader
):
YgoStocMsg
{
...
...
@@ -1096,6 +1154,13 @@ export namespace ygopro {
(
message
.
stoc_duel_start
=
StocDuelStart
.
deserialize
(
reader
))
);
break
;
case
12
:
reader
.
readMessage
(
message
.
stoc_game_msg
,
()
=>
(
message
.
stoc_game_msg
=
StocGameMessage
.
deserialize
(
reader
))
);
break
;
default
:
reader
.
skipField
();
}
...
...
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
d51ac1c0
...
...
@@ -21,3 +21,5 @@ export const STOC_SELECT_TP = 4;
export
const
STOC_HAND_RESULT
=
5
;
export
const
STOC_DECK_COUNT
=
9
;
export
const
STOC_DUEL_START
=
21
;
export
const
MSG_START
=
4
;
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
d51ac1c0
...
...
@@ -5,6 +5,8 @@
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
YgoProPacket
,
StocAdapter
}
from
"
../../packet
"
;
import
{
MSG_START
}
from
"
../../protoDecl
"
;
import
MsgStartAdapter
from
"
./start
"
;
/*
* STOC GameMsg
...
...
@@ -22,7 +24,28 @@ export default class GameMsgAdapter implements StocAdapter {
}
upcast
():
ygopro
.
YgoStocMsg
{
// TODO
return
new
ygopro
.
YgoStocMsg
({});
const
exData
=
this
.
packet
.
exData
;
const
dataView
=
new
DataView
(
exData
.
buffer
);
const
func
=
dataView
.
getUint8
(
0
);
const
gameData
=
exData
.
slice
(
1
);
const
gameMsg
=
new
ygopro
.
StocGameMessage
({});
switch
(
func
)
{
case
MSG_START
:
{
gameMsg
.
start
=
MsgStartAdapter
(
gameData
);
break
;
}
default
:
{
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
break
;
}
}
return
new
ygopro
.
YgoStocMsg
({
stoc_game_msg
:
gameMsg
,
});
}
}
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/start.ts
0 → 100644
View file @
d51ac1c0
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
const
LITTLE_ENDIAN
=
true
;
const
INT16_BYTE_OFFSET
=
2
;
const
INT32_BYTE_OFFSET
=
4
;
/*
* MSG Start
*
* @param todo
*
* @usage - 服务端在决斗开始时告诉前端/客户端双方的基础信息
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
dataView
=
new
DataView
(
data
.
buffer
);
// TODO: 对DataView包装下实现一个BufferIO类,便于解析二进制数据
const
pT
=
dataView
.
getUint8
(
0
);
const
playerType
=
(
pT
&
0xf
)
<=
0
?
ygopro
.
StocGameMessage
.
MsgStart
.
PlayerType
.
FirstStrike
:
(
pT
&
0xf0
)
>
0
?
ygopro
.
StocGameMessage
.
MsgStart
.
PlayerType
.
Observer
:
ygopro
.
StocGameMessage
.
MsgStart
.
PlayerType
.
SecondStrike
;
let
offset
=
1
;
if
(
dataView
.
byteLength
>
17
)
{
// data长度大于17,会多传一个大师规则字段
const
masterRule
=
dataView
.
getUint8
(
offset
);
// TODO
offset
+=
1
;
}
const
life1
=
dataView
.
getInt32
(
offset
,
LITTLE_ENDIAN
);
offset
+=
INT32_BYTE_OFFSET
;
const
life2
=
dataView
.
getInt32
(
offset
,
LITTLE_ENDIAN
);
offset
+=
INT32_BYTE_OFFSET
;
const
deckSize1
=
dataView
.
getInt16
(
offset
,
LITTLE_ENDIAN
);
offset
+=
INT16_BYTE_OFFSET
;
const
extraSize1
=
dataView
.
getInt16
(
offset
,
LITTLE_ENDIAN
);
offset
+=
INT16_BYTE_OFFSET
;
const
deckSize2
=
dataView
.
getInt16
(
offset
,
LITTLE_ENDIAN
);
offset
+=
INT16_BYTE_OFFSET
;
const
extraSize2
=
dataView
.
getInt16
(
offset
,
LITTLE_ENDIAN
);
offset
+=
INT16_BYTE_OFFSET
;
return
new
ygopro
.
StocGameMessage
.
MsgStart
({
playerType
,
life1
,
life2
,
deckSize1
,
deckSize2
,
extraSize1
,
extraSize2
,
});
};
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