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
0c0079b6
Commit
0c0079b6
authored
Aug 20, 2023
by
timel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev/callalily' into 'main'
fetchCard/searchCard改为同步 See merge request
!277
parents
270df721
19073671
Pipeline
#23227
passed with stages
in 10 minutes and 10 seconds
Changes
20
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
57 additions
and
37 deletions
+57
-37
src/api/cards.ts
src/api/cards.ts
+4
-4
src/api/strings.ts
src/api/strings.ts
+1
-1
src/middleware/sqlite/index.ts
src/middleware/sqlite/index.ts
+14
-10
src/service/duel/announce.ts
src/service/duel/announce.ts
+1
-1
src/service/duel/chaining.ts
src/service/duel/chaining.ts
+1
-1
src/service/duel/confirmCards.ts
src/service/duel/confirmCards.ts
+1
-1
src/service/duel/draw.ts
src/service/duel/draw.ts
+1
-1
src/service/duel/move.ts
src/service/duel/move.ts
+1
-1
src/service/duel/selectEffectYn.ts
src/service/duel/selectEffectYn.ts
+1
-1
src/service/duel/selectOption.ts
src/service/duel/selectOption.ts
+1
-1
src/service/duel/sortCard.ts
src/service/duel/sortCard.ts
+1
-1
src/service/duel/start.ts
src/service/duel/start.ts
+1
-1
src/service/duel/updateData.ts
src/service/duel/updateData.ts
+1
-1
src/service/room/errorMsg.ts
src/service/room/errorMsg.ts
+1
-1
src/service/utils/fetchCheckCardMeta.ts
src/service/utils/fetchCheckCardMeta.ts
+1
-1
src/stores/matStore/methods/fetchHint.ts
src/stores/matStore/methods/fetchHint.ts
+2
-2
src/ui/BuildDeck/CardDetail.tsx
src/ui/BuildDeck/CardDetail.tsx
+1
-1
src/ui/BuildDeck/index.tsx
src/ui/BuildDeck/index.tsx
+2
-2
src/ui/WaitRoom/index.module.scss
src/ui/WaitRoom/index.module.scss
+7
-1
src/ui/WaitRoom/index.tsx
src/ui/WaitRoom/index.tsx
+14
-4
No files found.
src/api/cards.ts
View file @
0c0079b6
...
...
@@ -50,8 +50,8 @@ export interface CardText {
* @returns 卡片数据
*
* */
export
async
function
fetchCard
(
id
:
number
):
Promise
<
CardMeta
>
{
const
res
=
await
sqliteMiddleWare
({
export
function
fetchCard
(
id
:
number
):
CardMeta
{
const
res
=
sqliteMiddleWare
({
cmd
:
sqliteCmd
.
SELECT
,
payload
:
{
id
},
});
...
...
@@ -65,8 +65,8 @@ export async function fetchCard(id: number): Promise<CardMeta> {
* @returns 卡片数据
*
* */
export
async
function
searchCards
(
params
:
FtsParams
):
Promise
<
CardMeta
[]
>
{
const
res
=
await
sqliteMiddleWare
({
export
function
searchCards
(
params
:
FtsParams
):
CardMeta
[]
{
const
res
=
sqliteMiddleWare
({
cmd
:
sqliteCmd
.
FTS
,
payload
:
{
ftsParams
:
params
},
});
...
...
src/api/strings.ts
View file @
0c0079b6
...
...
@@ -36,6 +36,6 @@ export async function getStrings(description: number): Promise<string> {
const
code
=
description
>>
4
;
const
index
=
description
&
0xf
;
return
getCardStr
(
await
fetchCard
(
code
),
index
)
||
""
;
return
getCardStr
(
fetchCard
(
code
),
index
)
||
""
;
}
}
src/middleware/sqlite/index.ts
View file @
0c0079b6
...
...
@@ -24,8 +24,8 @@ export enum sqliteCmd {
FTS
,
}
export
interface
sqliteAction
{
cmd
:
sqliteCmd
;
export
interface
sqliteAction
<
T
extends
sqliteCmd
>
{
cmd
:
T
;
// 初始化DB需要业务方传入的数据
initInfo
?:
{
dbUrl
:
string
;
...
...
@@ -47,8 +47,14 @@ const sqlPromise = initSqlJs({
locateFile
:
(
file
)
=>
`
${
NeosConfig
.
assetsPath
}
/
${
file
}
`
,
});
export
default
function
<
T
extends
sqliteCmd
>
(
action
:
sqliteAction
<
T
>
,
):
T
extends
sqliteCmd
.
INIT
?
Promise
<
void
>
:
sqliteResult
{
return
helper
(
action
)
as
any
;
}
// FIXME: 应该有个返回值,告诉业务方本次请求的结果,比如初始化DB失败
export
default
async
function
(
action
:
sqliteAction
):
Promise
<
sqliteResult
>
{
function
helper
<
T
extends
sqliteCmd
>
(
action
:
sqliteAction
<
T
>
)
{
switch
(
action
.
cmd
)
{
case
sqliteCmd
.
INIT
:
{
const
info
=
action
.
initInfo
;
...
...
@@ -56,16 +62,14 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
const
dataPromise
=
pfetch
(
info
.
dbUrl
,
{
progressCallback
:
action
.
initInfo
?.
progressCallback
,
}).
then
((
res
)
=>
res
.
arrayBuffer
());
// TODO: i18n
const
[
SQL
,
buffer
]
=
await
Promise
.
all
([
sqlPromise
,
dataPromise
]);
YGODB
=
new
SQL
.
Database
(
new
Uint8Array
(
buffer
));
console
.
info
(
"
YGODB inited!
"
);
return
Promise
.
all
([
sqlPromise
,
dataPromise
]).
then
(([
SQL
,
buffer
])
=>
{
YGODB
=
new
SQL
.
Database
(
new
Uint8Array
(
buffer
));
console
.
log
(
"
YGODB inited!
"
);
});
}
else
{
console
.
warn
(
"
init YGODB action without initInfo
"
);
return
{};
}
return
{};
}
case
sqliteCmd
.
SELECT
:
{
if
(
YGODB
&&
action
.
payload
&&
action
.
payload
.
id
)
{
...
...
src/service/duel/announce.ts
View file @
0c0079b6
...
...
@@ -40,7 +40,7 @@ export default async (announce: MsgAnnounce) => {
case
MsgAnnounce
.
AnnounceType
.
Card
:
{
const
options
=
[];
for
(
const
option
of
announce
.
options
)
{
const
meta
=
await
fetchCard
(
option
.
code
);
const
meta
=
fetchCard
(
option
.
code
);
if
(
meta
.
text
.
name
)
{
options
.
push
({
info
:
meta
.
text
.
name
,
...
...
src/service/duel/chaining.ts
View file @
0c0079b6
...
...
@@ -18,7 +18,7 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
// 设置连锁序号
target
.
chainIndex
=
matStore
.
chains
.
length
;
const
meta
=
await
fetchCard
(
chaining
.
code
);
const
meta
=
fetchCard
(
chaining
.
code
);
// 这里不能设置`code`,因为存在一个场景:
// 对方的`魔神仪-曼德拉护肤草`发动效果后,后端会发一次`MSG_SHUFFLE_HAND`,但传给前端的codes全是0,如果这里设置了`code`的话,在后面的`MSG_SHUFFLE_HAND`处理就会有问题。
// target.code = meta.id;
...
...
src/service/duel/confirmCards.ts
View file @
0c0079b6
...
...
@@ -11,7 +11,7 @@ export default async (confirmCards: ygopro.StocGameMessage.MsgConfirmCards) => {
if
(
target
)
{
// 设置`occupant`
const
meta
=
await
fetchCard
(
card
.
code
);
const
meta
=
fetchCard
(
card
.
code
);
target
.
meta
=
meta
;
// 动画
await
callCardFocus
(
target
.
uuid
);
...
...
src/service/duel/draw.ts
View file @
0c0079b6
...
...
@@ -17,7 +17,7 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
for
(
const
idx
in
newHands
)
{
const
card
=
newHands
[
Number
(
idx
)];
const
code
=
draw
.
cards
[
idx
];
const
meta
=
await
fetchCard
(
code
);
const
meta
=
fetchCard
(
code
);
card
.
code
=
code
;
card
.
meta
=
meta
;
card
.
location
.
zone
=
ygopro
.
CardZone
.
HAND
;
...
...
src/service/duel/move.ts
View file @
0c0079b6
...
...
@@ -34,7 +34,7 @@ export default async (move: MsgMove) => {
const
to
=
move
.
to
;
const
reason
=
move
.
reason
;
const
meta
=
await
fetchCard
(
code
);
const
meta
=
fetchCard
(
code
);
if
(
meta
.
data
.
type
!==
undefined
&&
(
meta
.
data
.
type
&
TYPE_TOKEN
)
>
0
)
{
// 衍生物
if
(
from
.
zone
===
DECK
)
{
...
...
src/service/duel/selectEffectYn.ts
View file @
0c0079b6
...
...
@@ -32,6 +32,6 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
// TODO: 国际化文案
const
desc
=
fetchStrings
(
Region
.
System
,
effect_description
);
const
meta
=
await
fetchCard
(
code
);
const
meta
=
fetchCard
(
code
);
await
displayYesNoModal
(
textGenerator
(
desc
,
meta
,
location
));
};
src/service/duel/selectOption.ts
View file @
0c0079b6
...
...
@@ -13,7 +13,7 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
fetchStrings
(
Region
.
System
,
556
),
await
Promise
.
all
(
options
.
map
(
async
({
code
,
response
})
=>
{
const
meta
=
await
fetchCard
(
code
>>
4
);
const
meta
=
fetchCard
(
code
>>
4
);
const
msg
=
getCardStr
(
meta
,
code
&
0xf
)
||
"
[?]
"
;
return
{
msg
,
response
};
}),
...
...
src/service/duel/sortCard.ts
View file @
0c0079b6
...
...
@@ -6,7 +6,7 @@ type MsgSortCard = ygopro.StocGameMessage.MsgSortCard;
export
default
async
(
sortCard
:
MsgSortCard
)
=>
{
const
options
=
await
Promise
.
all
(
sortCard
.
options
.
map
(
async
({
code
,
response
})
=>
{
const
meta
=
await
fetchCard
(
code
!
);
const
meta
=
fetchCard
(
code
!
);
return
{
meta
,
response
:
response
!
,
...
...
src/service/duel/start.ts
View file @
0c0079b6
...
...
@@ -106,7 +106,7 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
const
genCard
=
(
o
:
CardType
)
=>
{
const
t
=
proxy
(
o
);
subscribeKey
(
t
,
"
code
"
,
async
(
code
)
=>
{
const
meta
=
await
fetchCard
(
code
??
0
);
const
meta
=
fetchCard
(
code
??
0
);
t
.
meta
=
meta
;
});
return
t
;
...
...
src/service/duel/updateData.ts
View file @
0c0079b6
...
...
@@ -16,7 +16,7 @@ export default async (updateData: MsgUpdateData) => {
if
(
target
)
{
// 目前只更新以下字段
if
(
action
?.
code
>=
0
)
{
const
newMeta
=
await
fetchCard
(
action
.
code
);
const
newMeta
=
fetchCard
(
action
.
code
);
target
.
code
=
action
.
code
;
target
.
meta
=
newMeta
;
}
...
...
src/service/room/errorMsg.ts
View file @
0c0079b6
...
...
@@ -24,7 +24,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
case
ErrorType
.
DECKERROR
:
{
const
flag
=
error_code
>>
28
;
const
code
=
error_code
&&
0xfffffff
;
const
card
=
await
fetchCard
(
code
);
const
card
=
fetchCard
(
code
);
const
baseMsg
=
`卡组非法,请检查:
${
card
.
text
.
name
}
`
;
switch
(
flag
)
{
case
DECKERROR_LFLIST
:
{
...
...
src/service/utils/fetchCheckCardMeta.ts
View file @
0c0079b6
...
...
@@ -30,7 +30,7 @@ const helper = async (
code
!==
0
?
code
:
cardStore
.
at
(
location
.
zone
,
controller
,
location
.
sequence
)?.
code
||
0
;
const
meta
=
await
fetchCard
(
newID
);
const
meta
=
fetchCard
(
newID
);
const
effectDesc
=
effect_description
?
getCardStr
(
meta
,
effect_description
&
0xf
)
...
...
src/stores/matStore/methods/fetchHint.ts
View file @
0c0079b6
...
...
@@ -22,7 +22,7 @@ export const fetchSelectHintMeta = async ({
let
selectHintMeta
=
""
;
if
(
selectHintData
>
DESCRIPTION_LIMIT
)
{
// 针对`MSG_SELECT_PLACE`的特化逻辑
const
cardMeta
=
await
fetchCard
(
selectHintData
);
const
cardMeta
=
fetchCard
(
selectHintData
);
selectHintMeta
=
fetchStrings
(
Region
.
System
,
569
).
replace
(
"
[%ls]
"
,
cardMeta
.
text
.
name
||
"
[?]
"
,
...
...
@@ -55,7 +55,7 @@ export const fetchEsHintMeta = async ({
?
originMsg
:
fetchStrings
(
Region
.
System
,
originMsg
);
const
cardMeta
=
cardID
?
await
fetchCard
(
cardID
)
:
undefined
;
const
cardMeta
=
cardID
?
fetchCard
(
cardID
)
:
undefined
;
let
esHint
=
newOriginMsg
;
...
...
src/ui/BuildDeck/CardDetail.tsx
View file @
0c0079b6
...
...
@@ -23,7 +23,7 @@ export const CardDetail: React.FC<{
}
>
=
({
code
,
open
,
onClose
})
=>
{
const
[
card
,
setCard
]
=
useState
<
CardMeta
>
();
useEffect
(()
=>
{
fetchCard
(
code
).
then
(
setCard
);
setCard
(
fetchCard
(
code
)
);
},
[
code
]);
const
cardType
=
useMemo
(
()
=>
...
...
src/ui/BuildDeck/index.tsx
View file @
0c0079b6
...
...
@@ -262,8 +262,8 @@ const Search: React.FC = () => {
]
as
const
).
map
(([
label
,
onClick
],
key
)
=>
({
key
,
label
,
onClick
}));
const
handleSearch
=
async
(
conditions
:
FtsConditions
=
searchConditions
)
=>
{
const
result
=
(
await
searchCards
({
query
:
searchWord
,
conditions
})
)
const
handleSearch
=
(
conditions
:
FtsConditions
=
searchConditions
)
=>
{
const
result
=
searchCards
({
query
:
searchWord
,
conditions
}
)
.
filter
((
card
)
=>
!
isToken
(
card
.
data
.
type
??
0
))
.
sort
(
sortRef
.
current
);
// 衍生物不显示
setSearchResult
(()
=>
result
);
...
...
src/ui/WaitRoom/index.module.scss
View file @
0c0079b6
...
...
@@ -54,9 +54,15 @@
.inner
{
position
:
absolute
;
left
:
0
;
width
:
150px
;
height
:
70px
;
filter
:
blur
(
120px
);
transition
:
0
.3s
;
}
&
.ready
.inner
{
width
:
250px
;
height
:
100px
;
filter
:
blur
(
1
20px
);
filter
:
blur
(
1
00px
)
brightness
(
1
.2
)
saturate
(
1
.2
);
}
&
.me
{
box-shadow
:
-5px
0
20px
0
rgba
(
0
,
115
,
255
,
0
.15
);
...
...
src/ui/WaitRoom/index.tsx
View file @
0c0079b6
...
...
@@ -99,6 +99,7 @@ export const Component: React.FC = () => {
who=
{
Who
.
Me
}
player=
{
me
}
avatar=
{
user
?.
avatar_url
}
ready=
{
me
?.
state
===
PlayerState
.
READY
}
btn=
{
room
.
stage
===
RoomStage
.
WAITING
?
(
<
Button
...
...
@@ -144,6 +145,7 @@ export const Component: React.FC = () => {
key=
{
idx
}
who=
{
Who
.
Op
}
player=
{
player
}
ready=
{
op
?.
state
===
PlayerState
.
READY
}
btn=
{
room
.
stage
===
RoomStage
.
WAITING
?
null
:
(
<
MoraAvatar
...
...
@@ -183,12 +185,17 @@ enum Who {
// 玩家区域: 双方各有一个
const
PlayerZone
:
React
.
FC
<
{
btn
?:
React
.
ReactNode
;
// 在内部右侧可以放一个按钮
who
?
:
Who
;
who
:
Who
;
player
?:
Player
;
avatar
?:
string
;
// 因为对手的头像目前不清楚如何获取,因此暂时这里作为一个参数传入
}
>
=
({
btn
,
who
,
player
,
avatar
})
=>
{
ready
:
boolean
;
}
>
=
({
btn
,
who
,
player
,
avatar
,
ready
})
=>
{
return
(
<
div
className=
{
classNames
(
styles
[
"
side-box
"
],
who
&&
styles
[
who
])
}
>
<
div
className=
{
classNames
(
styles
[
"
side-box
"
],
styles
[
who
],
{
[
styles
.
ready
]:
ready
,
})
}
>
<
div
className=
{
styles
.
inner
}
></
div
>
<
div
style=
{
{
position
:
"
relative
"
}
}
>
<
Avatar
...
...
@@ -364,7 +371,10 @@ const ActionButton: React.FC<{
<
span
>
等待游戏开始
</
span
>
</>
)
:
(
<></>
<>
<
LoadingOutlined
/>
<
span
>
等待游戏开始
</
span
>
</>
)
}
</
SpecialButton
>
</
TpPopover
>
...
...
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