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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
3d2bc984
Commit
3d2bc984
authored
Jan 02, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add selectCard adapter and service
parent
b87313f2
Pipeline
#19120
passed with stages
in 4 minutes and 45 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
31 deletions
+84
-31
src/api/ocgcore/ocgAdapter/bufferIO.ts
src/api/ocgcore/ocgAdapter/bufferIO.ts
+25
-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
+2
-31
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/selectCard.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/selectCard.ts
+33
-0
src/api/ocgcore/ocgAdapter/util.ts
src/api/ocgcore/ocgAdapter/util.ts
+1
-0
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+8
-0
src/service/duel/selectCard.ts
src/service/duel/selectCard.ts
+8
-0
No files found.
src/api/ocgcore/ocgAdapter/bufferIO.ts
View file @
3d2bc984
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../idl/ocgcore
"
;
import
{
numberToCardPosition
,
numberToCardZone
}
from
"
./util
"
;
const
OFFSET_UINT8
=
1
;
const
OFFSET_UINT8
=
1
;
const
OFFSET_INT8
=
1
;
const
OFFSET_INT8
=
1
;
...
@@ -62,6 +63,30 @@ export class BufferReader {
...
@@ -62,6 +63,30 @@ export class BufferReader {
return
cardInfo
;
return
cardInfo
;
}
}
readCardLocation
(
overlay
?:
boolean
):
ygopro
.
CardLocation
{
const
controler
=
this
.
readUint8
();
const
location
=
this
.
readUint8
();
const
sequence
=
this
.
readUint8
();
const
ss
=
this
.
readUint8
();
const
cardLocation
=
new
ygopro
.
CardLocation
({
controler
,
location
:
numberToCardZone
(
location
),
sequence
,
});
if
(
overlay
)
{
cardLocation
.
overlay_sequence
=
ss
;
}
else
{
const
position
=
numberToCardPosition
(
ss
);
if
(
position
)
{
cardLocation
.
position
=
position
;
}
}
return
cardLocation
;
}
}
}
export
class
BufferWriter
{
export
class
BufferWriter
{
...
...
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
3d2bc984
...
@@ -34,3 +34,4 @@ export const MSG_HINT = 2;
...
@@ -34,3 +34,4 @@ 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
;
export
const
MSG_MOVE
=
50
;
export
const
MSG_SELECT_CARD
=
15
;
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
3d2bc984
...
@@ -14,6 +14,7 @@ import MsgHintAdapter from "./hint";
...
@@ -14,6 +14,7 @@ import MsgHintAdapter from "./hint";
import
MsgSelectIdleCmdAdapter
from
"
./selectIdleCmd
"
;
import
MsgSelectIdleCmdAdapter
from
"
./selectIdleCmd
"
;
import
MsgSelectPlaceAdapter
from
"
./selectPlace
"
;
import
MsgSelectPlaceAdapter
from
"
./selectPlace
"
;
import
MsgMoveAdapter
from
"
./move
"
;
import
MsgMoveAdapter
from
"
./move
"
;
import
MsgSelectCardAdapter
from
"
./selectCard
"
;
/*
/*
* STOC GameMsg
* STOC GameMsg
...
@@ -79,6 +80,11 @@ export default class GameMsgAdapter implements StocAdapter {
...
@@ -79,6 +80,11 @@ export default class GameMsgAdapter implements StocAdapter {
break
;
break
;
}
}
case
GAME_MSG
.
MSG_SELECT_CARD
:
{
gameMsg
.
select_card
=
MsgSelectCardAdapter
(
gameData
);
break
;
}
default
:
{
default
:
{
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/move.ts
View file @
3d2bc984
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
import
{
cardZoneToNumber
,
numberToCardPosition
,
numberToCardZone
,
}
from
"
../../util
"
;
import
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
import
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
/*
/*
...
@@ -19,32 +14,8 @@ export default (data: Uint8Array) => {
...
@@ -19,32 +14,8 @@ export default (data: Uint8Array) => {
const
code
=
reader
.
readUint32
();
const
code
=
reader
.
readUint32
();
const
readCardLocation
=
()
=>
{
const
fromLocation
=
reader
.
readCardLocation
();
const
controler
=
reader
.
readUint8
();
const
toLocation
=
reader
.
readCardLocation
();
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
))
{
const
position
=
numberToCardPosition
(
ss
);
if
(
position
)
{
cardLocation
.
position
=
position
;
}
}
else
{
cardLocation
.
overlay_sequence
=
ss
;
}
return
cardLocation
;
};
const
fromLocation
=
readCardLocation
();
const
toLocation
=
readCardLocation
();
return
new
MsgMove
({
return
new
MsgMove
({
code
,
code
,
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/selectCard.ts
0 → 100644
View file @
3d2bc984
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
/*
* Msg Select Card
*
* @param - see: https://code.mycard.moe/mycard/neos-protobuf/-/blob/main/idl/ocgcore.neos-protobuf
* @usage - 玩家可选择的卡牌
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReader
(
data
,
true
);
const
player
=
reader
.
readUint8
();
const
cancelable
=
reader
.
readUint8
()
!=
0
;
const
min
=
reader
.
readUint8
();
const
max
=
reader
.
readUint8
();
const
count
=
reader
.
readUint8
();
const
msg
=
new
MsgSelectCard
({
player
,
cancelable
,
min
,
max
});
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
const
code
=
reader
.
readUint32
();
const
location
=
reader
.
readCardLocation
();
msg
.
cards
.
push
(
new
MsgSelectCard
.
SelectAbleCard
({
code
,
location
,
response
:
i
})
);
}
return
msg
;
};
src/api/ocgcore/ocgAdapter/util.ts
View file @
3d2bc984
...
@@ -157,6 +157,7 @@ export function numberToCardZone(
...
@@ -157,6 +157,7 @@ export function numberToCardZone(
}
}
}
}
// TODO: 需要考虑超量叠加情况下的位运算
export
function
numberToCardPosition
(
export
function
numberToCardPosition
(
position
:
number
position
:
number
):
ygopro
.
CardPosition
|
undefined
{
):
ygopro
.
CardPosition
|
undefined
{
...
...
src/service/duel/gameMsg.ts
View file @
3d2bc984
...
@@ -8,6 +8,7 @@ import onMsgHint from "./hint";
...
@@ -8,6 +8,7 @@ import onMsgHint from "./hint";
import
onMsgSelectIdleCmd
from
"
./selectIdleCmd
"
;
import
onMsgSelectIdleCmd
from
"
./selectIdleCmd
"
;
import
onMsgSelectPlace
from
"
./selectPlace
"
;
import
onMsgSelectPlace
from
"
./selectPlace
"
;
import
onMsgMove
from
"
./move
"
;
import
onMsgMove
from
"
./move
"
;
import
onMsgSelectCard
from
"
./selectCard
"
;
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
dispatch
=
store
.
dispatch
;
const
dispatch
=
store
.
dispatch
;
...
@@ -70,6 +71,13 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
...
@@ -70,6 +71,13 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
break
;
}
}
case
"
select_card
"
:
{
const
selectCard
=
msg
.
select_card
;
onMsgSelectCard
(
selectCard
,
dispatch
);
break
;
}
default
:
{
default
:
{
break
;
break
;
}
}
...
...
src/service/duel/selectCard.ts
0 → 100644
View file @
3d2bc984
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
export
default
(
selectCard
:
MsgSelectCard
,
dispatch
:
AppDispatch
)
=>
{
console
.
log
(
selectCard
);
// TODO
};
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