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
0e6be757
Commit
0e6be757
authored
Oct 23, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add CtosUpdateDeck adapt
parent
1aad1af3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
9 deletions
+52
-9
src/api/ocgcore/ocgAdapter/ctos/ctosUpdateDeck.ts
src/api/ocgcore/ocgAdapter/ctos/ctosUpdateDeck.ts
+40
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+1
-0
src/api/ocgcore/ocgHelper.ts
src/api/ocgcore/ocgHelper.ts
+7
-4
src/middleware/socket.ts
src/middleware/socket.ts
+4
-5
No files found.
src/api/ocgcore/ocgAdapter/ctos/ctosUpdateDeck.ts
0 → 100644
View file @
0e6be757
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
ygoProPacket
}
from
"
../packet
"
;
import
{
CTOS_UPDATE_DECK
}
from
"
../protoDecl
"
;
const
BYTES_PER_U32
=
4
;
export
default
class
CtosUpdateDeck
extends
ygoProPacket
{
constructor
(
pb
:
ygopro
.
YgoCtosMsg
)
{
const
updateDeck
=
pb
.
ctos_update_deck
;
const
main
=
updateDeck
.
main
;
const
extra
=
updateDeck
.
extra
;
const
side
=
updateDeck
.
side
;
const
mainLen
=
main
.
length
+
extra
.
length
;
const
sideLen
=
side
.
length
;
const
exDataLen
=
(
2
+
mainLen
+
sideLen
)
*
BYTES_PER_U32
;
const
exData
=
new
Uint8Array
(
exDataLen
);
const
dataView
=
new
DataView
(
exData
.
buffer
);
dataView
.
setInt32
(
0
,
mainLen
,
true
);
dataView
.
setInt32
(
1
*
BYTES_PER_U32
,
sideLen
,
true
);
let
offset
=
2
;
for
(
let
card
of
main
)
{
dataView
.
setInt32
(
offset
*
BYTES_PER_U32
,
card
,
true
);
offset
+=
1
;
}
for
(
let
card
of
extra
)
{
dataView
.
setInt32
(
offset
*
BYTES_PER_U32
,
card
,
true
);
offset
+=
1
;
}
for
(
let
card
of
side
)
{
dataView
.
setInt32
(
offset
*
BYTES_PER_U32
,
card
,
true
);
offset
+=
1
;
}
super
(
exDataLen
+
3
,
CTOS_UPDATE_DECK
,
exData
);
}
}
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
0e6be757
export
const
CTOS_PLAYER_INFO
=
16
;
export
const
CTOS_PLAYER_INFO
=
16
;
export
const
CTOS_JOIN_GAME
=
18
;
export
const
CTOS_JOIN_GAME
=
18
;
export
const
CTOS_UPDATE_DECK
=
2
;
export
const
STOC_JOIN_GAME
=
18
;
export
const
STOC_JOIN_GAME
=
18
;
export
const
STOC_CHAT
=
25
;
export
const
STOC_CHAT
=
25
;
src/api/ocgcore/ocgHelper.ts
View file @
0e6be757
...
@@ -3,6 +3,7 @@ import socketMiddleWare, { socketCmd } from "../../middleware/socket";
...
@@ -3,6 +3,7 @@ import socketMiddleWare, { socketCmd } from "../../middleware/socket";
import
{
IDeck
}
from
"
../Card
"
;
import
{
IDeck
}
from
"
../Card
"
;
import
playerInfoPacket
from
"
./ocgAdapter/ctos/ctosPlayerInfo
"
;
import
playerInfoPacket
from
"
./ocgAdapter/ctos/ctosPlayerInfo
"
;
import
joinGamePacket
from
"
./ocgAdapter/ctos/ctosJoinGame
"
;
import
joinGamePacket
from
"
./ocgAdapter/ctos/ctosJoinGame
"
;
import
CtosUpdateDeck
from
"
./ocgAdapter/ctos/ctosUpdateDeck
"
;
export
function
sendUpdateDeck
(
deck
:
IDeck
)
{
export
function
sendUpdateDeck
(
deck
:
IDeck
)
{
const
updateDeck
=
new
ygopro
.
YgoCtosMsg
({
const
updateDeck
=
new
ygopro
.
YgoCtosMsg
({
...
@@ -12,8 +13,10 @@ export function sendUpdateDeck(deck: IDeck) {
...
@@ -12,8 +13,10 @@ export function sendUpdateDeck(deck: IDeck) {
side
:
deck
.
side
,
side
:
deck
.
side
,
}),
}),
});
});
const
payload
=
new
CtosUpdateDeck
(
updateDeck
).
serialize
();
console
.
log
(
payload
);
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
:
updateDeck
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
}
export
function
sendHsReady
()
{
export
function
sendHsReady
()
{
...
@@ -21,7 +24,7 @@ export function sendHsReady() {
...
@@ -21,7 +24,7 @@ export function sendHsReady() {
ctos_hs_ready
:
new
ygopro
.
CtosHsReady
({}),
ctos_hs_ready
:
new
ygopro
.
CtosHsReady
({}),
});
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
:
hasReady
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
:
hasReady
.
serialize
()
});
}
}
export
function
sendHsStart
()
{
export
function
sendHsStart
()
{
...
@@ -29,7 +32,7 @@ export function sendHsStart() {
...
@@ -29,7 +32,7 @@ export function sendHsStart() {
ctos_hs_start
:
new
ygopro
.
CtosHsStart
({}),
ctos_hs_start
:
new
ygopro
.
CtosHsStart
({}),
});
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
:
hasStart
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
:
hasStart
.
serialize
()
});
}
}
export
function
sendPlayerInfo
(
ws
:
WebSocket
,
player
:
string
)
{
export
function
sendPlayerInfo
(
ws
:
WebSocket
,
player
:
string
)
{
...
@@ -38,7 +41,7 @@ export function sendPlayerInfo(ws: WebSocket, player: string) {
...
@@ -38,7 +41,7 @@ export function sendPlayerInfo(ws: WebSocket, player: string) {
name
:
player
,
name
:
player
,
}),
}),
});
});
const
packet
=
new
playerInfoPacket
(
playerInfo
);
const
packet
=
new
playerInfoPacket
(
playerInfo
);
// todo: 需要收敛在一个层次里
ws
.
send
(
packet
.
serialize
());
ws
.
send
(
packet
.
serialize
());
}
}
...
...
src/middleware/socket.ts
View file @
0e6be757
import
{
ygopro
}
from
"
../api/ocgcore/idl/ocgcore
"
;
import
handleSocketOpen
from
"
../service/onSocketOpen
"
;
import
handleSocketOpen
from
"
../service/onSocketOpen
"
;
import
handleSocketMessage
from
"
../service/onSocketMessage
"
;
import
handleSocketMessage
from
"
../service/onSocketMessage
"
;
...
@@ -15,7 +14,7 @@ export interface socketAction {
...
@@ -15,7 +14,7 @@ export interface socketAction {
player
:
string
;
player
:
string
;
passWd
:
string
;
passWd
:
string
;
};
};
payload
?:
ygopro
.
YgoCtosMsg
;
payload
?:
Uint8Array
;
}
}
let
ws
:
WebSocket
|
null
=
null
;
let
ws
:
WebSocket
|
null
=
null
;
...
@@ -47,9 +46,9 @@ export default function (action: socketAction) {
...
@@ -47,9 +46,9 @@ export default function (action: socketAction) {
break
;
break
;
}
}
case
socketCmd
.
SEND
:
{
case
socketCmd
.
SEND
:
{
const
p
b
=
action
.
payload
;
const
p
ayload
=
action
.
payload
;
if
(
ws
&&
p
b
)
{
if
(
ws
&&
p
ayload
)
{
ws
.
send
(
p
b
.
serialize
()
);
ws
.
send
(
p
ayload
);
}
}
break
;
break
;
...
...
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