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
d174c541
Commit
d174c541
authored
Dec 21, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Modal Reducer
parent
47fab419
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
1 deletion
+69
-1
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+19
-1
src/reducers/duel/modal.ts
src/reducers/duel/modal.ts
+50
-0
No files found.
src/reducers/duel/mod.ts
View file @
d174c541
...
...
@@ -15,6 +15,12 @@ import {
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
import
{
newPhaseImpl
}
from
"
./phaseSlice
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
ModalState
,
setCardModalIsOpenImpl
,
setCardModalTextImpl
,
setCardModalImgUrlImpl
,
}
from
"
./modal
"
;
export
interface
DuelState
{
selfType
?:
number
;
...
...
@@ -26,9 +32,16 @@ export interface DuelState {
opTimeLimit
?:
TimeLimit
;
// 对手的计时
currentPlayer
?:
number
;
// 当前的操作方
currentPhase
?:
string
;
// 当前的阶段
// UI相关
modalState
:
ModalState
;
}
const
initialState
:
DuelState
=
{};
const
initialState
:
DuelState
=
{
modalState
:
{
cardModal
:
{
isOpen
:
false
},
},
};
const
duelSlice
=
createSlice
({
name
:
"
duel
"
,
...
...
@@ -45,6 +58,11 @@ const duelSlice = createSlice({
// 手牌相关`Reducer`
clearHandsInteractivity
:
clearHandsInteractivityImpl
,
addHandsInteractivity
:
addHandsInteractivityImpl
,
// UI相关`Reducer`
setCardModalIsOpen
:
setCardModalIsOpenImpl
,
setCardModalText
:
setCardModalTextImpl
,
setCardModalImgUrl
:
setCardModalImgUrlImpl
,
},
extraReducers
(
builder
)
{
handsCase
(
builder
);
...
...
src/reducers/duel/modal.ts
0 → 100644
View file @
d174c541
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
DuelState
}
from
"
./mod
"
;
export
interface
ModalState
{
// 卡牌弹窗
cardModal
:
{
isOpen
:
boolean
;
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
;
};
}
// 更新卡牌弹窗打开状态
export
const
setCardModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
isOpen
=
action
.
payload
;
};
// 更新卡牌弹窗文本
export
const
setCardModalTextImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
[
string
?,
string
?]
>
>
=
(
state
,
action
)
=>
{
const
name
=
action
.
payload
[
0
];
const
desc
=
action
.
payload
[
1
];
state
.
modalState
.
cardModal
.
name
=
name
;
state
.
modalState
.
cardModal
.
desc
=
desc
;
};
// 更新卡牌弹窗图片Url
export
const
setCardModalImgUrlImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
string
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
imgUrl
=
action
.
payload
;
};
export
const
selectCardModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
isOpen
;
export
const
selectCardModalName
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
name
;
export
const
selectCardModalDesc
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
desc
;
export
const
selectCardModalImgUrl
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
imgUrl
;
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