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
b5ea98a8
Commit
b5ea98a8
authored
Sep 02, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extract genCard
parent
ad0a228f
Pipeline
#23323
passed with stages
in 13 minutes and 5 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
18 deletions
+24
-18
src/service/duel/reloadField.ts
src/service/duel/reloadField.ts
+1
-3
src/service/duel/start.ts
src/service/duel/start.ts
+3
-14
src/service/duel/updateData.ts
src/service/duel/updateData.ts
+4
-1
src/service/utils/genCard.ts
src/service/utils/genCard.ts
+15
-0
src/service/utils/index.ts
src/service/utils/index.ts
+1
-0
No files found.
src/service/duel/reloadField.ts
View file @
b5ea98a8
import
{
ygopro
}
from
"
@/api
"
;
type
MsgReloadField
=
ygopro
.
StocGameMessage
.
MsgReloadField
;
export
default
(
_field
:
MsgReloadField
)
=>
{
// TODO: 断线重连比较复杂,先留着后面时实现
};
export
default
(
_field
:
MsgReloadField
)
=>
{};
src/service/duel/start.ts
View file @
b5ea98a8
import
{
flatten
}
from
"
lodash-es
"
;
import
{
v4
as
v4uuid
}
from
"
uuid
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
subscribeKey
}
from
"
valtio/utils
"
;
import
PlayerType
=
ygopro
.
StocGameMessage
.
MsgStart
.
PlayerType
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
cardStore
,
CardType
,
matStore
,
RoomStage
,
roomStore
,
...
...
@@ -16,6 +13,8 @@ import {
sideStore
,
}
from
"
@/stores
"
;
import
{
replayStart
}
from
"
@/ui/Match/ReplayModal
"
;
import
{
genCard
}
from
"
../utils
"
;
const
TOKEN_SIZE
=
13
;
// 每人场上最多就只可能有13个token
export
default
async
(
start
:
ygopro
.
StocGameMessage
.
MsgStart
)
=>
{
...
...
@@ -101,13 +100,3 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
// 否则在和AI对战时,由于后端给传给前端的`MSG`频率太高,会导致一些问题。
await
sleep
(
useConfig
().
startDelay
);
};
// 自动从code推断出occupant
const
genCard
=
(
o
:
CardType
)
=>
{
const
t
=
proxy
(
o
);
subscribeKey
(
t
,
"
code
"
,
async
(
code
)
=>
{
const
meta
=
fetchCard
(
code
??
0
);
t
.
meta
=
meta
;
});
return
t
;
};
src/service/duel/updateData.ts
View file @
b5ea98a8
...
...
@@ -17,7 +17,10 @@ export default async (updateData: MsgUpdateData) => {
// 目前只更新以下字段
if
(
action
?.
code
>=
0
)
{
const
newMeta
=
fetchCard
(
action
.
code
);
if
(
target
.
code
!==
action
.
code
)
{
// 这个if判断一定要有,不然会触发`genCard`里面的事件
target
.
code
=
action
.
code
;
}
target
.
meta
=
newMeta
;
}
...
...
src/service/utils/genCard.ts
0 → 100644
View file @
b5ea98a8
import
{
proxy
}
from
"
valtio
"
;
import
{
subscribeKey
}
from
"
valtio/utils
"
;
import
{
fetchCard
}
from
"
@/api
"
;
import
{
CardType
}
from
"
@/stores
"
;
// 自动从code推断出meta
export
const
genCard
=
(
card
:
CardType
)
=>
{
const
t
=
proxy
(
card
);
subscribeKey
(
t
,
"
code
"
,
(
code
)
=>
{
const
meta
=
fetchCard
(
code
);
t
.
meta
=
meta
;
});
return
t
;
};
src/service/utils/index.ts
View file @
b5ea98a8
export
*
from
"
./fetchCheckCardMeta
"
;
export
*
from
"
./genCard
"
;
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