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
55eba807
Commit
55eba807
authored
Nov 05, 2022
by
Chunchi Che
Committed by
WANG HE
Dec 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle deckcount
parent
3989ad51
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
118 additions
and
1 deletion
+118
-1
src/api/ocgcore/ocgAdapter/adapter.ts
src/api/ocgcore/ocgAdapter/adapter.ts
+13
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+2
-0
src/api/ocgcore/ocgAdapter/stoc/stocDeckCount.ts
src/api/ocgcore/ocgAdapter/stoc/stocDeckCount.ts
+37
-0
src/api/ocgcore/ocgAdapter/stoc/stocJoinGame.ts
src/api/ocgcore/ocgAdapter/stoc/stocJoinGame.ts
+1
-1
src/reducers/playerSlice.ts
src/reducers/playerSlice.ts
+15
-0
src/service/mora/deckCount.ts
src/service/mora/deckCount.ts
+25
-0
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+12
-0
src/ui/Mora.tsx
src/ui/Mora.tsx
+13
-0
No files found.
src/api/ocgcore/ocgAdapter/adapter.ts
View file @
55eba807
...
...
@@ -10,6 +10,8 @@ import {
STOC_SELECT_HAND
,
STOC_SELECT_TP
,
STOC_HAND_RESULT
,
STOC_DECK_COUNT
,
STOC_DUEL_START
,
}
from
"
./protoDecl
"
;
import
StocChat
from
"
./stoc/stocChat
"
;
import
StocJoinGame
from
"
./stoc/stocJoinGame
"
;
...
...
@@ -19,6 +21,7 @@ import StocHsWatchChange from "./stoc/stocHsWatchChange";
import
StocTypeChange
from
"
./stoc/stocTypeChange
"
;
import
StocSelectHand
from
"
./stoc/stocSelectHand
"
;
import
StocSelectTp
from
"
./stoc/stocSelectTp
"
;
import
StocDeckCount
from
"
./stoc/stocDeckCount
"
;
/*
* 将[`ygoProPacket`]对象转换成[`ygopro.YgoStocMsg`]对象
...
...
@@ -74,6 +77,16 @@ export function adaptStoc(packet: ygoProPacket): ygopro.YgoStocMsg {
break
;
}
case
STOC_DECK_COUNT
:
{
pb
=
new
StocDeckCount
(
packet
).
upcast
();
break
;
}
case
STOC_DUEL_START
:
{
// TODO
break
;
}
default
:
{
break
;
}
...
...
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
55eba807
...
...
@@ -19,3 +19,5 @@ export const STOC_TYPE_CHANGE = 19;
export
const
STOC_SELECT_HAND
=
3
;
export
const
STOC_SELECT_TP
=
4
;
export
const
STOC_HAND_RESULT
=
5
;
export
const
STOC_DECK_COUNT
=
9
;
export
const
STOC_DUEL_START
=
21
;
src/api/ocgcore/ocgAdapter/stoc/stocDeckCount.ts
0 → 100644
View file @
55eba807
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
ygoProPacket
,
StocAdapter
}
from
"
../packet
"
;
const
LITTLE_ENDIAN
=
true
;
const
INT16_BYTE_OFFSET
=
2
;
/*
* STOC DeckCount
*
* @param see ocgcore.proto
*
* @usage - 展示双方卡组信息
* */
export
default
class
deckCountAdapter
implements
StocAdapter
{
packet
:
ygoProPacket
;
constructor
(
packet
:
ygoProPacket
)
{
this
.
packet
=
packet
;
}
upcast
():
ygopro
.
YgoStocMsg
{
const
pb
=
new
ygopro
.
StocDeckCount
({});
const
dataView
=
new
DataView
(
this
.
packet
.
exData
.
buffer
);
pb
.
meMain
=
dataView
.
getInt16
(
0
*
INT16_BYTE_OFFSET
,
LITTLE_ENDIAN
);
pb
.
meExtra
=
dataView
.
getInt16
(
1
*
INT16_BYTE_OFFSET
,
LITTLE_ENDIAN
);
pb
.
meSide
=
dataView
.
getInt16
(
2
*
INT16_BYTE_OFFSET
,
LITTLE_ENDIAN
);
pb
.
opMain
=
dataView
.
getInt16
(
3
*
INT16_BYTE_OFFSET
,
LITTLE_ENDIAN
);
pb
.
opExtra
=
dataView
.
getInt16
(
4
*
INT16_BYTE_OFFSET
,
LITTLE_ENDIAN
);
pb
.
opSide
=
dataView
.
getInt16
(
5
*
INT16_BYTE_OFFSET
,
LITTLE_ENDIAN
);
return
new
ygopro
.
YgoStocMsg
({
stoc_deck_count
:
pb
,
});
}
}
src/api/ocgcore/ocgAdapter/stoc/stocJoinGame.ts
View file @
55eba807
...
...
@@ -14,7 +14,7 @@ export default class joinGameAdapter implements StocAdapter {
}
upcast
():
ygopro
.
YgoStocMsg
{
//
todo
//
TODO
return
new
ygopro
.
YgoStocMsg
({
stoc_join_game
:
new
ygopro
.
StocJoinGame
({}),
});
...
...
src/reducers/playerSlice.ts
View file @
55eba807
...
...
@@ -9,6 +9,13 @@ export interface Player {
name
?:
string
;
state
?:
string
;
isHost
?:
boolean
;
deckInfo
?:
deckInfo
;
}
export
interface
deckInfo
{
mainCnt
:
number
;
extraCnt
:
number
;
sideCnt
:
number
;
}
export
interface
playerState
{
...
...
@@ -47,6 +54,12 @@ const playerSlice = createSlice({
player1Leave
:
(
state
)
=>
{
state
.
player1
=
{};
},
player0DeckInfo
:
(
state
,
action
:
PayloadAction
<
deckInfo
>
)
=>
{
state
.
player0
.
deckInfo
=
action
.
payload
;
},
player1DeckInfo
:
(
state
,
action
:
PayloadAction
<
deckInfo
>
)
=>
{
state
.
player1
.
deckInfo
=
action
.
payload
;
},
hostChange
:
(
state
,
action
:
PayloadAction
<
number
>
)
=>
{
const
i
=
action
.
payload
;
...
...
@@ -77,6 +90,8 @@ export const {
player1Update
,
player0Leave
,
player1Leave
,
player0DeckInfo
,
player1DeckInfo
,
hostChange
,
observerIncrement
,
observerChange
,
...
...
src/service/mora/deckCount.ts
0 → 100644
View file @
55eba807
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
store
}
from
"
../../store
"
;
import
{
player0DeckInfo
,
player1DeckInfo
}
from
"
../../reducers/playerSlice
"
;
// FIXME: player0 不一定是当前玩家
export
default
function
handleDeckCount
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
dispath
=
store
.
dispatch
;
const
deckCount
=
pb
.
stoc_deck_count
;
dispath
(
player0DeckInfo
({
mainCnt
:
deckCount
.
meMain
,
extraCnt
:
deckCount
.
meExtra
,
sideCnt
:
deckCount
.
meSide
,
})
);
dispath
(
player1DeckInfo
({
mainCnt
:
deckCount
.
opMain
,
extraCnt
:
deckCount
.
opExtra
,
sideCnt
:
deckCount
.
opSide
,
})
);
}
src/service/onSocketMessage.ts
View file @
55eba807
...
...
@@ -12,6 +12,7 @@ import { ygoProPacket } from "../api/ocgcore/ocgAdapter/packet";
import
{
adaptStoc
}
from
"
../api/ocgcore/ocgAdapter/adapter
"
;
import
handleSelectHand
from
"
./mora/selectHand
"
;
import
handleSelectTp
from
"
./mora/selectTp
"
;
import
handleDeckCount
from
"
./mora/deckCount
"
;
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
...
...
@@ -69,6 +70,17 @@ export default function handleSocketMessage(e: MessageEvent) {
break
;
}
case
"
stoc_deck_count
"
:
{
handleDeckCount
(
pb
);
break
;
}
case
"
stoc_duel_start
"
:
{
// TODO
console
.
log
(
"
TODO: handle STOC DuleStart.
"
);
break
;
}
default
:
{
console
.
log
(
packet
);
...
...
src/ui/Mora.tsx
View file @
55eba807
...
...
@@ -13,6 +13,7 @@ import {
selectTpSelectAble
,
unSelectTpAble
,
}
from
"
../reducers/moraSlice
"
;
import
{
selectPlayer0
,
selectPlayer1
}
from
"
../reducers/playerSlice
"
;
import
{
store
}
from
"
../store
"
;
// TODO: 应该展示对手卡组信息和聊天信息
...
...
@@ -20,6 +21,8 @@ export default function Mora() {
const
dispatch
=
store
.
dispatch
;
const
selectHandAble
=
useAppSelector
(
selectHandSelectAble
);
const
selectTpAble
=
useAppSelector
(
selectTpSelectAble
);
const
player0
=
useAppSelector
(
selectPlayer0
);
const
player1
=
useAppSelector
(
selectPlayer1
);
const
handleSelectScissors
=
()
=>
{
sendHandResult
(
"
scissors
"
);
...
...
@@ -63,6 +66,16 @@ export default function Mora() {
second
</
button
>
</
div
>
<
div
className=
"item"
>
<
p
>
Me: main=
{
player0
.
deckInfo
?.
mainCnt
}
, extra=
{
player0
.
deckInfo
?.
extraCnt
}
, side=
{
player0
.
deckInfo
?.
sideCnt
}
</
p
>
<
p
>
Me: main=
{
player1
.
deckInfo
?.
mainCnt
}
, extra=
{
player1
.
deckInfo
?.
extraCnt
}
, side=
{
player1
.
deckInfo
?.
sideCnt
}
</
p
>
</
div
>
</
div
>
);
}
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