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
baichixing
Neos
Commits
d8cfe6a5
Commit
d8cfe6a5
authored
Dec 30, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MsgMoveAdapter
parent
e796acce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
0 deletions
+98
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+1
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
+6
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/move.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/move.ts
+48
-0
src/api/ocgcore/ocgAdapter/util.ts
src/api/ocgcore/ocgAdapter/util.ts
+43
-0
No files found.
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
d8cfe6a5
...
@@ -33,3 +33,4 @@ export const MSG_NEW_PHASE = 41;
...
@@ -33,3 +33,4 @@ export const MSG_NEW_PHASE = 41;
export
const
MSG_HINT
=
2
;
export
const
MSG_HINT
=
2
;
export
const
MSG_SELECT_IDLE_CMD
=
11
;
export
const
MSG_SELECT_IDLE_CMD
=
11
;
export
const
MSG_SELECT_PLACE
=
18
;
export
const
MSG_SELECT_PLACE
=
18
;
export
const
MSG_MOVE
=
50
;
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
d8cfe6a5
...
@@ -13,6 +13,7 @@ import MsgNewPhaseAdapter from "./newPhase";
...
@@ -13,6 +13,7 @@ import MsgNewPhaseAdapter from "./newPhase";
import
MsgHintAdapter
from
"
./hint
"
;
import
MsgHintAdapter
from
"
./hint
"
;
import
MsgSelectIdleCmdAdapter
from
"
./selectIdleCmd
"
;
import
MsgSelectIdleCmdAdapter
from
"
./selectIdleCmd
"
;
import
MsgSelectPlaceAdapter
from
"
./selectPlace
"
;
import
MsgSelectPlaceAdapter
from
"
./selectPlace
"
;
import
MsgMoveAdapter
from
"
./move
"
;
/*
/*
* STOC GameMsg
* STOC GameMsg
...
@@ -73,6 +74,11 @@ export default class GameMsgAdapter implements StocAdapter {
...
@@ -73,6 +74,11 @@ export default class GameMsgAdapter implements StocAdapter {
break
;
break
;
}
}
case
GAME_MSG
.
MSG_MOVE
:
{
gameMsg
.
move
=
MsgMoveAdapter
(
gameData
);
break
;
}
default
:
{
default
:
{
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/move.ts
0 → 100644
View file @
d8cfe6a5
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
import
{
cardZoneToNumber
,
numberToCardZone
}
from
"
../../util
"
;
import
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
/*
* Msg Move
* @param - TODO
*
* @usage - 服务端告知前端/客户端卡牌移动信息
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReader
(
data
,
true
);
const
code
=
reader
.
readUint32
();
const
readCardLocation
=
()
=>
{
const
controler
=
reader
.
readUint8
();
const
location
=
reader
.
readUint8
();
const
sequence
=
reader
.
readUint8
();
const
ss
=
reader
.
readUint8
();
const
cardLocation
=
new
ygopro
.
CardLocation
({
controler
,
location
:
numberToCardZone
(
location
),
sequence
,
});
if
(
location
!=
cardZoneToNumber
(
ygopro
.
CardZone
.
OVERLAY
))
{
cardLocation
.
position
=
ss
;
}
else
{
cardLocation
.
overlay_sequence
=
ss
;
}
return
cardLocation
;
};
const
fromLocation
=
readCardLocation
();
const
toLocation
=
readCardLocation
();
return
new
MsgMove
({
code
,
from
:
fromLocation
,
to
:
toLocation
,
reason
:
reader
.
readUint8
(),
});
};
src/api/ocgcore/ocgAdapter/util.ts
View file @
d8cfe6a5
...
@@ -113,3 +113,46 @@ export function cardZoneToNumber(zone: ygopro.CardZone): number {
...
@@ -113,3 +113,46 @@ export function cardZoneToNumber(zone: ygopro.CardZone): number {
}
}
}
}
}
}
export
function
numberToCardZone
(
location
:
number
):
ygopro
.
CardZone
|
undefined
{
switch
(
location
)
{
case
0x01
:
{
return
ygopro
.
CardZone
.
DECK
;
}
case
0x02
:
{
return
ygopro
.
CardZone
.
HAND
;
}
case
0x04
:
{
return
ygopro
.
CardZone
.
MZONE
;
}
case
0x08
:
{
return
ygopro
.
CardZone
.
SZONE
;
}
case
0x10
:
{
return
ygopro
.
CardZone
.
GRAVE
;
}
case
0x20
:
{
return
ygopro
.
CardZone
.
REMOVED
;
}
case
0x40
:
{
return
ygopro
.
CardZone
.
EXTRA
;
}
case
0x80
:
{
return
ygopro
.
CardZone
.
OVERLAY
;
}
case
0x0c
:
{
return
ygopro
.
CardZone
.
ONFIELD
;
}
case
0x100
:
{
return
ygopro
.
CardZone
.
FZONE
;
}
case
0x200
:
{
return
ygopro
.
CardZone
.
PZONE
;
}
default
:
{
return
undefined
;
}
}
}
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