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
9c34b487
Commit
9c34b487
authored
Jan 07, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/service/select_chain_cancel' into 'main'
add cancelable logic See merge request
mycard/Neos!65
parents
46c12e4b
e3839c99
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
25 deletions
+86
-25
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+7
-1
src/reducers/duel/modalSlice.ts
src/reducers/duel/modalSlice.ts
+24
-0
src/service/duel/selectChain.ts
src/service/duel/selectChain.ts
+5
-1
src/ui/Duel/checkCardModal.tsx
src/ui/Duel/checkCardModal.tsx
+50
-23
No files found.
src/reducers/duel/mod.ts
View file @
9c34b487
...
@@ -28,6 +28,8 @@ import {
...
@@ -28,6 +28,8 @@ import {
setCheckCardModalIsOpenImpl
,
setCheckCardModalIsOpenImpl
,
setCheckCardModalMinMaxImpl
,
setCheckCardModalMinMaxImpl
,
setCheckCardModalOnSubmitImpl
,
setCheckCardModalOnSubmitImpl
,
setCheckCardMOdalCancelAbleImpl
,
setCheckCardModalCancelResponseImpl
,
resetCheckCardModalImpl
,
resetCheckCardModalImpl
,
checkCardModalCase
,
checkCardModalCase
,
}
from
"
./modalSlice
"
;
}
from
"
./modalSlice
"
;
...
@@ -81,7 +83,7 @@ const initialState: DuelState = {
...
@@ -81,7 +83,7 @@ const initialState: DuelState = {
modalState
:
{
modalState
:
{
cardModal
:
{
isOpen
:
false
,
interactivies
:
[]
},
cardModal
:
{
isOpen
:
false
,
interactivies
:
[]
},
cardListModal
:
{
isOpen
:
false
,
list
:
[]
},
cardListModal
:
{
isOpen
:
false
,
list
:
[]
},
checkCardModal
:
{
isOpen
:
false
,
tags
:
[]
},
checkCardModal
:
{
isOpen
:
false
,
cancelAble
:
false
,
tags
:
[]
},
},
},
};
};
...
@@ -125,6 +127,8 @@ const duelSlice = createSlice({
...
@@ -125,6 +127,8 @@ const duelSlice = createSlice({
setCheckCardModalIsOpen
:
setCheckCardModalIsOpenImpl
,
setCheckCardModalIsOpen
:
setCheckCardModalIsOpenImpl
,
setCheckCardModalMinMax
:
setCheckCardModalMinMaxImpl
,
setCheckCardModalMinMax
:
setCheckCardModalMinMaxImpl
,
setCheckCardModalOnSubmit
:
setCheckCardModalOnSubmitImpl
,
setCheckCardModalOnSubmit
:
setCheckCardModalOnSubmitImpl
,
setCheckCardMOdalCancelAble
:
setCheckCardMOdalCancelAbleImpl
,
setCheckCardModalCancelResponse
:
setCheckCardModalCancelResponseImpl
,
resetCheckCardModal
:
resetCheckCardModalImpl
,
resetCheckCardModal
:
resetCheckCardModalImpl
,
},
},
extraReducers
(
builder
)
{
extraReducers
(
builder
)
{
...
@@ -162,6 +166,8 @@ export const {
...
@@ -162,6 +166,8 @@ export const {
setCheckCardModalIsOpen
,
setCheckCardModalIsOpen
,
setCheckCardModalMinMax
,
setCheckCardModalMinMax
,
setCheckCardModalOnSubmit
,
setCheckCardModalOnSubmit
,
setCheckCardMOdalCancelAble
,
setCheckCardModalCancelResponse
,
resetCheckCardModal
,
resetCheckCardModal
,
}
=
duelSlice
.
actions
;
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
...
...
src/reducers/duel/modalSlice.ts
View file @
9c34b487
...
@@ -33,6 +33,8 @@ export interface ModalState {
...
@@ -33,6 +33,8 @@ export interface ModalState {
onSubmit
?:
string
;
onSubmit
?:
string
;
selectMin
?:
number
;
selectMin
?:
number
;
selectMax
?:
number
;
selectMax
?:
number
;
cancelAble
:
boolean
;
cancelResponse
?:
number
;
tags
:
{
tags
:
{
tagName
:
string
;
tagName
:
string
;
options
:
{
options
:
{
...
@@ -125,6 +127,22 @@ export const setCheckCardModalOnSubmitImpl: CaseReducer<
...
@@ -125,6 +127,22 @@ export const setCheckCardModalOnSubmitImpl: CaseReducer<
state
.
modalState
.
checkCardModal
.
onSubmit
=
action
.
payload
;
state
.
modalState
.
checkCardModal
.
onSubmit
=
action
.
payload
;
};
};
// 更新卡牌选择弹窗是否可以取消
export
const
setCheckCardMOdalCancelAbleImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
checkCardModal
.
cancelAble
=
action
.
payload
;
};
// 更新卡牌选择弹窗取消时返回给服务端的`Response`
export
const
setCheckCardModalCancelResponseImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
checkCardModal
.
cancelResponse
=
action
.
payload
;
};
// 增加卡牌选择选项
// 增加卡牌选择选项
export
const
fetchCheckCardMeta
=
createAsyncThunk
(
export
const
fetchCheckCardMeta
=
createAsyncThunk
(
"
duel/fetchCheckCardMeta
"
,
"
duel/fetchCheckCardMeta
"
,
...
@@ -204,6 +222,8 @@ export const resetCheckCardModalImpl: CaseReducer<DuelState> = (state) => {
...
@@ -204,6 +222,8 @@ export const resetCheckCardModalImpl: CaseReducer<DuelState> = (state) => {
state
.
modalState
.
checkCardModal
.
isOpen
=
false
;
state
.
modalState
.
checkCardModal
.
isOpen
=
false
;
state
.
modalState
.
checkCardModal
.
selectMin
=
undefined
;
state
.
modalState
.
checkCardModal
.
selectMin
=
undefined
;
state
.
modalState
.
checkCardModal
.
selectMax
=
undefined
;
state
.
modalState
.
checkCardModal
.
selectMax
=
undefined
;
state
.
modalState
.
checkCardModal
.
cancelAble
=
false
;
state
.
modalState
.
checkCardModal
.
cancelResponse
=
undefined
;
state
.
modalState
.
checkCardModal
.
tags
=
[];
state
.
modalState
.
checkCardModal
.
tags
=
[];
};
};
...
@@ -233,3 +253,7 @@ export const selectCheckCardModalTags = (state: RootState) =>
...
@@ -233,3 +253,7 @@ export const selectCheckCardModalTags = (state: RootState) =>
state
.
duel
.
modalState
.
checkCardModal
.
tags
;
state
.
duel
.
modalState
.
checkCardModal
.
tags
;
export
const
selectCheckCardModalOnSubmit
=
(
state
:
RootState
)
=>
export
const
selectCheckCardModalOnSubmit
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
checkCardModal
.
onSubmit
;
state
.
duel
.
modalState
.
checkCardModal
.
onSubmit
;
export
const
selectCheckCardModalCancelAble
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
checkCardModal
.
cancelAble
;
export
const
selectCheckCardModalCacnelResponse
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
checkCardModal
.
cancelResponse
;
src/service/duel/selectChain.ts
View file @
9c34b487
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
sendSelectChainResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
sendSelectChainResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
import
{
setCheckCardMOdalCancelAble
,
setCheckCardModalCancelResponse
,
setCheckCardModalIsOpen
,
setCheckCardModalIsOpen
,
setCheckCardModalMinMax
,
setCheckCardModalMinMax
,
setCheckCardModalOnSubmit
,
setCheckCardModalOnSubmit
,
...
@@ -61,9 +63,11 @@ export default (selectChain: MsgSelectChain, dispatch: AppDispatch) => {
...
@@ -61,9 +63,11 @@ export default (selectChain: MsgSelectChain, dispatch: AppDispatch) => {
case
2
:
// 处理多张
case
2
:
// 处理多张
case
3
:
{
case
3
:
{
// 处理强制发动的卡
// 处理强制发动的卡
// TODO:非强制发动的场景需要支持取消
dispatch
(
setCheckCardModalMinMax
({
min
:
1
,
max
:
1
}));
dispatch
(
setCheckCardModalMinMax
({
min
:
1
,
max
:
1
}));
dispatch
(
setCheckCardModalOnSubmit
(
"
sendSelectChainResponse
"
));
dispatch
(
setCheckCardModalOnSubmit
(
"
sendSelectChainResponse
"
));
dispatch
(
setCheckCardMOdalCancelAble
(
!
forced
));
dispatch
(
setCheckCardModalCancelResponse
(
-
1
));
for
(
const
chain
of
chains
)
{
for
(
const
chain
of
chains
)
{
const
tagName
=
CardZoneToChinese
(
chain
.
location
.
location
);
const
tagName
=
CardZoneToChinese
(
chain
.
location
.
location
);
...
...
src/ui/Duel/checkCardModal.tsx
View file @
9c34b487
...
@@ -2,6 +2,8 @@ import React, { useState } from "react";
...
@@ -2,6 +2,8 @@ import React, { useState } from "react";
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
store
}
from
"
../../store
"
;
import
{
store
}
from
"
../../store
"
;
import
{
import
{
selectCheckCardModalCacnelResponse
,
selectCheckCardModalCancelAble
,
selectCheckCardModalIsOpen
,
selectCheckCardModalIsOpen
,
selectCheckCardModalMinMax
,
selectCheckCardModalMinMax
,
selectCheckCardModalOnSubmit
,
selectCheckCardModalOnSubmit
,
...
@@ -24,38 +26,63 @@ const CheckCardModal = () => {
...
@@ -24,38 +26,63 @@ const CheckCardModal = () => {
const
{
min
,
max
}
=
useAppSelector
(
selectCheckCardModalMinMax
);
const
{
min
,
max
}
=
useAppSelector
(
selectCheckCardModalMinMax
);
const
tabs
=
useAppSelector
(
selectCheckCardModalTags
);
const
tabs
=
useAppSelector
(
selectCheckCardModalTags
);
const
onSubmit
=
useAppSelector
(
selectCheckCardModalOnSubmit
);
const
onSubmit
=
useAppSelector
(
selectCheckCardModalOnSubmit
);
const
cancelAble
=
useAppSelector
(
selectCheckCardModalCancelAble
);
const
cancelResponse
=
useAppSelector
(
selectCheckCardModalCacnelResponse
);
const
[
response
,
setResponse
]
=
useState
<
number
[]
>
([]);
const
[
response
,
setResponse
]
=
useState
<
number
[]
>
([]);
const
defaultValue
:
number
[]
=
[];
const
defaultValue
:
number
[]
=
[];
// TODO: 这里可以考虑更好地封装
const
sendResponseHandler
=
(
handlerName
:
string
|
undefined
,
response
:
number
[]
)
=>
{
switch
(
handlerName
)
{
case
"
sendSelectChainResponse
"
:
{
sendSelectChainResponse
(
response
[
0
]);
break
;
}
case
"
sendSelectCardResponse
"
:
{
sendSelectCardResponse
(
response
);
break
;
}
default
:
{
}
}
};
return
(
return
(
<
Modal
<
Modal
title=
{
`请选择${min}到${max}张卡片`
}
title=
{
`请选择${min}到${max}张卡片`
}
open=
{
isOpen
}
open=
{
isOpen
}
closable=
{
false
}
closable=
{
false
}
footer=
{
footer=
{
<
Button
<>
disabled=
{
response
.
length
<
min
||
response
.
length
>
max
}
<
Button
onClick=
{
()
=>
{
disabled=
{
response
.
length
<
min
||
response
.
length
>
max
}
switch
(
onSubmit
)
{
onClick=
{
()
=>
{
case
"
sendSelectChainResponse
"
:
{
sendResponseHandler
(
onSubmit
,
response
);
sendSelectChainResponse
(
response
[
0
]);
dispatch
(
setCheckCardModalIsOpen
(
false
));
dispatch
(
resetCheckCardModal
());
break
;
}
}
}
>
case
"
sendSelectCardResponse
"
:
{
submit
sendSelectCardResponse
(
response
);
</
Button
>
{
cancelAble
?
(
break
;
<
Button
}
onClick=
{
()
=>
{
default
:
{
if
(
cancelResponse
)
{
}
sendResponseHandler
(
onSubmit
,
[
cancelResponse
]);
}
}
dispatch
(
setCheckCardModalIsOpen
(
false
));
dispatch
(
setCheckCardModalIsOpen
(
false
));
dispatch
(
resetCheckCardModal
());
dispatch
(
resetCheckCardModal
());
}
}
}
}
>
>
submit
cancel
</
Button
>
</
Button
>
)
:
(
<></>
)
}
</>
}
}
width=
{
800
}
width=
{
800
}
>
>
...
...
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