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
love_飞影
Neos
Commits
d65485b1
Commit
d65485b1
authored
Jun 08, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: store
parent
91b5fbdc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
24 deletions
+21
-24
src/service/duel/start.ts
src/service/duel/start.ts
+2
-2
src/stores/index.ts
src/stores/index.ts
+7
-12
src/ui/Duel/PlayMat/Card/index.tsx
src/ui/Duel/PlayMat/Card/index.tsx
+1
-1
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+11
-9
No files found.
src/service/duel/start.ts
View file @
d65485b1
...
...
@@ -6,8 +6,8 @@ import { subscribeKey } from "valtio/utils";
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
cardStore
,
CardType
,
s
tore
}
from
"
@/stores
"
;
const
{
matStore
}
=
store
;
import
{
cardStore
,
CardType
,
matS
tore
}
from
"
@/stores
"
;
const
TOKEN_SIZE
=
13
;
// 每人场上最多就只可能有13个token
export
default
async
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
)
=>
{
...
...
src/stores/index.ts
View file @
d65485b1
...
...
@@ -7,7 +7,6 @@ export * from "./methods";
export
*
from
"
./moraStore
"
;
export
*
from
"
./placeStore
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
devtools
}
from
"
valtio/utils
"
;
import
{
cardStore
}
from
"
./cardStore
"
;
...
...
@@ -18,14 +17,10 @@ import { messageStore } from "./messageStore";
import
{
moraStore
}
from
"
./moraStore
"
;
import
{
placeStore
}
from
"
./placeStore
"
;
export
const
store
=
proxy
({
chatStore
,
joinStore
,
moraStore
,
matStore
,
// 决斗盘
messageStore
,
// 决斗的信息,包括模态框
cardStore
,
placeStore
,
});
devtools
(
store
,
{
name
:
"
valtio store
"
,
enabled
:
true
});
devtools
(
chatStore
,
{
name
:
"
chat store
"
,
enabled
:
true
});
devtools
(
joinStore
,
{
name
:
"
join store
"
,
enabled
:
true
});
devtools
(
moraStore
,
{
name
:
"
mora store
"
,
enabled
:
true
});
devtools
(
matStore
,
{
name
:
"
mat store
"
,
enabled
:
true
});
devtools
(
messageStore
,
{
name
:
"
message store
"
,
enabled
:
true
});
devtools
(
cardStore
,
{
name
:
"
card store
"
,
enabled
:
true
});
devtools
(
placeStore
,
{
name
:
"
place store
"
,
enabled
:
true
});
src/ui/Duel/PlayMat/Card/index.tsx
View file @
d65485b1
...
...
@@ -94,7 +94,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
useEffect
(()
=>
{
setHighlight
(
!!
snap
.
idleInteractivities
.
length
);
},
[
snap
.
idleInteractivities
]);
},
[
snap
.
idleInteractivities
.
length
]);
return
(
<
animated
.
div
...
...
src/ui/WaitRoom.tsx
View file @
d65485b1
...
...
@@ -30,7 +30,7 @@ import { DeckManager, fetchDeck, type IDeck } from "@/api/deck";
import
{
useConfig
}
from
"
@/config
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
{
s
tore
}
from
"
@/stores
"
;
import
{
chatStore
,
joinStore
,
matStore
,
moraS
tore
}
from
"
@/stores
"
;
const
NeosConfig
=
useConfig
();
...
...
@@ -42,8 +42,10 @@ const {
}
=
useConfig
();
const
WaitRoom
=
()
=>
{
const
state
=
store
;
const
snap
=
useSnapshot
(
state
);
const
snapJoin
=
useSnapshot
(
joinStore
);
const
snapChat
=
useSnapshot
(
chatStore
);
const
snapMat
=
useSnapshot
(
matStore
);
const
snapMora
=
useSnapshot
(
moraStore
);
const
params
=
useParams
<
{
player
?:
string
;
passWd
?:
string
;
...
...
@@ -89,12 +91,12 @@ const WaitRoom = () => {
const
[
api
,
contextHolder
]
=
notification
.
useNotification
();
const
joined
=
snap
.
joinStore
.
value
;
const
chat
=
snap
.
chatStore
.
message
;
const
isHost
=
snap
.
matStore
.
isHost
;
const
player0
=
snap
.
matStore
.
player
[
0
];
const
player1
=
snap
.
matStore
.
player
[
1
];
const
duelStart
=
snap
.
moraStore
.
duelStart
;
const
joined
=
snap
Join
.
value
;
const
chat
=
snap
Chat
.
message
;
const
isHost
=
snap
Mat
.
isHost
;
const
player0
=
snap
Mat
.
player
[
0
];
const
player1
=
snap
Mat
.
player
[
1
];
const
duelStart
=
snap
Mora
.
duelStart
;
// FIXME: 这些数据应该从`store`中获取
// 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