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
861c4e93
Commit
861c4e93
authored
Mar 05, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/nagivate' into 'main'
Optimize/nagivate See merge request
!117
parents
6e57d067
73946803
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
19 deletions
+53
-19
src/api/ocgcore/ocgAdapter/adapter.ts
src/api/ocgcore/ocgAdapter/adapter.ts
+2
-1
src/api/ocgcore/ocgAdapter/stoc/stocDuelStart.ts
src/api/ocgcore/ocgAdapter/stoc/stocDuelStart.ts
+21
-0
src/reducers/moraSlice.ts
src/reducers/moraSlice.ts
+7
-0
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+2
-2
src/service/room/duelStart.ts
src/service/room/duelStart.ts
+9
-0
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+12
-16
No files found.
src/api/ocgcore/ocgAdapter/adapter.ts
View file @
861c4e93
...
...
@@ -26,6 +26,7 @@ import StocSelectTp from "./stoc/stocSelectTp";
import
StocDeckCount
from
"
./stoc/stocDeckCount
"
;
import
StocTimeLimit
from
"
./stoc/stocTimeLimit
"
;
import
StocGameMsg
from
"
./stoc/stocGameMsg/mod
"
;
import
StocDuelStart
from
"
./stoc/stocDuelStart
"
;
/*
* 将[`ygoProPacket`]对象转换成[`ygopro.YgoStocMsg`]对象
...
...
@@ -87,7 +88,7 @@ export function adaptStoc(packet: YgoProPacket): ygopro.YgoStocMsg {
break
;
}
case
STOC_DUEL_START
:
{
// TODO
pb
=
new
StocDuelStart
(
packet
).
upcast
();
break
;
}
...
...
src/api/ocgcore/ocgAdapter/stoc/stocDuelStart.ts
0 → 100644
View file @
861c4e93
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
YgoProPacket
,
StocAdapter
}
from
"
../packet
"
;
/*
* STOC DuelStart
*
* @usage - 通知客户端决斗开始
* */
export
default
class
DuelStart
implements
StocAdapter
{
packet
:
YgoProPacket
;
constructor
(
packet
:
YgoProPacket
)
{
this
.
packet
=
packet
;
}
upcast
():
ygopro
.
YgoStocMsg
{
return
new
ygopro
.
YgoStocMsg
({
stoc_duel_start
:
new
ygopro
.
StocDuelStart
({}),
});
}
}
src/reducers/moraSlice.ts
View file @
861c4e93
...
...
@@ -6,11 +6,13 @@ import { createSlice } from "@reduxjs/toolkit";
import
{
RootState
}
from
"
../store
"
;
export
interface
moraState
{
duelStart
:
boolean
;
selectHandAble
:
boolean
;
selectTpAble
:
boolean
;
}
const
initialState
:
moraState
=
{
duelStart
:
false
,
selectHandAble
:
false
,
selectTpAble
:
false
,
};
...
...
@@ -19,6 +21,9 @@ const moraSlice = createSlice({
name
:
"
mora
"
,
initialState
,
reducers
:
{
duelStart
:
(
state
)
=>
{
state
.
duelStart
=
true
;
},
selectHandAble
:
(
state
)
=>
{
state
.
selectHandAble
=
true
;
},
...
...
@@ -35,11 +40,13 @@ const moraSlice = createSlice({
});
export
const
{
duelStart
,
selectHandAble
,
unSelectHandAble
,
selectTpAble
,
unSelectTpAble
,
}
=
moraSlice
.
actions
;
export
const
selectDuelStart
=
(
state
:
RootState
)
=>
state
.
mora
.
duelStart
;
export
const
selectHandSelectAble
=
(
state
:
RootState
)
=>
state
.
mora
.
selectHandAble
;
export
const
selectTpSelectAble
=
(
state
:
RootState
)
=>
state
.
mora
.
selectTpAble
;
...
...
src/service/onSocketMessage.ts
View file @
861c4e93
...
...
@@ -15,6 +15,7 @@ import handleSelectTp from "./mora/selectTp";
import
handleDeckCount
from
"
./mora/deckCount
"
;
import
handleGameMsg
from
"
./duel/gameMsg
"
;
import
handleTimeLimit
from
"
./duel/timeLimit
"
;
import
handleDuelStart
from
"
./room/duelStart
"
;
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
...
...
@@ -78,8 +79,7 @@ export default function handleSocketMessage(e: MessageEvent) {
break
;
}
case
"
stoc_duel_start
"
:
{
// TODO
console
.
log
(
"
TODO: handle STOC DuleStart.
"
);
handleDuelStart
(
pb
);
break
;
}
...
...
src/service/room/duelStart.ts
0 → 100644
View file @
861c4e93
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
duelStart
}
from
"
../../reducers/moraSlice
"
;
import
{
store
}
from
"
../../store
"
;
export
default
function
handleDuelStart
(
_pb
:
ygopro
.
YgoStocMsg
)
{
const
dispatch
=
store
.
dispatch
;
dispatch
(
duelStart
());
}
src/ui/WaitRoom.tsx
View file @
861c4e93
...
...
@@ -40,7 +40,8 @@ import {
}
from
"
@ant-design/icons
"
;
import
{
initMeExtraDeckMeta
}
from
"
../reducers/duel/extraDeckSlice
"
;
import
type
{
MenuProps
,
UploadProps
}
from
"
antd
"
;
import
{
Link
,
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
selectDuelStart
}
from
"
../reducers/moraSlice
"
;
const
READY_STATE
=
"
ready
"
;
...
...
@@ -84,6 +85,7 @@ const WaitRoom = () => {
const
isHost
=
useAppSelector
(
selectIsHost
);
const
player0
=
useAppSelector
(
selectPlayer0
);
const
player1
=
useAppSelector
(
selectPlayer1
);
const
duelStart
=
useAppSelector
(
selectDuelStart
);
const
[
api
,
contextHolder
]
=
notification
.
useNotification
();
const
[
deckTitle
,
setDeckTitle
]
=
useState
(
"
请选择卡组
"
);
// FIXME: 这些数据应该从`store`中获取
...
...
@@ -153,6 +155,13 @@ const WaitRoom = () => {
api
.
info
({
message
:
"
Chat
"
,
description
:
chat
,
placement
:
"
bottom
"
});
}
},
[
chat
]);
useEffect
(()
=>
{
// 若当前玩家是房主并且对战双方都已准备完毕,跳转到猜拳页面;
// 否则停留在当前页面。
if
(
duelStart
)
{
navigate
(
`/mora/
${
player
}
/
${
passWd
}
/
${
ip
}
`
);
}
},
[
duelStart
]);
return
(
<>
...
...
@@ -181,21 +190,8 @@ const WaitRoom = () => {
</
Space
>
<
Space
wrap
size=
{
10
}
>
<
Avatar
size=
{
25
}
icon=
{
<
SendOutlined
/>
}
/>
<
Button
onClick=
{
handleChoseStart
}
>
<
Link
to=
{
// 若当前玩家是房主并且对战双方都已准备完毕,跳转到猜拳页面;
// 否则停留在当前页面。
!
isHost
||
!
joined
||
player0
.
state
!==
READY_STATE
||
player1
.
state
!==
READY_STATE
?
{}
:
{
pathname
:
`/mora/${player}/${passWd}/${ip}`
}
}
>
开始游戏
</
Link
>
<
Button
onClick=
{
handleChoseStart
}
disabled=
{
!
isHost
}
>
开始游戏
</
Button
>
</
Space
>
</
Space
>
...
...
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