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
6f35edc4
Commit
6f35edc4
authored
May 07, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/store/modal' into 'main'
Optimize/store/modal See merge request
!179
parents
3803129a
1f953299
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
440 additions
and
1137 deletions
+440
-1137
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+97
-279
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/mod.ts
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/mod.ts
+6
-14
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/selectMulti.ts
...cgcore/ocgAdapter/ctos/ctosGameMsgResponse/selectMulti.ts
+1
-1
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/selectSingle.ts
...gcore/ocgAdapter/ctos/ctosGameMsgResponse/selectSingle.ts
+1
-1
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/selectUnselectCard.ts
...ocgAdapter/ctos/ctosGameMsgResponse/selectUnselectCard.ts
+0
-17
src/api/ocgcore/ocgHelper.ts
src/api/ocgcore/ocgHelper.ts
+4
-22
src/service/duel/selectCard.ts
src/service/duel/selectCard.ts
+7
-9
src/service/duel/selectChain.ts
src/service/duel/selectChain.ts
+9
-11
src/service/duel/selectEffectYn.ts
src/service/duel/selectEffectYn.ts
+3
-11
src/service/duel/selectSum.ts
src/service/duel/selectSum.ts
+12
-14
src/service/duel/selectTribute.ts
src/service/duel/selectTribute.ts
+9
-18
src/service/duel/selectUnselectCard.ts
src/service/duel/selectUnselectCard.ts
+13
-28
src/stores/matStore/methods/cardZoneToChinese.ts
src/stores/matStore/methods/cardZoneToChinese.ts
+0
-42
src/stores/matStore/methods/fetchCheckCardMeta.ts
src/stores/matStore/methods/fetchCheckCardMeta.ts
+22
-74
src/stores/matStore/methods/index.ts
src/stores/matStore/methods/index.ts
+0
-1
src/stores/messageStore/methods/clearSelectActions.ts
src/stores/messageStore/methods/clearSelectActions.ts
+18
-0
src/stores/messageStore/methods/fetchCheckCardMetasV2.ts
src/stores/messageStore/methods/fetchCheckCardMetasV2.ts
+0
-44
src/stores/messageStore/methods/fetchCheckCardMetasV3.ts
src/stores/messageStore/methods/fetchCheckCardMetasV3.ts
+0
-49
src/stores/messageStore/methods/index.ts
src/stores/messageStore/methods/index.ts
+1
-2
src/stores/messageStore/store.ts
src/stores/messageStore/store.ts
+7
-15
src/stores/messageStore/types.ts
src/stores/messageStore/types.ts
+31
-58
src/ui/Duel/Main.tsx
src/ui/Duel/Main.tsx
+2
-6
src/ui/Duel/Message/CheckCardModal.tsx
src/ui/Duel/Message/CheckCardModal.tsx
+0
-168
src/ui/Duel/Message/CheckCardModalV2.tsx
src/ui/Duel/Message/CheckCardModalV2.tsx
+0
-125
src/ui/Duel/Message/CheckCardModalV3.tsx
src/ui/Duel/Message/CheckCardModalV3.tsx
+0
-124
src/ui/Duel/Message/SelectActionsModal.tsx
src/ui/Duel/Message/SelectActionsModal.tsx
+195
-0
src/ui/Duel/Message/index.ts
src/ui/Duel/Message/index.ts
+1
-3
No files found.
neos-protobuf
@
be66d514
Subproject commit
1648b05d2e0bf0fc84c9e98104b8d9ca6a014c1
a
Subproject commit
be66d514be6d1224163f55bca85dc361d0c9fe6
a
src/api/ocgcore/idl/ocgcore.ts
View file @
6f35edc4
This diff is collapsed.
Click to expand it.
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/mod.ts
View file @
6f35edc4
...
@@ -2,15 +2,14 @@ import { ygopro } from "../../../idl/ocgcore";
...
@@ -2,15 +2,14 @@ import { ygopro } from "../../../idl/ocgcore";
import
{
YgoProPacket
}
from
"
../../packet
"
;
import
{
YgoProPacket
}
from
"
../../packet
"
;
import
{
CTOS_RESPONSE
}
from
"
../../protoDecl
"
;
import
{
CTOS_RESPONSE
}
from
"
../../protoDecl
"
;
import
adaptSelectBattleCmdResponse
from
"
./selectBattleCmd
"
;
import
adaptSelectBattleCmdResponse
from
"
./selectBattleCmd
"
;
import
adaptSelectCardResponse
from
"
./selectCard
"
;
import
adaptSelectChainResponse
from
"
./selectChain
"
;
import
adaptSelectCounterResponse
from
"
./selectCounter
"
;
import
adaptSelectCounterResponse
from
"
./selectCounter
"
;
import
adaptSelectEffectYnResponse
from
"
./selectEffectYn
"
;
import
adaptSelectEffectYnResponse
from
"
./selectEffectYn
"
;
import
adaptSelectIdleCmdResponse
from
"
./selectIdleCmd
"
;
import
adaptSelectIdleCmdResponse
from
"
./selectIdleCmd
"
;
import
adaptSelectMultiResponse
from
"
./selectMulti
"
;
import
adaptSelectOptionResponse
from
"
./selectOption
"
;
import
adaptSelectOptionResponse
from
"
./selectOption
"
;
import
adaptSelectPlaceResponse
from
"
./selectPlace
"
;
import
adaptSelectPlaceResponse
from
"
./selectPlace
"
;
import
adaptSelectPositionResponse
from
"
./selectPosition
"
;
import
adaptSelectPositionResponse
from
"
./selectPosition
"
;
import
adaptSelect
UnselectCardResponse
from
"
./selectUnselectCard
"
;
import
adaptSelect
SingleResponse
from
"
./selectSingle
"
;
import
adaptSortCardResponse
from
"
./sortCard
"
;
import
adaptSortCardResponse
from
"
./sortCard
"
;
/*
/*
...
@@ -37,13 +36,13 @@ export default class CtosResponsePacket extends YgoProPacket {
...
@@ -37,13 +36,13 @@ export default class CtosResponsePacket extends YgoProPacket {
break
;
break
;
}
}
case
"
select_
card
"
:
{
case
"
select_
multi
"
:
{
extraData
=
adaptSelect
CardResponse
(
response
.
select_card
);
extraData
=
adaptSelect
MultiResponse
(
response
.
select_multi
);
break
;
break
;
}
}
case
"
select_
chain
"
:
{
case
"
select_
single
"
:
{
extraData
=
adaptSelect
ChainResponse
(
response
.
select_chain
);
extraData
=
adaptSelect
SingleResponse
(
response
.
select_single
);
break
;
break
;
}
}
...
@@ -67,13 +66,6 @@ export default class CtosResponsePacket extends YgoProPacket {
...
@@ -67,13 +66,6 @@ export default class CtosResponsePacket extends YgoProPacket {
break
;
break
;
}
}
case
"
select_unselect_card
"
:
{
extraData
=
adaptSelectUnselectCardResponse
(
response
.
select_unselect_card
);
break
;
}
case
"
select_counter_response
"
:
{
case
"
select_counter_response
"
:
{
extraData
=
adaptSelectCounterResponse
(
extraData
=
adaptSelectCounterResponse
(
response
.
select_counter_response
response
.
select_counter_response
...
...
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/select
Card
.ts
→
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/select
Multi
.ts
View file @
6f35edc4
...
@@ -2,7 +2,7 @@ import { BufferWriter } from "rust-src";
...
@@ -2,7 +2,7 @@ import { BufferWriter } from "rust-src";
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
export
default
(
response
:
ygopro
.
CtosGameMsgResponse
.
Select
Card
Response
)
=>
{
export
default
(
response
:
ygopro
.
CtosGameMsgResponse
.
Select
Multi
Response
)
=>
{
const
writer
=
new
BufferWriter
();
const
writer
=
new
BufferWriter
();
writer
.
writeUint8
(
response
.
selected_ptrs
.
length
);
writer
.
writeUint8
(
response
.
selected_ptrs
.
length
);
...
...
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/select
Chain
.ts
→
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/select
Single
.ts
View file @
6f35edc4
...
@@ -2,7 +2,7 @@ import { BufferWriter } from "rust-src";
...
@@ -2,7 +2,7 @@ import { BufferWriter } from "rust-src";
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
export
default
(
response
:
ygopro
.
CtosGameMsgResponse
.
Select
Chain
Response
)
=>
{
export
default
(
response
:
ygopro
.
CtosGameMsgResponse
.
Select
Single
Response
)
=>
{
const
writer
=
new
BufferWriter
();
const
writer
=
new
BufferWriter
();
writer
.
writeInt32
(
response
.
selected_ptr
);
writer
.
writeInt32
(
response
.
selected_ptr
);
...
...
src/api/ocgcore/ocgAdapter/ctos/ctosGameMsgResponse/selectUnselectCard.ts
deleted
100644 → 0
View file @
3803129a
import
{
BufferWriter
}
from
"
rust-src
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
export
default
(
response
:
ygopro
.
CtosGameMsgResponse
.
SelectUnselectCardResponse
)
=>
{
const
writer
=
new
BufferWriter
();
if
(
response
.
cancel_or_finish
)
{
writer
.
writeInt32
(
-
1
);
}
else
{
writer
.
writeUint8
(
1
);
writer
.
writeUint8
(
response
.
selected_ptr
);
}
return
writer
.
toArray
();
};
src/api/ocgcore/ocgHelper.ts
View file @
6f35edc4
...
@@ -172,10 +172,10 @@ export function sendSelectPlaceResponse(value: {
...
@@ -172,10 +172,10 @@ export function sendSelectPlaceResponse(value: {
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
}
export
function
sendSelect
Card
Response
(
value
:
number
[])
{
export
function
sendSelect
Multi
Response
(
value
:
number
[])
{
const
response
=
new
ygopro
.
YgoCtosMsg
({
const
response
=
new
ygopro
.
YgoCtosMsg
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
select_
card
:
new
ygopro
.
CtosGameMsgResponse
.
SelectCard
Response
({
select_
multi
:
new
ygopro
.
CtosGameMsgResponse
.
SelectMulti
Response
({
selected_ptrs
:
value
,
selected_ptrs
:
value
,
}),
}),
}),
}),
...
@@ -185,10 +185,10 @@ export function sendSelectCardResponse(value: number[]) {
...
@@ -185,10 +185,10 @@ export function sendSelectCardResponse(value: number[]) {
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
}
export
function
sendSelect
Chain
Response
(
value
:
number
)
{
export
function
sendSelect
Single
Response
(
value
:
number
)
{
const
response
=
new
ygopro
.
YgoCtosMsg
({
const
response
=
new
ygopro
.
YgoCtosMsg
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
select_
chain
:
new
ygopro
.
CtosGameMsgResponse
.
SelectChain
Response
({
select_
single
:
new
ygopro
.
CtosGameMsgResponse
.
SelectSingle
Response
({
selected_ptr
:
value
,
selected_ptr
:
value
,
}),
}),
}),
}),
...
@@ -252,24 +252,6 @@ export function sendSelectBattleCmdResponse(value: number) {
...
@@ -252,24 +252,6 @@ export function sendSelectBattleCmdResponse(value: number) {
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
}
export
function
sendSelectUnselectCardResponse
(
value
:
{
cancel_or_finish
?:
boolean
;
selected_ptr
?:
number
;
})
{
const
response
=
new
ygopro
.
YgoCtosMsg
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
select_unselect_card
:
new
ygopro
.
CtosGameMsgResponse
.
SelectUnselectCardResponse
({
selected_ptr
:
value
.
selected_ptr
,
cancel_or_finish
:
value
.
cancel_or_finish
,
}),
}),
});
const
payload
=
new
GameMsgResponse
(
response
).
serialize
();
socketMiddleWare
({
cmd
:
socketCmd
.
SEND
,
payload
});
}
export
function
sendSelectCounterResponse
(
counts
:
number
[])
{
export
function
sendSelectCounterResponse
(
counts
:
number
[])
{
const
response
=
new
ygopro
.
YgoCtosMsg
({
const
response
=
new
ygopro
.
YgoCtosMsg
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
ctos_response
:
new
ygopro
.
CtosGameMsgResponse
({
...
...
src/service/duel/selectCard.ts
View file @
6f35edc4
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
{
CardZoneToChinese
,
fetchCheckCardMeta
,
messageStore
}
from
"
@/stores
"
;
import
{
fetchCheckCardMeta
,
messageStore
}
from
"
@/stores
"
;
export
default
(
selectCard
:
MsgSelectCard
)
=>
{
export
default
(
selectCard
:
MsgSelectCard
)
=>
{
const
_player
=
selectCard
.
player
;
const
cancelable
=
selectCard
.
cancelable
;
const
_cancelable
=
selectCard
.
cancelable
;
// TODO: 处理可取消逻辑
const
min
=
selectCard
.
min
;
const
min
=
selectCard
.
min
;
const
max
=
selectCard
.
max
;
const
max
=
selectCard
.
max
;
const
cards
=
selectCard
.
cards
;
const
cards
=
selectCard
.
cards
;
// TODO: handle release_param
// TODO: handle release_param
messageStore
.
checkCardModal
.
selectM
in
=
min
;
messageStore
.
selectCardActions
.
m
in
=
min
;
messageStore
.
checkCardModal
.
selectM
ax
=
max
;
messageStore
.
selectCardActions
.
m
ax
=
max
;
messageStore
.
checkCardModal
.
onSubmit
=
"
sendSelectCardResponse
"
;
messageStore
.
selectCardActions
.
cancelAble
=
cancelable
;
for
(
const
card
of
cards
)
{
for
(
const
card
of
cards
)
{
const
tagName
=
CardZoneToChinese
(
card
.
location
.
location
);
fetchCheckCardMeta
({
fetchCheckCardMeta
(
card
.
location
.
location
,
{
code
:
card
.
code
,
code
:
card
.
code
,
location
:
card
.
location
,
location
:
card
.
location
,
response
:
card
.
response
,
response
:
card
.
response
,
});
});
}
}
messageStore
.
checkCardModal
.
isOpen
=
true
;
messageStore
.
selectCardActions
.
isOpen
=
true
;
};
};
src/service/duel/selectChain.ts
View file @
6f35edc4
import
{
sendSelect
Chain
Response
,
ygopro
}
from
"
@/api
"
;
import
{
sendSelect
Single
Response
,
ygopro
}
from
"
@/api
"
;
import
{
import
{
fetchCheckCardMeta
,
fetchCheckCardMeta
,
fetchSelectHintMeta
,
fetchSelectHintMeta
,
...
@@ -7,7 +7,6 @@ import {
...
@@ -7,7 +7,6 @@ import {
type
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
type
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
export
default
(
selectChain
:
MsgSelectChain
)
=>
{
export
default
(
selectChain
:
MsgSelectChain
)
=>
{
const
player
=
selectChain
.
player
;
const
spCount
=
selectChain
.
special_count
;
const
spCount
=
selectChain
.
special_count
;
const
forced
=
selectChain
.
forced
;
const
forced
=
selectChain
.
forced
;
const
hint0
=
selectChain
.
hint0
;
const
hint0
=
selectChain
.
hint0
;
...
@@ -50,7 +49,7 @@ export default (selectChain: MsgSelectChain) => {
...
@@ -50,7 +49,7 @@ export default (selectChain: MsgSelectChain) => {
switch
(
handle_flag
)
{
switch
(
handle_flag
)
{
case
0
:
{
case
0
:
{
// 直接回答
// 直接回答
sendSelect
Chain
Response
(
-
1
);
sendSelect
Single
Response
(
-
1
);
break
;
break
;
}
}
...
@@ -58,14 +57,13 @@ export default (selectChain: MsgSelectChain) => {
...
@@ -58,14 +57,13 @@ export default (selectChain: MsgSelectChain) => {
case
3
:
{
case
3
:
{
// 处理强制发动的卡
// 处理强制发动的卡
messageStore
.
checkCardModal
.
selectMin
=
1
;
messageStore
.
selectCardActions
.
isChain
=
true
;
messageStore
.
checkCardModal
.
selectMax
=
1
;
messageStore
.
selectCardActions
.
min
=
1
;
messageStore
.
checkCardModal
.
onSubmit
=
"
sendSelectChainResponse
"
;
messageStore
.
selectCardActions
.
max
=
1
;
messageStore
.
checkCardModal
.
cancelAble
=
!
forced
;
messageStore
.
selectCardActions
.
cancelAble
=
!
forced
;
messageStore
.
checkCardModal
.
cancelResponse
=
-
1
;
for
(
const
chain
of
chains
)
{
for
(
const
chain
of
chains
)
{
fetchCheckCardMeta
(
chain
.
location
.
location
,
{
fetchCheckCardMeta
({
code
:
chain
.
code
,
code
:
chain
.
code
,
location
:
chain
.
location
,
location
:
chain
.
location
,
response
:
chain
.
response
,
response
:
chain
.
response
,
...
@@ -75,13 +73,13 @@ export default (selectChain: MsgSelectChain) => {
...
@@ -75,13 +73,13 @@ export default (selectChain: MsgSelectChain) => {
fetchSelectHintMeta
({
fetchSelectHintMeta
({
selectHintData
:
203
,
selectHintData
:
203
,
});
});
messageStore
.
checkCardModal
.
isOpen
=
true
;
messageStore
.
selectCardActions
.
isOpen
=
true
;
break
;
break
;
}
}
case
4
:
{
case
4
:
{
// 有一张强制发动的卡,直接回应
// 有一张强制发动的卡,直接回应
sendSelect
Chain
Response
(
chains
[
0
].
response
);
sendSelect
Single
Response
(
chains
[
0
].
response
);
break
;
break
;
}
}
...
...
src/service/duel/selectEffectYn.ts
View file @
6f35edc4
import
{
fetchStrings
,
ygopro
}
from
"
@/api
"
;
import
{
fetchStrings
,
ygopro
}
from
"
@/api
"
;
import
{
CardMeta
,
fetchCard
}
from
"
@/api/cards
"
;
import
{
CardMeta
,
fetchCard
}
from
"
@/api/cards
"
;
import
{
CardZoneToChinese
,
messageStore
}
from
"
@/stores
"
;
import
{
messageStore
}
from
"
@/stores
"
;
type
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
type
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
// 这里改成了 async 不知道有没有影响
// 这里改成了 async 不知道有没有影响
export
default
async
(
selectEffectYn
:
MsgSelectEffectYn
)
=>
{
export
default
async
(
selectEffectYn
:
MsgSelectEffectYn
)
=>
{
const
player
=
selectEffectYn
.
player
;
const
code
=
selectEffectYn
.
code
;
const
code
=
selectEffectYn
.
code
;
const
location
=
selectEffectYn
.
location
;
const
location
=
selectEffectYn
.
location
;
const
effect_description
=
selectEffectYn
.
effect_description
;
const
effect_description
=
selectEffectYn
.
effect_description
;
...
@@ -20,7 +19,7 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
...
@@ -20,7 +19,7 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
)
=>
{
)
=>
{
const
desc1
=
desc
.
replace
(
const
desc1
=
desc
.
replace
(
`[%ls]`
,
`[%ls]`
,
CardZoneToChinese
(
cardLocation
.
location
)
fetchStrings
(
"
!system
"
,
cardLocation
.
location
+
1000
)
);
);
const
desc2
=
desc1
.
replace
(
`[%ls]`
,
cardMeta
.
text
.
name
||
"
[?]
"
);
const
desc2
=
desc1
.
replace
(
`[%ls]`
,
cardMeta
.
text
.
name
||
"
[?]
"
);
return
desc2
;
return
desc2
;
...
@@ -29,14 +28,7 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
...
@@ -29,14 +28,7 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
const
desc1
=
desc
.
replace
(
`[%ls]`
,
cardMeta
.
text
.
name
||
"
[?]
"
);
const
desc1
=
desc
.
replace
(
`[%ls]`
,
cardMeta
.
text
.
name
||
"
[?]
"
);
return
desc1
;
return
desc1
;
};
};
// dispatch(
// fetchYesNoMeta({
// code,
// location,
// descCode: effect_description,
// textGenerator,
// })
// );
// TODO: 国际化文案
// TODO: 国际化文案
const
desc
=
fetchStrings
(
"
!system
"
,
effect_description
);
const
desc
=
fetchStrings
(
"
!system
"
,
effect_description
);
...
...
src/service/duel/selectSum.ts
View file @
6f35edc4
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
fetchCheckCardMeta
sV3
,
messageStore
}
from
"
@/stores
"
;
import
{
fetchCheckCardMeta
,
messageStore
}
from
"
@/stores
"
;
type
MsgSelectSum
=
ygopro
.
StocGameMessage
.
MsgSelectSum
;
type
MsgSelectSum
=
ygopro
.
StocGameMessage
.
MsgSelectSum
;
export
default
(
selectSum
:
MsgSelectSum
)
=>
{
export
default
(
selectSum
:
MsgSelectSum
)
=>
{
messageStore
.
checkCardModalV3
.
overflow
=
selectSum
.
overflow
!=
0
;
messageStore
.
selectCardActions
.
overflow
=
selectSum
.
overflow
!=
0
;
messageStore
.
checkCardModalV3
.
allLevel
=
selectSum
.
level_sum
;
messageStore
.
selectCardActions
.
totalLevels
=
selectSum
.
level_sum
;
messageStore
.
checkCardModalV3
.
selectM
in
=
selectSum
.
min
;
messageStore
.
selectCardActions
.
m
in
=
selectSum
.
min
;
messageStore
.
checkCardModalV3
.
selectM
ax
=
selectSum
.
max
;
messageStore
.
selectCardActions
.
m
ax
=
selectSum
.
max
;
fetchCheckCardMetasV3
({
for
(
const
option
of
selectSum
.
must_select_cards
)
{
mustSelect
:
true
,
fetchCheckCardMeta
(
option
,
false
,
true
);
options
:
selectSum
.
must_select_cards
,
}
});
fetchCheckCardMetasV3
({
for
(
const
option
of
selectSum
.
selectable_cards
)
{
mustSelect
:
false
,
fetchCheckCardMeta
(
option
);
options
:
selectSum
.
selectable_cards
,
}
});
messageStore
.
checkCardModalV3
.
isOpen
=
true
;
messageStore
.
selectCardActions
.
isOpen
=
true
;
};
};
src/service/duel/selectTribute.ts
View file @
6f35edc4
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
fetchCheckCardMeta
sV3
,
messageStore
}
from
"
@/stores
"
;
import
{
fetchCheckCardMeta
,
messageStore
}
from
"
@/stores
"
;
type
MsgSelectTribute
=
ygopro
.
StocGameMessage
.
MsgSelectTribute
;
type
MsgSelectTribute
=
ygopro
.
StocGameMessage
.
MsgSelectTribute
;
export
default
(
selectTribute
:
MsgSelectTribute
)
=>
{
export
default
(
selectTribute
:
MsgSelectTribute
)
=>
{
// TODO: 当玩家选择卡数大于`max`时,是否也合法?
// TODO: 当玩家选择卡数大于`max`时,是否也合法?
messageStore
.
checkCardModalV3
.
overflow
=
true
;
messageStore
.
selectCardActions
.
overflow
=
true
;
messageStore
.
checkCardModalV3
.
allLevel
=
0
;
messageStore
.
selectCardActions
.
totalLevels
=
0
;
messageStore
.
checkCardModalV3
.
selectM
in
=
selectTribute
.
min
;
messageStore
.
selectCardActions
.
m
in
=
selectTribute
.
min
;
messageStore
.
checkCardModalV3
.
selectM
ax
=
selectTribute
.
max
;
messageStore
.
selectCardActions
.
m
ax
=
selectTribute
.
max
;
fetchCheckCardMetasV3
({
for
(
const
option
of
selectTribute
.
selectable_cards
)
{
mustSelect
:
false
,
fetchCheckCardMeta
(
option
);
options
:
selectTribute
.
selectable_cards
.
map
((
card
)
=>
{
}
return
{
code
:
card
.
code
,
location
:
card
.
location
,
level1
:
card
.
level
,
level2
:
card
.
level
,
response
:
card
.
response
,
};
}),
});
messageStore
.
checkCardModalV3
.
isOpen
=
true
;
messageStore
.
selectCardActions
.
isOpen
=
true
;
};
};
src/service/duel/selectUnselectCard.ts
View file @
6f35edc4
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
fetchCheckCardMeta
sV2
,
messageStore
}
from
"
@/stores
"
;
import
{
fetchCheckCardMeta
,
messageStore
}
from
"
@/stores
"
;
type
MsgSelectUnselectCard
=
ygopro
.
StocGameMessage
.
MsgSelectUnselectCard
;
type
MsgSelectUnselectCard
=
ygopro
.
StocGameMessage
.
MsgSelectUnselectCard
;
...
@@ -11,33 +11,18 @@ export default ({
...
@@ -11,33 +11,18 @@ export default ({
selectable_cards
:
selectableCards
,
selectable_cards
:
selectableCards
,
selected_cards
:
selectedCards
,
selected_cards
:
selectedCards
,
}:
MsgSelectUnselectCard
)
=>
{
}:
MsgSelectUnselectCard
)
=>
{
messageStore
.
checkCardModalV2
.
isOpen
=
true
;
messageStore
.
selectCardActions
.
isOpen
=
true
;
messageStore
.
checkCardModalV2
.
finishAble
=
finishable
;
messageStore
.
selectCardActions
.
finishAble
=
finishable
;
messageStore
.
checkCardModalV2
.
cancelAble
=
cancelable
;
messageStore
.
selectCardActions
.
cancelAble
=
cancelable
;
messageStore
.
checkCardModalV2
.
selectMin
=
min
;
messageStore
.
selectCardActions
.
min
=
min
;
messageStore
.
checkCardModalV2
.
selectMax
=
max
;
messageStore
.
selectCardActions
.
max
=
max
;
messageStore
.
selectCardActions
.
single
=
true
;
fetchCheckCardMetasV2
({
for
(
const
option
of
selectableCards
)
{
selected
:
false
,
fetchCheckCardMeta
(
option
);
options
:
selectableCards
.
map
((
card
)
=>
{
}
return
{
code
:
card
.
code
,
location
:
card
.
location
,
response
:
card
.
response
,
};
}),
});
fetchCheckCardMetasV2
({
for
(
const
option
of
selectedCards
)
{
selected
:
true
,
fetchCheckCardMeta
(
option
,
true
);
options
:
selectedCards
.
map
((
card
)
=>
{
}
return
{
code
:
card
.
code
,
location
:
card
.
location
,
response
:
card
.
response
,
};
}),
});
messageStore
.
checkCardModalV2
.
responseable
=
true
;
};
};
src/stores/matStore/methods/cardZoneToChinese.ts
deleted
100644 → 0
View file @
3803129a
import
{
ygopro
}
from
"
@/api
"
;
export
function
CardZoneToChinese
(
zone
:
ygopro
.
CardZone
):
string
{
switch
(
zone
)
{
case
ygopro
.
CardZone
.
DECK
:
{
return
"
卡组
"
;
}
case
ygopro
.
CardZone
.
HAND
:
{
return
"
手牌
"
;
}
case
ygopro
.
CardZone
.
EXTRA
:
{
return
"
额外卡组
"
;
}
case
ygopro
.
CardZone
.
GRAVE
:
{
return
"
墓地
"
;
}
case
ygopro
.
CardZone
.
FZONE
:
{
return
"
FZONE
"
;
}
case
ygopro
.
CardZone
.
MZONE
:
{
return
"
怪兽区
"
;
}
case
ygopro
.
CardZone
.
SZONE
:
{
return
"
魔法陷阱区
"
;
}
case
ygopro
.
CardZone
.
REMOVED
:
{
return
"
除外区
"
;
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
return
"
超量区
"
;
}
case
ygopro
.
CardZone
.
PZONE
:
{
return
"
灵摆区
"
;
}
case
ygopro
.
CardZone
.
ONFIELD
:
{
return
"
场地区
"
;
}
default
:
{
return
"
未知区域
"
;
}
}
}
src/stores/matStore/methods/fetchCheckCardMeta.ts
View file @
6f35edc4
...
@@ -2,102 +2,50 @@ import { ygopro } from "@/api";
...
@@ -2,102 +2,50 @@ import { ygopro } from "@/api";
import
{
fetchCard
,
getCardStr
}
from
"
@/api/cards
"
;
import
{
fetchCard
,
getCardStr
}
from
"
@/api/cards
"
;
import
{
matStore
,
messageStore
}
from
"
@/stores
"
;
import
{
matStore
,
messageStore
}
from
"
@/stores
"
;
import
{
CardZoneToChinese
}
from
"
./cardZoneToChinese
"
;
type
Location
=
|
ygopro
.
CardLocation
|
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
;
function
cmpCardLocation
(
left
:
Location
,
right
?:
Location
,
strict
?:
boolean
):
boolean
{
if
(
strict
)
{
return
JSON
.
stringify
(
left
)
===
JSON
.
stringify
(
right
);
}
else
{
return
(
left
.
controler
===
right
?.
controler
&&
left
.
location
===
right
?.
location
&&
left
.
sequence
===
right
?.
sequence
);
}
}
/**
* 这段代码定义了一个异步函数 fetchCheckCardMeta,它的作用是获取一张卡片的元数据并将其添加到某个名为 messageStore.checkCardModal 的对象上。
该函数的第一个参数是一个枚举值 ygopro.CardZone,表示卡片所在的区域。其余参数是一个包含卡片编号、位置、响应码和效果描述代码等信息的对象。
首先,这个函数会根据区域类型调用 CardZoneToChinese() 函数生成一个中文名称。然后,它会调用 fetchCard() 异步函数来获取指定卡片的元数据 meta。
接下来,函数会根据传递进来的 location 对象获取卡片所属的控制者,并根据控制者判断这张卡片是我方的还是对方的。然后,它会根据卡片的位置信息获取卡片的实际 ID,并构造一个新的选项 newOption。
接着,函数会遍历已有的 messageStore.checkCardModal.tags,查找是否存在名为 combinedTagName 的标签。如果找到了,则将新选项 newOption 加入该标签的选项列表中并立即返回。如果找不到,则创建一个新标签,并将新选项 newOption 添加到其中。
最后,函数会再次遍历所有标签,查找是否存在名为 combinedTagName 的标签。如果找到了,则遍历该标签中的所有选项,并查找是否存在与 location 对象中指定的卡片位置信息完全相同的选项。如果找到了,则更新该选项的元数据和效果描述等信息。
*/
export
const
fetchCheckCardMeta
=
async
(
export
const
fetchCheckCardMeta
=
async
(
zone
:
ygopro
.
CardZone
,
{
{
code
,
code
,
location
,
location
,
level1
,
level2
,
response
,
response
,
effectDescCode
,
effectDescCode
,
}:
{
}:
{
code
:
number
;
code
:
number
;
location
:
ygopro
.
CardLocation
;
location
:
ygopro
.
CardLocation
;
level1
?:
number
;
level2
?:
number
;
response
:
number
;
response
:
number
;
effectDescCode
?:
number
;
effectDescCode
?:
number
;
}
},
selected
?:
boolean
,
mustSelect
?:
boolean
)
=>
{
)
=>
{
const
tagName
=
CardZoneToChinese
(
zone
);
const
meta
=
await
fetchCard
(
code
);
const
controller
=
location
.
controler
;
const
controller
=
location
.
controler
;
const
combinedTagName
=
matStore
.
isMe
(
controller
)
?
`我方的
${
tagName
}
`
:
`对方的
${
tagName
}
`
;
const
newID
=
const
newID
=
code
!=
0
code
!=
0
?
code
?
code
:
matStore
.
in
(
location
.
location
).
of
(
controller
)[
location
.
sequence
]
:
matStore
.
in
(
location
.
location
).
of
(
controller
)[
location
.
sequence
]
?.
occupant
?.
id
||
0
;
?.
occupant
?.
id
||
0
;
const
meta
=
await
fetchCard
(
code
);
const
effectDesc
=
effectDescCode
?
getCardStr
(
meta
,
effectDescCode
&
0xf
)
:
undefined
;
const
newOption
=
{
const
newOption
=
{
meta
:
{
id
:
newID
,
data
:
{},
text
:
{}
}
,
code
:
newID
,
location
:
location
.
toObject
(),
location
:
location
.
toObject
(),
effectDescCode
,
level1
,
level2
,
effectDesc
,
response
,
response
,
};
};
for
(
const
tag
of
messageStore
.
checkCardModal
.
tags
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
tag
.
options
.
push
(
newOption
);
return
;
}
}
messageStore
.
checkCardModal
.
tags
.
push
({
tagName
:
combinedTagName
,
options
:
[
newOption
],
});
for
(
const
tag
of
messageStore
.
checkCardModal
.
tags
)
{
if
(
selected
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
messageStore
.
selectCardActions
.
selecteds
.
push
(
newOption
);
for
(
const
old
of
tag
.
options
)
{
}
else
if
(
mustSelect
)
{
if
(
meta
.
id
==
old
.
meta
.
id
&&
cmpCardLocation
(
location
,
old
.
location
))
{
messageStore
.
selectCardActions
.
mustSelects
.
push
(
newOption
);
const
cardID
=
old
.
meta
.
id
;
}
else
{
old
.
meta
=
meta
;
messageStore
.
selectCardActions
.
selectables
.
push
(
newOption
);
old
.
meta
.
id
=
cardID
;
const
effectDescCode
=
old
.
effectDescCode
;
const
effectDesc
=
effectDescCode
?
getCardStr
(
old
.
meta
,
effectDescCode
&
0xf
)
:
undefined
;
old
.
effectDesc
=
effectDesc
;
}
}
}
}
}
};
};
src/stores/matStore/methods/index.ts
View file @
6f35edc4
export
*
from
"
./cardZoneToChinese
"
;
export
*
from
"
./fetchCheckCardMeta
"
;
export
*
from
"
./fetchCheckCardMeta
"
;
export
*
from
"
./fetchHint
"
;
export
*
from
"
./fetchHint
"
;
export
*
from
"
./fetchOverlayMeta
"
;
export
*
from
"
./fetchOverlayMeta
"
;
...
...
src/stores/messageStore/methods/clearSelectActions.ts
0 → 100644
View file @
6f35edc4
import
{
messageStore
}
from
"
../store
"
;
const
{
selectCardActions
}
=
messageStore
;
export
const
clearSelectActions
=
()
=>
{
selectCardActions
.
isOpen
=
false
;
selectCardActions
.
isChain
=
undefined
;
selectCardActions
.
min
=
undefined
;
selectCardActions
.
max
=
undefined
;
selectCardActions
.
cancelAble
=
false
;
selectCardActions
.
totalLevels
=
undefined
;
selectCardActions
.
selecteds
=
[];
selectCardActions
.
selectables
=
[];
selectCardActions
.
mustSelects
=
[];
selectCardActions
.
finishAble
=
false
;
selectCardActions
.
overflow
=
false
;
selectCardActions
.
single
=
undefined
;
};
src/stores/messageStore/methods/fetchCheckCardMetasV2.ts
deleted
100644 → 0
View file @
3803129a
import
{
fetchCard
,
type
ygopro
}
from
"
@/api
"
;
import
{
getCardByLocation
,
messageStore
}
from
"
@/stores
"
;
export
const
fetchCheckCardMetasV2
=
async
({
selected
,
options
,
}:
{
selected
:
boolean
;
options
:
{
code
:
number
;
location
:
ygopro
.
CardLocation
;
response
:
number
;
name
?:
string
;
desc
?:
string
;
}[];
})
=>
{
const
metas
=
await
Promise
.
all
(
options
.
map
(
async
(
option
)
=>
{
return
await
fetchCard
(
option
.
code
,
true
);
})
);
for
(
const
option
of
options
)
{
if
(
option
.
code
==
0
)
{
const
newCode
=
getCardByLocation
(
option
.
location
)?.
occupant
?.
id
||
0
;
option
.
code
=
newCode
;
}
}
options
.
forEach
((
option
)
=>
{
metas
.
forEach
((
meta
)
=>
{
if
(
option
.
code
==
meta
.
id
)
{
option
.
name
=
meta
.
text
.
name
;
option
.
desc
=
meta
.
text
.
desc
;
}
});
});
if
(
selected
)
{
messageStore
.
checkCardModalV2
.
selectedOptions
=
options
;
}
else
{
messageStore
.
checkCardModalV2
.
selectableOptions
=
options
;
}
};
src/stores/messageStore/methods/fetchCheckCardMetasV3.ts
deleted
100644 → 0
View file @
3803129a
import
{
fetchCard
,
type
ygopro
}
from
"
@/api
"
;
import
{
getCardByLocation
,
messageStore
}
from
"
@/stores
"
;
export
const
fetchCheckCardMetasV3
=
async
({
mustSelect
,
options
,
}:
{
mustSelect
:
boolean
;
options
:
{
code
:
number
;
location
:
ygopro
.
CardLocation
;
level1
:
number
;
level2
:
number
;
response
:
number
;
}[];
})
=>
{
const
metas
=
await
Promise
.
all
(
options
.
map
(
async
(
option
)
=>
{
return
await
fetchCard
(
option
.
code
,
true
);
})
);
const
newOptions
=
options
.
map
((
option
)
=>
{
if
(
option
.
code
==
0
)
{
const
newCode
=
getCardByLocation
(
option
.
location
)?.
occupant
?.
id
||
0
;
option
.
code
=
newCode
;
}
return
{
meta
:
{
id
:
option
.
code
,
data
:
{},
text
:
{}
},
level1
:
option
.
level1
,
level2
:
option
.
level2
,
response
:
option
.
response
,
};
});
newOptions
.
forEach
((
option
)
=>
{
metas
.
forEach
((
meta
)
=>
{
if
(
option
.
meta
.
id
==
meta
.
id
)
{
option
.
meta
=
meta
;
}
});
});
if
(
mustSelect
)
{
messageStore
.
checkCardModalV3
.
mustSelectList
=
newOptions
;
}
else
{
messageStore
.
checkCardModalV3
.
selectAbleList
=
newOptions
;
}
};
src/stores/messageStore/methods/index.ts
View file @
6f35edc4
export
*
from
"
./clearAllIdleInteractivities
"
;
export
*
from
"
./clearAllIdleInteractivities
"
;
export
*
from
"
./clearAllPlaceInteradtivities
"
;
export
*
from
"
./clearAllPlaceInteradtivities
"
;
export
*
from
"
./fetchCheckCardMetasV2
"
;
export
*
from
"
./clearSelectActions
"
;
export
*
from
"
./fetchCheckCardMetasV3
"
;
src/stores/messageStore/store.ts
View file @
6f35edc4
...
@@ -5,25 +5,17 @@ import type { ModalState } from "./types";
...
@@ -5,25 +5,17 @@ import type { ModalState } from "./types";
export
const
messageStore
=
proxy
<
ModalState
>
({
export
const
messageStore
=
proxy
<
ModalState
>
({
cardModal
:
{
isOpen
:
false
,
interactivies
:
[],
counters
:
{}
},
cardModal
:
{
isOpen
:
false
,
interactivies
:
[],
counters
:
{}
},
cardListModal
:
{
isOpen
:
false
,
list
:
[]
},
cardListModal
:
{
isOpen
:
false
,
list
:
[]
},
checkCardModal
:
{
isOpen
:
false
,
cancelAble
:
false
,
tags
:
[]
},
selectCardActions
:
{
yesNoModal
:
{
isOpen
:
false
},
positionModal
:
{
isOpen
:
false
,
positions
:
[]
},
optionModal
:
{
isOpen
:
false
,
options
:
[]
},
checkCardModalV2
:
{
isOpen
:
false
,
isOpen
:
false
,
cancelAble
:
false
,
cancelAble
:
false
,
finishAble
:
false
,
finishAble
:
false
,
responseable
:
false
,
selecteds
:
[],
selectableOptions
:
[],
selectables
:
[],
selectedOptions
:
[],
mustSelects
:
[],
},
checkCardModalV3
:
{
isOpen
:
false
,
overflow
:
false
,
allLevel
:
0
,
mustSelectList
:
[],
selectAbleList
:
[],
},
},
yesNoModal
:
{
isOpen
:
false
},
positionModal
:
{
isOpen
:
false
,
positions
:
[]
},
optionModal
:
{
isOpen
:
false
,
options
:
[]
},
checkCounterModal
:
{
checkCounterModal
:
{
isOpen
:
false
,
isOpen
:
false
,
options
:
[],
options
:
[],
...
...
src/stores/messageStore/types.ts
View file @
6f35edc4
import
type
{
CardMeta
,
ygopro
}
from
"
@/api
"
;
import
type
{
CardMeta
,
ygopro
}
from
"
@/api
"
;
type
CardLocation
=
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
;
type
CardLocation
=
ReturnType
<
typeof
ygopro
.
CardLocation
.
prototype
.
toObject
>
;
interface
Option
{
// card id
code
:
number
;
location
?:
CardLocation
;
// 效果
effectDesc
?:
string
;
// 作为素材的cost,比如同调召唤的星级
level1
?:
number
;
level2
?:
number
;
response
:
number
;
}
export
interface
ModalState
{
export
interface
ModalState
{
// 卡牌弹窗
// 卡牌弹窗
cardModal
:
{
cardModal
:
{
...
@@ -17,24 +29,27 @@ export interface ModalState {
...
@@ -17,24 +29,27 @@ export interface ModalState {
interactivies
:
{
desc
:
string
;
response
:
number
}[];
interactivies
:
{
desc
:
string
;
response
:
number
}[];
}[];
}[];
};
};
// 卡牌选择
弹窗
// 卡牌选择
状态
checkCardModal
:
{
selectCardActions
:
{
isOpen
:
boolean
;
isOpen
:
boolean
;
onSubmit
?:
string
;
// 如果是连锁,发response给后端的方式稍微有点不同,这里标记下
selectMin
?:
number
;
isChain
?:
boolean
;
selectMax
?:
number
;
min
?:
number
;
max
?:
number
;
// 是否只能选择单个
single
?:
boolean
;
cancelAble
:
boolean
;
cancelAble
:
boolean
;
cancelResponse
?:
number
;
finishAble
:
boolean
;
tags
:
{
// 上级/同调/超量/链接召唤的总cost
tagName
:
string
;
totalLevels
?:
number
;
options
:
{
// cost是否可以溢出,比如同调召唤是false,某些链接召唤是true
meta
:
CardMeta
;
overflow
?:
boolean
;
location
?:
CardLocation
;
// 已经选择的列表
effectDescCode
?:
number
;
selecteds
:
Option
[]
;
effectDesc
?:
string
;
// 可以选择的列表
response
:
number
;
selectables
:
Option
[]
;
}[];
// 必须选择的列表
}
[];
mustSelects
:
Option
[];
};
};
// Yes or No弹窗
// Yes or No弹窗
yesNoModal
:
{
yesNoModal
:
{
...
@@ -51,48 +66,6 @@ export interface ModalState {
...
@@ -51,48 +66,6 @@ export interface ModalState {
isOpen
:
boolean
;
isOpen
:
boolean
;
options
:
{
msg
:
string
;
response
:
number
}[];
options
:
{
msg
:
string
;
response
:
number
}[];
};
};
// 卡牌选择弹窗V2
checkCardModalV2
:
{
isOpen
:
boolean
;
cancelAble
:
boolean
;
finishAble
:
boolean
;
selectMin
?:
number
;
selectMax
?:
number
;
responseable
?:
boolean
;
selectableOptions
:
{
code
:
number
;
name
?:
string
;
desc
?:
string
;
response
:
number
;
}[];
selectedOptions
:
{
code
:
number
;
name
?:
string
;
desc
?:
string
;
response
:
number
;
}[];
};
// 卡牌选择弹窗V3
checkCardModalV3
:
{
isOpen
:
boolean
;
overflow
:
boolean
;
allLevel
:
number
;
selectMin
?:
number
;
selectMax
?:
number
;
responseable
?:
boolean
;
mustSelectList
:
{
meta
:
CardMeta
;
level1
:
number
;
level2
:
number
;
response
:
number
;
}[];
selectAbleList
:
{
meta
:
CardMeta
;
level1
:
number
;
level2
:
number
;
response
:
number
;
}[];
};
// 指示器选择弹窗
// 指示器选择弹窗
checkCounterModal
:
{
checkCounterModal
:
{
isOpen
:
boolean
;
isOpen
:
boolean
;
...
...
src/ui/Duel/Main.tsx
View file @
6f35edc4
...
@@ -4,13 +4,11 @@ import {
...
@@ -4,13 +4,11 @@ import {
Alert
,
Alert
,
CardListModal
,
CardListModal
,
CardModal
,
CardModal
,
CheckCardModal
,
CheckCardModalV2
,
CheckCardModalV3
,
CheckCounterModal
,
CheckCounterModal
,
HintNotification
,
HintNotification
,
OptionModal
,
OptionModal
,
PositionModal
,
PositionModal
,
SelectActionsModal
,
SortCardModal
,
SortCardModal
,
YesNoModal
,
YesNoModal
,
}
from
"
./Message
"
;
}
from
"
./Message
"
;
...
@@ -24,12 +22,10 @@ const NeosDuel = () => {
...
@@ -24,12 +22,10 @@ const NeosDuel = () => {
<
CardModal
/>
<
CardModal
/>
<
CardListModal
/>
<
CardListModal
/>
<
HintNotification
/>
<
HintNotification
/>
<
CheckCard
Modal
/>
<
SelectActions
Modal
/>
<
YesNoModal
/>
<
YesNoModal
/>
<
PositionModal
/>
<
PositionModal
/>
<
OptionModal
/>
<
OptionModal
/>
<
CheckCardModalV2
/>
<
CheckCardModalV3
/>
<
CheckCounterModal
/>
<
CheckCounterModal
/>
<
SortCardModal
/>
<
SortCardModal
/>
</>
</>
...
...
src/ui/Duel/Message/CheckCardModal.tsx
deleted
100644 → 0
View file @
3803129a
import
{
ThunderboltOutlined
}
from
"
@ant-design/icons
"
;
import
{
CheckCard
,
CheckCardProps
}
from
"
@ant-design/pro-components
"
;
import
{
Button
,
Col
,
Popover
,
Row
}
from
"
antd
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
sendSelectCardResponse
,
sendSelectChainResponse
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
matStore
,
messageStore
}
from
"
@/stores
"
;
import
{
DragModal
}
from
"
./DragModal
"
;
const
NeosConfig
=
useConfig
();
const
{
checkCardModal
}
=
messageStore
;
export
const
CheckCardModal
=
()
=>
{
const
snapCheckCardModal
=
useSnapshot
(
checkCardModal
);
const
isOpen
=
snapCheckCardModal
.
isOpen
;
const
min
=
snapCheckCardModal
.
selectMin
??
0
;
const
max
=
snapCheckCardModal
.
selectMax
??
10
;
const
tabs
=
snapCheckCardModal
.
tags
;
const
onSubmit
=
snapCheckCardModal
.
onSubmit
;
const
cancelAble
=
snapCheckCardModal
.
cancelAble
;
const
cancelResponse
=
snapCheckCardModal
.
cancelResponse
;
const
[
response
,
setResponse
]
=
useState
<
number
[]
>
([]);
const
defaultValue
:
number
[]
=
[];
const
hint
=
useSnapshot
(
matStore
.
hint
);
const
preHintMsg
=
hint
?.
esHint
||
""
;
const
selectHintMsg
=
hint
?.
esSelectHint
||
"
请选择卡片
"
;
// TODO: 这里可以考虑更好地封装
const
sendResponseHandler
=
(
handlerName
:
string
|
undefined
,
response
:
number
[]
)
=>
{
switch
(
handlerName
)
{
case
"
sendSelectChainResponse
"
:
{
sendSelectChainResponse
(
response
[
0
]);
break
;
}
case
"
sendSelectCardResponse
"
:
{
sendSelectCardResponse
(
response
);
break
;
}
default
:
{
}
}
};
const
resetCheckCardModal
=
()
=>
{
checkCardModal
.
isOpen
=
false
;
checkCardModal
.
selectMin
=
undefined
;
checkCardModal
.
selectMax
=
undefined
;
checkCardModal
.
cancelAble
=
false
;
checkCardModal
.
cancelResponse
=
undefined
;
checkCardModal
.
tags
=
[];
};
return
(
<
DragModal
title=
{
`${preHintMsg} ${selectHintMsg} ${min}-${max}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
<>
<
Button
disabled=
{
response
.
length
<
min
||
response
.
length
>
max
}
onClick=
{
()
=>
{
sendResponseHandler
(
onSubmit
,
response
);
checkCardModal
.
isOpen
=
false
;
resetCheckCardModal
();
}
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
submit
</
Button
>
{
cancelAble
?
(
<
Button
onClick=
{
()
=>
{
if
(
cancelResponse
)
{
sendResponseHandler
(
onSubmit
,
[
cancelResponse
]);
}
checkCardModal
.
isOpen
=
false
;
resetCheckCardModal
();
}
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
cancel
</
Button
>
)
:
(
<></>
)
}
</>
}
width=
{
800
}
>
<
CheckCard
.
Group
multiple
bordered
size=
"small"
defaultValue=
{
defaultValue
}
onChange=
{
(
value
)
=>
{
// @ts-ignore
setResponse
(
value
);
}
}
>
{
tabs
.
map
((
tab
,
idx
)
=>
{
return
(
<
Row
key=
{
idx
}
>
{
tab
.
options
.
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
HoverCheckCard
hoverContent=
{
option
.
effectDesc
}
title=
{
option
.
meta
.
text
.
name
}
description=
{
option
.
meta
.
text
.
desc
}
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
meta
.
id
.
toString
()
}
src=
{
option
.
meta
.
id
?
`${NeosConfig.cardImgUrl}/${option.meta.id}.jpg`
:
`${NeosConfig.assetsPath}/card_back.jpg`
}
style=
{
{
width
:
100
}
}
/>
}
value=
{
option
.
response
}
/>
</
Col
>
);
})
}
</
Row
>
);
})
}
</
CheckCard
.
Group
>
</
DragModal
>
);
};
const
HoverCheckCard
=
(
props
:
CheckCardProps
&
{
hoverContent
?:
string
})
=>
{
const
[
hover
,
setHover
]
=
useState
(
false
);
const
onMouseEnter
=
()
=>
setHover
(
true
);
const
onMouseLeave
=
()
=>
setHover
(
false
);
return
(
<>
<
CheckCard
{
...
props
}
/>
{
props
.
hoverContent
?
(
<
Popover
content=
{
<
p
>
{
props
.
hoverContent
}
</
p
>
}
open=
{
hover
}
>
<
Button
icon=
{
<
ThunderboltOutlined
/>
}
onMouseEnter=
{
onMouseEnter
}
onMouseLeave=
{
onMouseLeave
}
></
Button
>
</
Popover
>
)
:
(
<></>
)
}
</>
);
};
src/ui/Duel/Message/CheckCardModalV2.tsx
deleted
100644 → 0
View file @
3803129a
import
{
CheckCard
}
from
"
@ant-design/pro-components
"
;
import
{
Button
,
Card
,
Col
,
Row
}
from
"
antd
"
;
import
React
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
sendSelectUnselectCardResponse
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
matStore
,
messageStore
}
from
"
@/stores
"
;
import
{
DragModal
}
from
"
./DragModal
"
;
const
{
checkCardModalV2
}
=
messageStore
;
const
NeosConfig
=
useConfig
();
export
const
CheckCardModalV2
=
()
=>
{
const
snapCheckCardModalV2
=
useSnapshot
(
checkCardModalV2
);
const
isOpen
=
snapCheckCardModalV2
.
isOpen
;
const
min
=
snapCheckCardModalV2
.
selectMin
??
0
;
const
max
=
snapCheckCardModalV2
.
selectMax
??
10
;
const
cancelable
=
snapCheckCardModalV2
.
cancelAble
;
const
finishable
=
snapCheckCardModalV2
.
finishAble
;
const
selectableOptions
=
snapCheckCardModalV2
.
selectableOptions
;
const
selectedOptions
=
snapCheckCardModalV2
.
selectedOptions
;
const
responseable
=
snapCheckCardModalV2
.
responseable
;
const
hint
=
useSnapshot
(
matStore
.
hint
);
const
preHintMsg
=
hint
?.
esHint
||
""
;
const
selectHintMsg
=
hint
?.
esSelectHint
||
"
请选择卡片
"
;
const
resetCheckCardModalV2
=
()
=>
{
checkCardModalV2
.
isOpen
=
false
;
checkCardModalV2
.
finishAble
=
false
;
checkCardModalV2
.
cancelAble
=
false
;
checkCardModalV2
.
responseable
=
false
;
checkCardModalV2
.
selectableOptions
=
[];
checkCardModalV2
.
selectedOptions
=
[];
};
const
onFinishOrCancel
=
()
=>
{
sendSelectUnselectCardResponse
({
cancel_or_finish
:
true
});
checkCardModalV2
.
isOpen
=
false
;
checkCardModalV2
.
responseable
=
false
;
resetCheckCardModalV2
();
};
return
(
<
DragModal
title=
{
`${preHintMsg} ${selectHintMsg} ${min}-${max}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
<>
<
Button
disabled=
{
!
finishable
||
!
responseable
}
onClick=
{
onFinishOrCancel
}
>
finish
</
Button
>
<
Button
disabled=
{
!
cancelable
||
!
responseable
}
onClick=
{
onFinishOrCancel
}
>
cancel
</
Button
>
</>
}
width=
{
800
}
>
<
CheckCard
.
Group
bordered
size=
"small"
onChange=
{
(
value
)
=>
{
if
(
responseable
)
{
// @ts-ignore
sendSelectUnselectCardResponse
({
selected_ptr
:
value
});
checkCardModalV2
.
isOpen
=
false
;
checkCardModalV2
.
responseable
=
false
;
}
}
}
>
<
Row
>
{
selectableOptions
.
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
CheckCard
title=
{
option
.
name
}
description=
{
option
.
desc
}
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
code
.
toString
()
}
src=
{
`${NeosConfig.cardImgUrl}/${option.code}.jpg`
}
style=
{
{
width
:
100
}
}
/>
}
value=
{
option
.
response
}
/>
</
Col
>
);
})
}
</
Row
>
</
CheckCard
.
Group
>
<
p
>
已经选择的卡片
</
p
>
<
Row
>
{
selectedOptions
.
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
Card
hoverable
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
code
.
toString
()
}
src=
{
`${NeosConfig.cardImgUrl}/${option.code}.jpg`
}
/>
}
/>
</
Col
>
);
})
}
</
Row
>
</
DragModal
>
);
};
src/ui/Duel/Message/CheckCardModalV3.tsx
deleted
100644 → 0
View file @
3803129a
import
{
CheckCard
}
from
"
@ant-design/pro-components
"
;
import
{
Button
,
Card
,
Col
,
Row
}
from
"
antd
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
sendSelectCardResponse
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
matStore
,
messageStore
}
from
"
@/stores
"
;
import
{
DragModal
}
from
"
./DragModal
"
;
const
NeosConfig
=
useConfig
();
const
{
checkCardModalV3
}
=
messageStore
;
export
const
CheckCardModalV3
=
()
=>
{
const
snapCheckCardModalV3
=
useSnapshot
(
checkCardModalV3
);
const
isOpen
=
snapCheckCardModalV3
.
isOpen
;
const
min
=
snapCheckCardModalV3
.
selectMin
||
0
;
const
max
=
snapCheckCardModalV3
.
selectMax
||
0
;
const
mustSelectOptions
=
snapCheckCardModalV3
.
mustSelectList
;
const
selectAbleOptions
=
snapCheckCardModalV3
.
selectAbleList
;
const
overflow
=
snapCheckCardModalV3
.
overflow
;
const
LevelSum
=
snapCheckCardModalV3
.
allLevel
;
const
[
selectedOptions
,
setSelectedOptions
]
=
useState
([]);
const
Level1Sum
=
mustSelectOptions
.
concat
(
selectedOptions
)
.
map
((
option
)
=>
option
.
level1
)
.
reduce
((
sum
,
current
)
=>
sum
+
current
,
0
);
const
Level2Sum
=
mustSelectOptions
.
concat
(
selectedOptions
)
.
map
((
option
)
=>
option
.
level2
)
.
reduce
((
sum
,
current
)
=>
sum
+
current
,
0
);
const
hint
=
useSnapshot
(
matStore
.
hint
);
const
preHintMsg
=
hint
?.
esHint
||
""
;
const
selectHintMsg
=
hint
?.
esSelectHint
||
"
请选择卡片
"
;
const
responseable
=
(
overflow
?
Level1Sum
>=
LevelSum
||
Level2Sum
>=
LevelSum
:
Level1Sum
==
LevelSum
||
Level2Sum
==
LevelSum
)
&&
selectedOptions
.
length
<=
max
&&
selectedOptions
.
length
>=
min
;
const
onFinish
=
()
=>
{
sendSelectCardResponse
(
mustSelectOptions
.
concat
(
selectedOptions
).
map
((
option
)
=>
option
.
response
)
);
checkCardModalV3
.
isOpen
=
false
;
checkCardModalV3
.
responseable
=
false
;
checkCardModalV3
.
overflow
=
false
;
checkCardModalV3
.
allLevel
=
0
;
checkCardModalV3
.
mustSelectList
=
[];
checkCardModalV3
.
selectAbleList
=
[];
};
return
(
<
DragModal
title=
{
`${preHintMsg} ${selectHintMsg} ${min}-${max}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
<>
<
Button
disabled=
{
!
responseable
}
onClick=
{
onFinish
}
>
finish
</
Button
>
</>
}
width=
{
800
}
>
<
CheckCard
.
Group
bordered
size=
"small"
multiple=
{
true
}
onChange=
{
(
values
:
any
)
=>
{
console
.
log
(
values
);
setSelectedOptions
(
values
);
}
}
>
<
Row
>
{
selectAbleOptions
.
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
CheckCard
title=
{
option
.
meta
.
text
.
name
}
description=
{
option
.
meta
.
text
.
desc
}
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
meta
.
id
.
toString
()
}
src=
{
`${NeosConfig.cardImgUrl}/${option.meta.id}.jpg`
}
style=
{
{
width
:
100
}
}
/>
}
value=
{
option
}
/>
</
Col
>
);
})
}
</
Row
>
</
CheckCard
.
Group
>
<
p
>
必须选择的卡片
</
p
>
<
Row
>
{
mustSelectOptions
.
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
Card
hoverable
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
meta
.
id
.
toString
()
}
src=
{
`${NeosConfig.cardImgUrl}/${option.meta.id}.jpg`
}
/>
}
/>
</
Col
>
);
})
}
</
Row
>
</
DragModal
>
);
};
src/ui/Duel/Message/SelectActionsModal.tsx
0 → 100644
View file @
6f35edc4
import
{
ThunderboltOutlined
}
from
"
@ant-design/icons
"
;
import
{
CheckCard
,
CheckCardProps
}
from
"
@ant-design/pro-components
"
;
import
{
Button
,
Card
,
Col
,
Popover
,
Row
}
from
"
antd
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
fetchStrings
,
sendSelectMultiResponse
,
sendSelectSingleResponse
,
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
clearSelectActions
,
matStore
,
messageStore
}
from
"
@/stores
"
;
import
{
DragModal
}
from
"
./DragModal
"
;
const
NeosConfig
=
useConfig
();
const
CANCEL_RESPONSE
=
-
1
;
const
FINISH_RESPONSE
=
-
1
;
const
{
selectCardActions
}
=
messageStore
;
export
const
SelectActionsModal
=
()
=>
{
const
snap
=
useSnapshot
(
selectCardActions
);
const
isOpen
=
snap
.
isOpen
;
const
isChain
=
snap
.
isChain
;
const
min
=
snap
.
min
??
0
;
const
max
=
snap
.
max
??
0
;
const
single
=
snap
.
single
??
false
;
const
selecteds
=
snap
.
selecteds
;
const
selectables
=
snap
.
selectables
;
const
mustSelects
=
snap
.
mustSelects
;
const
[
response
,
setResponse
]
=
useState
([]);
const
hint
=
useSnapshot
(
matStore
.
hint
);
const
preHintMsg
=
hint
?.
esHint
||
""
;
const
selectHintMsg
=
hint
?.
esSelectHint
||
"
请选择卡片
"
;
const
cancelable
=
snap
.
cancelAble
;
const
finishable
=
snap
.
finishAble
;
const
totalLevels
=
snap
.
totalLevels
??
0
;
const
overflow
=
snap
.
overflow
||
false
;
const
LevelSum1
=
mustSelects
.
concat
(
response
)
.
map
((
option
)
=>
option
.
level1
||
0
)
.
reduce
((
sum
,
current
)
=>
sum
+
current
,
0
);
const
LevelSum2
=
mustSelects
.
concat
(
response
)
.
map
((
option
)
=>
option
.
level2
||
0
)
.
reduce
((
sum
,
current
)
=>
sum
+
current
,
0
);
const
levelMatched
=
overflow
?
LevelSum1
>=
totalLevels
||
LevelSum2
>=
totalLevels
:
LevelSum1
==
totalLevels
||
LevelSum2
==
totalLevels
;
const
submitable
=
single
?
response
.
length
==
1
:
response
.
length
>=
min
&&
response
.
length
<=
max
&&
levelMatched
;
return
(
<
DragModal
title=
{
`${preHintMsg} ${selectHintMsg} ${min}-${max} ${
single ? "每次选择一张" : ""
}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
<>
<
Button
disabled=
{
!
submitable
}
onClick=
{
()
=>
{
const
values
=
mustSelects
.
concat
(
response
)
.
map
((
option
)
=>
option
.
response
);
if
(
isChain
)
{
sendSelectSingleResponse
(
values
[
0
]);
}
else
{
sendSelectMultiResponse
(
values
);
}
clearSelectActions
();
}
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
{
fetchStrings
(
"
!system
"
,
1211
)
}
</
Button
>
<
Button
disabled=
{
!
finishable
}
onClick=
{
()
=>
{
sendSelectSingleResponse
(
FINISH_RESPONSE
);
clearSelectActions
();
}
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
{
fetchStrings
(
"
!system
"
,
1296
)
}
</
Button
>
<
Button
disabled=
{
!
cancelable
}
onClick=
{
()
=>
{
sendSelectSingleResponse
(
CANCEL_RESPONSE
);
clearSelectActions
();
}
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
{
fetchStrings
(
"
!system
"
,
1295
)
}
</
Button
>
</>
}
width=
{
800
}
>
<
CheckCard
.
Group
multiple
bordered
size=
"small"
onChange=
{
(
value
)
=>
{
// @ts-ignore
setResponse
(
value
);
}
}
>
<
Row
>
{
selectables
.
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
HoverCheckCard
hoverContent=
{
option
.
effectDesc
}
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
code
.
toString
()
}
src=
{
option
.
code
?
`${NeosConfig.cardImgUrl}/${option.code}.jpg`
:
`${NeosConfig.assetsPath}/card_back.jpg`
}
style=
{
{
width
:
100
}
}
/>
}
value=
{
option
}
/>
</
Col
>
);
})
}
</
Row
>
<
p
>
{
fetchStrings
(
"
!system
"
,
212
)
}
</
p
>
<
Row
>
{
selecteds
.
concat
(
mustSelects
).
map
((
option
,
idx
)
=>
{
return
(
<
Col
span=
{
4
}
key=
{
idx
}
>
<
Card
style=
{
{
width
:
120
}
}
cover=
{
<
img
alt=
{
option
.
code
.
toString
()
}
src=
{
option
.
code
?
`${NeosConfig.cardImgUrl}/${option.code}.jpg`
:
`${NeosConfig.assetsPath}/card_back.jpg`
}
/>
}
/>
</
Col
>
);
})
}
</
Row
>
</
CheckCard
.
Group
>
</
DragModal
>
);
};
const
HoverCheckCard
=
(
props
:
CheckCardProps
&
{
hoverContent
?:
string
})
=>
{
const
[
hover
,
setHover
]
=
useState
(
false
);
const
onMouseEnter
=
()
=>
setHover
(
true
);
const
onMouseLeave
=
()
=>
setHover
(
false
);
return
(
<>
<
CheckCard
{
...
props
}
/>
{
props
.
hoverContent
?
(
<
Popover
content=
{
<
p
>
{
props
.
hoverContent
}
</
p
>
}
open=
{
hover
}
>
<
Button
icon=
{
<
ThunderboltOutlined
/>
}
onMouseEnter=
{
onMouseEnter
}
onMouseLeave=
{
onMouseLeave
}
></
Button
>
</
Popover
>
)
:
(
<></>
)
}
</>
);
};
src/ui/Duel/Message/index.ts
View file @
6f35edc4
export
*
from
"
./Alert
"
;
export
*
from
"
./Alert
"
;
export
*
from
"
./CardListModal
"
;
export
*
from
"
./CardListModal
"
;
export
*
from
"
./CardModal
"
;
export
*
from
"
./CardModal
"
;
export
*
from
"
./CheckCardModal
"
;
export
*
from
"
./CheckCardModalV2
"
;
export
*
from
"
./CheckCardModalV3
"
;
export
*
from
"
./CheckCounterModal
"
;
export
*
from
"
./CheckCounterModal
"
;
export
*
from
"
./DragModal
"
;
export
*
from
"
./DragModal
"
;
export
*
from
"
./HintNotification
"
;
export
*
from
"
./HintNotification
"
;
export
*
from
"
./OptionModal
"
;
export
*
from
"
./OptionModal
"
;
export
*
from
"
./PositionModal
"
;
export
*
from
"
./PositionModal
"
;
export
*
from
"
./SelectActionsModal
"
;
export
*
from
"
./SendBox
"
;
export
*
from
"
./SendBox
"
;
export
*
from
"
./SortCardModal
"
;
export
*
from
"
./SortCardModal
"
;
export
*
from
"
./Status
"
;
export
*
from
"
./Status
"
;
...
...
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