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
deft
Neos
Commits
37f73cd3
Commit
37f73cd3
authored
Nov 19, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/service/game_msg' into 'main'
Feat/service/game msg See merge request
!17
parents
39e8bf88
66b1e942
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
251 additions
and
9 deletions
+251
-9
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+170
-6
src/api/ocgcore/ocgAdapter/bufferIO.ts
src/api/ocgcore/ocgAdapter/bufferIO.ts
+36
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+1
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/draw.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/draw.ts
+29
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
+8
-2
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+6
-0
No files found.
neos-protobuf
@
cdceb995
Subproject commit
867be3cee1dfe449735e81a85aa887724e8067cb
Subproject commit
cdceb9956b250e56cc59c18936872cdda3f3fb2c
src/api/ocgcore/idl/ocgcore.ts
View file @
37f73cd3
...
@@ -3100,13 +3100,20 @@ export namespace ygopro {
...
@@ -3100,13 +3100,20 @@ export namespace ygopro {
}
}
}
}
export
class
StocGameMessage
extends
pb_1
.
Message
{
export
class
StocGameMessage
extends
pb_1
.
Message
{
#
one_of_decls
:
number
[][]
=
[[
1
]];
#
one_of_decls
:
number
[][]
=
[[
1
,
2
]];
constructor
(
constructor
(
data
?:
data
?:
|
any
[]
|
any
[]
|
({}
&
{
|
({}
&
(
start
?:
StocGameMessage
.
MsgStart
;
|
{
})
start
?:
StocGameMessage
.
MsgStart
;
draw
?:
never
;
}
|
{
start
?:
never
;
draw
?:
StocGameMessage
.
MsgDraw
;
}
))
)
{
)
{
super
();
super
();
pb_1
.
Message
.
initialize
(
pb_1
.
Message
.
initialize
(
...
@@ -3121,6 +3128,9 @@ export namespace ygopro {
...
@@ -3121,6 +3128,9 @@ export namespace ygopro {
if
(
"
start
"
in
data
&&
data
.
start
!=
undefined
)
{
if
(
"
start
"
in
data
&&
data
.
start
!=
undefined
)
{
this
.
start
=
data
.
start
;
this
.
start
=
data
.
start
;
}
}
if
(
"
draw
"
in
data
&&
data
.
draw
!=
undefined
)
{
this
.
draw
=
data
.
draw
;
}
}
}
}
}
get
start
()
{
get
start
()
{
...
@@ -3136,31 +3146,53 @@ export namespace ygopro {
...
@@ -3136,31 +3146,53 @@ export namespace ygopro {
get
has_start
()
{
get
has_start
()
{
return
pb_1
.
Message
.
getField
(
this
,
1
)
!=
null
;
return
pb_1
.
Message
.
getField
(
this
,
1
)
!=
null
;
}
}
get
draw
()
{
return
pb_1
.
Message
.
getWrapperField
(
this
,
StocGameMessage
.
MsgDraw
,
2
)
as
StocGameMessage
.
MsgDraw
;
}
set
draw
(
value
:
StocGameMessage
.
MsgDraw
)
{
pb_1
.
Message
.
setOneofWrapperField
(
this
,
2
,
this
.
#
one_of_decls
[
0
],
value
);
}
get
has_draw
()
{
return
pb_1
.
Message
.
getField
(
this
,
2
)
!=
null
;
}
get
gameMsg
()
{
get
gameMsg
()
{
const
cases
:
{
const
cases
:
{
[
index
:
number
]:
"
none
"
|
"
start
"
;
[
index
:
number
]:
"
none
"
|
"
start
"
|
"
draw
"
;
}
=
{
}
=
{
0
:
"
none
"
,
0
:
"
none
"
,
1
:
"
start
"
,
1
:
"
start
"
,
2
:
"
draw
"
,
};
};
return
cases
[
pb_1
.
Message
.
computeOneofCase
(
this
,
[
1
])];
return
cases
[
pb_1
.
Message
.
computeOneofCase
(
this
,
[
1
,
2
])];
}
}
static
fromObject
(
data
:
{
static
fromObject
(
data
:
{
start
?:
ReturnType
<
typeof
StocGameMessage
.
MsgStart
.
prototype
.
toObject
>
;
start
?:
ReturnType
<
typeof
StocGameMessage
.
MsgStart
.
prototype
.
toObject
>
;
draw
?:
ReturnType
<
typeof
StocGameMessage
.
MsgDraw
.
prototype
.
toObject
>
;
}):
StocGameMessage
{
}):
StocGameMessage
{
const
message
=
new
StocGameMessage
({});
const
message
=
new
StocGameMessage
({});
if
(
data
.
start
!=
null
)
{
if
(
data
.
start
!=
null
)
{
message
.
start
=
StocGameMessage
.
MsgStart
.
fromObject
(
data
.
start
);
message
.
start
=
StocGameMessage
.
MsgStart
.
fromObject
(
data
.
start
);
}
}
if
(
data
.
draw
!=
null
)
{
message
.
draw
=
StocGameMessage
.
MsgDraw
.
fromObject
(
data
.
draw
);
}
return
message
;
return
message
;
}
}
toObject
()
{
toObject
()
{
const
data
:
{
const
data
:
{
start
?:
ReturnType
<
typeof
StocGameMessage
.
MsgStart
.
prototype
.
toObject
>
;
start
?:
ReturnType
<
typeof
StocGameMessage
.
MsgStart
.
prototype
.
toObject
>
;
draw
?:
ReturnType
<
typeof
StocGameMessage
.
MsgDraw
.
prototype
.
toObject
>
;
}
=
{};
}
=
{};
if
(
this
.
start
!=
null
)
{
if
(
this
.
start
!=
null
)
{
data
.
start
=
this
.
start
.
toObject
();
data
.
start
=
this
.
start
.
toObject
();
}
}
if
(
this
.
draw
!=
null
)
{
data
.
draw
=
this
.
draw
.
toObject
();
}
return
data
;
return
data
;
}
}
serialize
():
Uint8Array
;
serialize
():
Uint8Array
;
...
@@ -3169,6 +3201,8 @@ export namespace ygopro {
...
@@ -3169,6 +3201,8 @@ export namespace ygopro {
const
writer
=
w
||
new
pb_1
.
BinaryWriter
();
const
writer
=
w
||
new
pb_1
.
BinaryWriter
();
if
(
this
.
has_start
)
if
(
this
.
has_start
)
writer
.
writeMessage
(
1
,
this
.
start
,
()
=>
this
.
start
.
serialize
(
writer
));
writer
.
writeMessage
(
1
,
this
.
start
,
()
=>
this
.
start
.
serialize
(
writer
));
if
(
this
.
has_draw
)
writer
.
writeMessage
(
2
,
this
.
draw
,
()
=>
this
.
draw
.
serialize
(
writer
));
if
(
!
w
)
return
writer
.
getResultBuffer
();
if
(
!
w
)
return
writer
.
getResultBuffer
();
}
}
static
deserialize
(
bytes
:
Uint8Array
|
pb_1
.
BinaryReader
):
StocGameMessage
{
static
deserialize
(
bytes
:
Uint8Array
|
pb_1
.
BinaryReader
):
StocGameMessage
{
...
@@ -3187,6 +3221,12 @@ export namespace ygopro {
...
@@ -3187,6 +3221,12 @@ export namespace ygopro {
(
message
.
start
=
StocGameMessage
.
MsgStart
.
deserialize
(
reader
))
(
message
.
start
=
StocGameMessage
.
MsgStart
.
deserialize
(
reader
))
);
);
break
;
break
;
case
2
:
reader
.
readMessage
(
message
.
draw
,
()
=>
(
message
.
draw
=
StocGameMessage
.
MsgDraw
.
deserialize
(
reader
))
);
break
;
default
:
default
:
reader
.
skipField
();
reader
.
skipField
();
}
}
...
@@ -3426,5 +3466,129 @@ export namespace ygopro {
...
@@ -3426,5 +3466,129 @@ export namespace ygopro {
Observer
=
3
,
Observer
=
3
,
}
}
}
}
export
class
MsgDraw
extends
pb_1
.
Message
{
#
one_of_decls
:
number
[][]
=
[];
constructor
(
data
?:
|
any
[]
|
{
player
?:
number
;
count
?:
number
;
cards
?:
number
[];
}
)
{
super
();
pb_1
.
Message
.
initialize
(
this
,
Array
.
isArray
(
data
)
?
data
:
[],
0
,
-
1
,
[
3
],
this
.
#
one_of_decls
);
if
(
!
Array
.
isArray
(
data
)
&&
typeof
data
==
"
object
"
)
{
if
(
"
player
"
in
data
&&
data
.
player
!=
undefined
)
{
this
.
player
=
data
.
player
;
}
if
(
"
count
"
in
data
&&
data
.
count
!=
undefined
)
{
this
.
count
=
data
.
count
;
}
if
(
"
cards
"
in
data
&&
data
.
cards
!=
undefined
)
{
this
.
cards
=
data
.
cards
;
}
}
}
get
player
()
{
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
1
,
0
)
as
number
;
}
set
player
(
value
:
number
)
{
pb_1
.
Message
.
setField
(
this
,
1
,
value
);
}
get
count
()
{
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
2
,
0
)
as
number
;
}
set
count
(
value
:
number
)
{
pb_1
.
Message
.
setField
(
this
,
2
,
value
);
}
get
cards
()
{
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
3
,
[])
as
number
[];
}
set
cards
(
value
:
number
[])
{
pb_1
.
Message
.
setField
(
this
,
3
,
value
);
}
static
fromObject
(
data
:
{
player
?:
number
;
count
?:
number
;
cards
?:
number
[];
}):
MsgDraw
{
const
message
=
new
MsgDraw
({});
if
(
data
.
player
!=
null
)
{
message
.
player
=
data
.
player
;
}
if
(
data
.
count
!=
null
)
{
message
.
count
=
data
.
count
;
}
if
(
data
.
cards
!=
null
)
{
message
.
cards
=
data
.
cards
;
}
return
message
;
}
toObject
()
{
const
data
:
{
player
?:
number
;
count
?:
number
;
cards
?:
number
[];
}
=
{};
if
(
this
.
player
!=
null
)
{
data
.
player
=
this
.
player
;
}
if
(
this
.
count
!=
null
)
{
data
.
count
=
this
.
count
;
}
if
(
this
.
cards
!=
null
)
{
data
.
cards
=
this
.
cards
;
}
return
data
;
}
serialize
():
Uint8Array
;
serialize
(
w
:
pb_1
.
BinaryWriter
):
void
;
serialize
(
w
?:
pb_1
.
BinaryWriter
):
Uint8Array
|
void
{
const
writer
=
w
||
new
pb_1
.
BinaryWriter
();
if
(
this
.
player
!=
0
)
writer
.
writeInt32
(
1
,
this
.
player
);
if
(
this
.
count
!=
0
)
writer
.
writeInt32
(
2
,
this
.
count
);
if
(
this
.
cards
.
length
)
writer
.
writePackedInt32
(
3
,
this
.
cards
);
if
(
!
w
)
return
writer
.
getResultBuffer
();
}
static
deserialize
(
bytes
:
Uint8Array
|
pb_1
.
BinaryReader
):
MsgDraw
{
const
reader
=
bytes
instanceof
pb_1
.
BinaryReader
?
bytes
:
new
pb_1
.
BinaryReader
(
bytes
),
message
=
new
MsgDraw
();
while
(
reader
.
nextField
())
{
if
(
reader
.
isEndGroup
())
break
;
switch
(
reader
.
getFieldNumber
())
{
case
1
:
message
.
player
=
reader
.
readInt32
();
break
;
case
2
:
message
.
count
=
reader
.
readInt32
();
break
;
case
3
:
message
.
cards
=
reader
.
readPackedInt32
();
break
;
default
:
reader
.
skipField
();
}
}
return
message
;
}
serializeBinary
():
Uint8Array
{
return
this
.
serialize
();
}
static
deserializeBinary
(
bytes
:
Uint8Array
):
MsgDraw
{
return
MsgDraw
.
deserialize
(
bytes
);
}
}
}
}
}
}
src/api/ocgcore/ocgAdapter/bufferIO.ts
0 → 100644
View file @
37f73cd3
const
OFFSET_UINT8
=
1
;
const
OFFSET_INT8
=
1
;
const
OFFSET_UINT32
=
4
;
export
class
BufferReader
{
dataView
:
DataView
;
littleEndian
:
boolean
;
offset
:
number
;
constructor
(
data
:
Uint8Array
,
littleEndian
:
boolean
)
{
this
.
dataView
=
new
DataView
(
data
.
buffer
);
this
.
littleEndian
=
littleEndian
;
this
.
offset
=
0
;
}
readUint8
():
number
{
const
ret
=
this
.
dataView
.
getUint8
(
this
.
offset
);
this
.
offset
+=
OFFSET_UINT8
;
return
ret
;
}
readInt8
():
number
{
const
ret
=
this
.
dataView
.
getInt8
(
this
.
offset
);
this
.
offset
+=
OFFSET_INT8
;
return
ret
;
}
readUint32
():
number
{
const
ret
=
this
.
dataView
.
getUint32
(
this
.
offset
,
this
.
littleEndian
);
this
.
offset
+=
OFFSET_UINT32
;
return
ret
;
}
}
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
37f73cd3
...
@@ -24,3 +24,4 @@ export const STOC_DUEL_START = 21;
...
@@ -24,3 +24,4 @@ export const STOC_DUEL_START = 21;
export
const
STOC_GAME_MSG
=
1
;
export
const
STOC_GAME_MSG
=
1
;
export
const
MSG_START
=
4
;
export
const
MSG_START
=
4
;
export
const
MSG_DRAW
=
90
;
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/draw.ts
0 → 100644
View file @
37f73cd3
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
const
LITTLE_ENDIAN
=
true
;
/*
* MSG Draw
*
* @param player: char - 玩家编号
*
* @usage - 玩家抽卡内容
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReader
(
data
,
LITTLE_ENDIAN
);
const
player
=
reader
.
readUint8
();
const
count
=
reader
.
readUint8
();
let
cards
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
cards
.
push
(
reader
.
readUint32
());
}
return
new
ygopro
.
StocGameMessage
.
MsgDraw
({
player
,
count
,
cards
,
});
};
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
37f73cd3
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
YgoProPacket
,
StocAdapter
}
from
"
../../packet
"
;
import
{
YgoProPacket
,
StocAdapter
}
from
"
../../packet
"
;
import
{
MSG_START
}
from
"
../../protoDecl
"
;
import
*
as
GAME_MSG
from
"
../../protoDecl
"
;
import
MsgStartAdapter
from
"
./start
"
;
import
MsgStartAdapter
from
"
./start
"
;
import
MsgDrawAdapter
from
"
./draw
"
;
/*
/*
* STOC GameMsg
* STOC GameMsg
...
@@ -32,11 +33,16 @@ export default class GameMsgAdapter implements StocAdapter {
...
@@ -32,11 +33,16 @@ export default class GameMsgAdapter implements StocAdapter {
const
gameMsg
=
new
ygopro
.
StocGameMessage
({});
const
gameMsg
=
new
ygopro
.
StocGameMessage
({});
switch
(
func
)
{
switch
(
func
)
{
case
MSG_START
:
{
case
GAME_MSG
.
MSG_START
:
{
gameMsg
.
start
=
MsgStartAdapter
(
gameData
);
gameMsg
.
start
=
MsgStartAdapter
(
gameData
);
break
;
break
;
}
}
case
GAME_MSG
.
MSG_DRAW
:
{
gameMsg
.
draw
=
MsgDrawAdapter
(
gameData
);
break
;
}
default
:
{
default
:
{
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
...
...
src/service/duel/gameMsg.ts
View file @
37f73cd3
...
@@ -10,6 +10,12 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
...
@@ -10,6 +10,12 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
break
;
}
}
case
"
draw
"
:
{
// TODO
console
.
log
(
msg
.
draw
);
break
;
}
default
:
{
default
:
{
console
.
log
(
"
Unhandled GameMsg=
"
+
msg
.
gameMsg
);
console
.
log
(
"
Unhandled GameMsg=
"
+
msg
.
gameMsg
);
...
...
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