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
d0a0a652
Commit
d0a0a652
authored
Sep 08, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加优雅退出机制
parent
addbb292
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
158 additions
and
7 deletions
+158
-7
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+104
-4
src/api/ocgcore/ocgAdapter/adapter.ts
src/api/ocgcore/ocgAdapter/adapter.ts
+6
-0
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+1
-0
src/api/ocgcore/ocgAdapter/stoc/stocDuelEnd.ts
src/api/ocgcore/ocgAdapter/stoc/stocDuelEnd.ts
+21
-0
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+5
-0
src/service/room/duelEnd.ts
src/service/room/duelEnd.ts
+6
-0
src/stores/matStore/store.ts
src/stores/matStore/store.ts
+3
-0
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+2
-0
src/ui/Duel/Main.tsx
src/ui/Duel/Main.tsx
+9
-1
src/ui/Duel/Message/EndModal/index.tsx
src/ui/Duel/Message/EndModal/index.tsx
+0
-1
No files found.
neos-protobuf
@
702feb50
Subproject commit
a02a8caa38767bb06e1a9d5be97773af5a0fc4b2
Subproject commit
702feb507a3e5cd31fdc8ee7d9e4b80e68f89923
src/api/ocgcore/idl/ocgcore.ts
View file @
d0a0a652
This diff is collapsed.
Click to expand it.
src/api/ocgcore/ocgAdapter/adapter.ts
View file @
d0a0a652
...
...
@@ -4,6 +4,7 @@ import {
STOC_CHANGE_SIDE
,
STOC_CHAT
,
STOC_DECK_COUNT
,
STOC_DUEL_END
,
STOC_DUEL_START
,
STOC_ERROR_MSG
,
STOC_GAME_MSG
,
...
...
@@ -21,6 +22,7 @@ import {
import
StocChangeSide
from
"
./stoc/stocChangeSide
"
;
import
StocChat
from
"
./stoc/stocChat
"
;
import
StocDeckCount
from
"
./stoc/stocDeckCount
"
;
import
StocDuelEnd
from
"
./stoc/stocDuelEnd
"
;
import
StocDuelStart
from
"
./stoc/stocDuelStart
"
;
import
StocErrorMsg
from
"
./stoc/stocErrorMsg
"
;
import
StocGameMsg
from
"
./stoc/stocGameMsg/mod
"
;
...
...
@@ -89,6 +91,10 @@ export function adaptStoc(packet: YgoProPacket): ygopro.YgoStocMsg {
pb
=
new
StocDuelStart
(
packet
).
upcast
();
break
;
}
case
STOC_DUEL_END
:
{
pb
=
new
StocDuelEnd
(
packet
).
upcast
();
break
;
}
case
STOC_GAME_MSG
:
{
pb
=
new
StocGameMsg
(
packet
).
upcast
();
break
;
...
...
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
d0a0a652
...
...
@@ -28,6 +28,7 @@ export const STOC_SELECT_TP = 4;
export
const
STOC_HAND_RESULT
=
5
;
export
const
STOC_DECK_COUNT
=
9
;
export
const
STOC_DUEL_START
=
21
;
export
const
STOC_DUEL_END
=
22
;
export
const
STOC_GAME_MSG
=
1
;
export
const
STOC_TIME_LIMIT
=
24
;
export
const
STOC_ERROR_MSG
=
2
;
...
...
src/api/ocgcore/ocgAdapter/stoc/stocDuelEnd.ts
0 → 100644
View file @
d0a0a652
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
StocAdapter
,
YgoProPacket
}
from
"
../packet
"
;
/*
* STOC DuelEnd
*
* @usage - 通知客户端决斗结束
* */
export
default
class
DuelEnd
implements
StocAdapter
{
packet
:
YgoProPacket
;
constructor
(
packet
:
YgoProPacket
)
{
this
.
packet
=
packet
;
}
upcast
():
ygopro
.
YgoStocMsg
{
return
new
ygopro
.
YgoStocMsg
({
stoc_duel_end
:
new
ygopro
.
StocDuelEnd
({}),
});
}
}
src/service/onSocketMessage.ts
View file @
d0a0a652
...
...
@@ -12,6 +12,7 @@ import handleDeckCount from "./mora/deckCount";
import
handleSelectHand
from
"
./mora/selectHand
"
;
import
handleSelectTp
from
"
./mora/selectTp
"
;
import
handleChat
from
"
./room/chat
"
;
import
handleDuelEnd
from
"
./room/duelEnd
"
;
import
handleDuelStart
from
"
./room/duelStart
"
;
import
handleErrorMsg
from
"
./room/errorMsg
"
;
import
handleHandResult
from
"
./room/handResult
"
;
...
...
@@ -85,6 +86,10 @@ async function _handle(e: MessageEvent) {
handleDuelStart
(
pb
);
break
;
}
case
"
stoc_duel_end
"
:
{
handleDuelEnd
(
pb
);
break
;
}
case
"
stoc_game_msg
"
:
{
await
handleGameMsg
(
pb
);
...
...
src/service/room/duelEnd.ts
0 → 100644
View file @
d0a0a652
import
{
ygopro
}
from
"
@/api
"
;
import
{
matStore
}
from
"
@/stores
"
;
export
default
function
handleDuelEnd
(
_pb
:
ygopro
.
YgoStocMsg
)
{
matStore
.
duelEnd
=
true
;
}
src/stores/matStore/store.ts
View file @
d0a0a652
...
...
@@ -85,6 +85,7 @@ const initialState: Omit<MatState, "reset"> = {
},
tossResult
:
undefined
,
chainSetting
:
ChainSetting
.
CHAIN_SMART
,
duelEnd
:
false
,
// methods
isMe
,
};
...
...
@@ -102,6 +103,7 @@ class MatStore implements MatState, NeosStore {
unimplemented
=
initialState
.
unimplemented
;
handResults
=
initialState
.
handResults
;
tossResult
=
initialState
.
tossResult
;
duelEnd
=
initialState
.
duelEnd
;
// methods
isMe
=
initialState
.
isMe
;
reset
():
void
{
...
...
@@ -123,6 +125,7 @@ class MatStore implements MatState, NeosStore {
this
.
unimplemented
=
0
;
this
.
handResults
.
me
=
0
;
this
.
handResults
.
op
=
0
;
this
.
duelEnd
=
false
;
}
}
...
...
src/stores/matStore/types.ts
View file @
d0a0a652
...
...
@@ -40,6 +40,8 @@ export interface MatState {
set
:
(
controller
:
number
,
result
:
HandResult
)
=>
void
;
};
// 猜拳结果
duelEnd
:
boolean
;
// 决斗是否结束,包括单局模式和匹配模式
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
}
...
...
src/ui/Duel/Main.tsx
View file @
d0a0a652
...
...
@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
SideStage
,
sideStore
}
from
"
@/stores
"
;
import
{
matStore
,
SideStage
,
sideStore
}
from
"
@/stores
"
;
import
{
Alert
,
...
...
@@ -22,6 +22,7 @@ import { LifeBar, Mat, Menu, Underlying } from "./PlayMat";
export
const
Component
:
React
.
FC
=
()
=>
{
const
{
stage
}
=
useSnapshot
(
sideStore
);
const
{
duelEnd
}
=
useSnapshot
(
matStore
);
const
navigate
=
useNavigate
();
useEffect
(()
=>
{
...
...
@@ -31,6 +32,13 @@ export const Component: React.FC = () => {
}
},
[
stage
]);
useEffect
(()
=>
{
if
(
duelEnd
)
{
// 决斗结束,返回匹配页
navigate
(
"
/match
"
);
}
},
[
duelEnd
]);
return
(
<>
<
Underlying
/>
...
...
src/ui/Duel/Message/EndModal/index.tsx
View file @
d0a0a652
...
...
@@ -27,7 +27,6 @@ export const EndModal: React.FC = () => {
const
onReturn
=
()
=>
{
resetDuel
();
rs
();
// TODO: 这里暂时不自动跳转,决斗结束后让玩家自己手动选择回到主页
};
return
(
...
...
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