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
b3f03bdf
Commit
b3f03bdf
authored
Jul 10, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize replay navigate
parent
95e5da5f
Pipeline
#22617
passed with stages
in 11 minutes and 36 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
src/service/duel/start.ts
src/service/duel/start.ts
+5
-0
src/stores/matStore/store.ts
src/stores/matStore/store.ts
+1
-0
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+2
-0
src/ui/Replay/index.tsx
src/ui/Replay/index.tsx
+22
-4
No files found.
src/service/duel/start.ts
View file @
b3f03bdf
...
@@ -7,6 +7,7 @@ import { fetchCard, ygopro } from "@/api";
...
@@ -7,6 +7,7 @@ import { fetchCard, ygopro } from "@/api";
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
cardStore
,
CardType
,
matStore
}
from
"
@/stores
"
;
import
{
cardStore
,
CardType
,
matStore
}
from
"
@/stores
"
;
import
{
replayStart
}
from
"
@/ui/Replay
"
;
const
TOKEN_SIZE
=
13
;
// 每人场上最多就只可能有13个token
const
TOKEN_SIZE
=
13
;
// 每人场上最多就只可能有13个token
export
default
async
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
)
=>
{
export
default
async
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
)
=>
{
...
@@ -74,6 +75,10 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
...
@@ -74,6 +75,10 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
.
at
(
ygopro
.
CardZone
.
EXTRA
,
1
-
opponent
)
.
at
(
ygopro
.
CardZone
.
EXTRA
,
1
-
opponent
)
.
forEach
((
card
)
=>
(
card
.
code
=
myExtraDeckCodes
.
pop
()
??
0
));
.
forEach
((
card
)
=>
(
card
.
code
=
myExtraDeckCodes
.
pop
()
??
0
));
if
(
matStore
.
isReplay
)
{
replayStart
();
}
// 初始化完后,sleep 1s,让UI初始化完成,
// 初始化完后,sleep 1s,让UI初始化完成,
// 否则在和AI对战时,由于后端给传给前端的`MSG`频率太高,会导致一些问题。
// 否则在和AI对战时,由于后端给传给前端的`MSG`频率太高,会导致一些问题。
await
sleep
(
useConfig
().
startDelay
);
await
sleep
(
useConfig
().
startDelay
);
...
...
src/stores/matStore/store.ts
View file @
b3f03bdf
...
@@ -80,6 +80,7 @@ export const matStore: MatState = proxy<MatState>({
...
@@ -80,6 +80,7 @@ export const matStore: MatState = proxy<MatState>({
enableM2
:
false
,
// 允许进入M2阶段
enableM2
:
false
,
// 允许进入M2阶段
enableEp
:
false
,
// 允许回合结束
enableEp
:
false
,
// 允许回合结束
},
},
isReplay
:
false
,
unimplemented
:
0
,
unimplemented
:
0
,
handResults
:
{
handResults
:
{
me
:
0
,
me
:
0
,
...
...
src/stores/matStore/types.ts
View file @
b3f03bdf
...
@@ -28,6 +28,8 @@ export interface MatState {
...
@@ -28,6 +28,8 @@ export interface MatState {
phase
:
PhaseState
;
phase
:
PhaseState
;
isReplay
:
boolean
;
// 是否是回放模式
result
?:
{
result
?:
{
isWin
:
boolean
;
isWin
:
boolean
;
reason
:
string
;
reason
:
string
;
...
...
src/ui/Replay/index.tsx
View file @
b3f03bdf
...
@@ -2,17 +2,24 @@ import "../../styles/core.scss";
...
@@ -2,17 +2,24 @@ import "../../styles/core.scss";
import
{
UploadOutlined
}
from
"
@ant-design/icons
"
;
import
{
UploadOutlined
}
from
"
@ant-design/icons
"
;
import
{
Button
,
message
,
Modal
,
Upload
,
UploadProps
}
from
"
antd
"
;
import
{
Button
,
message
,
Modal
,
Upload
,
UploadProps
}
from
"
antd
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
use
Effect
,
use
State
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
rustInit
from
"
rust-src
"
;
import
rustInit
from
"
rust-src
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
initStrings
}
from
"
@/api
"
;
import
{
initStrings
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
{
matStore
}
from
"
@/stores
"
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
const
localStore
=
proxy
({
hasStart
:
false
,
});
const
ReplayModal
:
React
.
FC
=
()
=>
{
const
ReplayModal
:
React
.
FC
=
()
=>
{
const
{
hasStart
}
=
useSnapshot
(
localStore
);
const
[
replay
,
setReplay
]
=
useState
<
null
|
ArrayBuffer
>
(
null
);
const
[
replay
,
setReplay
]
=
useState
<
null
|
ArrayBuffer
>
(
null
);
const
uploadProps
:
UploadProps
=
{
const
uploadProps
:
UploadProps
=
{
name
:
"
replay
"
,
name
:
"
replay
"
,
...
@@ -29,6 +36,13 @@ const ReplayModal: React.FC = () => {
...
@@ -29,6 +36,13 @@ const ReplayModal: React.FC = () => {
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
useEffect
(()
=>
{
if
(
hasStart
)
{
// 跳转
navigate
(
`/duel/neos/replay/
${
NeosConfig
.
replayUrl
}
`
);
}
},
[
hasStart
]);
return
(
return
(
<
Modal
<
Modal
title=
"选择回放"
title=
"选择回放"
...
@@ -38,6 +52,9 @@ const ReplayModal: React.FC = () => {
...
@@ -38,6 +52,9 @@ const ReplayModal: React.FC = () => {
if
(
replay
===
null
)
{
if
(
replay
===
null
)
{
message
.
error
(
"
请先上传录像文件
"
);
message
.
error
(
"
请先上传录像文件
"
);
}
else
{
}
else
{
// 标记为回放模式
matStore
.
isReplay
=
true
;
// 初始化wasm
// 初始化wasm
const
url
=
const
url
=
import
.
meta
.
env
.
BASE_URL
===
"
/
"
import
.
meta
.
env
.
BASE_URL
===
"
/
"
...
@@ -70,9 +87,6 @@ const ReplayModal: React.FC = () => {
...
@@ -70,9 +87,6 @@ const ReplayModal: React.FC = () => {
// 初始化文案
// 初始化文案
await
initStrings
();
await
initStrings
();
// 跳转
navigate
(
`/duel/neos/replay/${NeosConfig.replayUrl}`
);
}
}
}
}
}
}
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
...
@@ -89,4 +103,8 @@ const ReplayModal: React.FC = () => {
...
@@ -89,4 +103,8 @@ const ReplayModal: React.FC = () => {
);
);
};
};
export
const
replayStart
=
()
=>
{
localStore
.
hasStart
=
true
;
};
export
default
ReplayModal
;
export
default
ReplayModal
;
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