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
ac124f5c
Commit
ac124f5c
authored
Dec 24, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hint reducer
parent
54891cf8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
src/reducers/duel/hint.ts
src/reducers/duel/hint.ts
+48
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+4
-0
No files found.
src/reducers/duel/hint.ts
0 → 100644
View file @
ac124f5c
import
{
createAsyncThunk
,
ActionReducerMapBuilder
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchStrings
}
from
"
../../api/strings
"
;
import
{
judgeSelf
}
from
"
./util
"
;
export
interface
HintState
{
code
:
number
;
msg
?:
string
;
}
export
const
fetchHintMeta
=
createAsyncThunk
(
"
duel/fetchHintMeta
"
,
async
(
param
:
[
number
,
number
])
=>
{
const
player
=
param
[
0
];
const
hintData
=
param
[
1
];
const
hintMeta
=
await
fetchStrings
(
"
!system
"
,
hintData
);
const
response
:
[
number
,
string
]
=
[
player
,
hintMeta
];
return
response
;
}
);
export
const
hintCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchHintMeta
.
pending
,
(
state
,
action
)
=>
{
const
player
=
action
.
meta
.
arg
[
0
];
const
code
=
action
.
meta
.
arg
[
1
];
if
(
judgeSelf
(
player
,
state
))
{
state
.
meHint
=
{
code
};
}
else
{
state
.
opHint
=
{
code
};
}
});
builder
.
addCase
(
fetchHintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
hintMeta
=
action
.
payload
[
1
];
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opHint
;
if
(
hint
)
{
hint
.
msg
=
hintMeta
;
}
});
};
export
const
selectMeHint
=
(
state
:
RootState
)
=>
state
.
duel
.
meHint
||
""
;
export
const
selectOpHint
=
(
state
:
RootState
)
=>
state
.
duel
.
opHint
||
""
;
src/reducers/duel/mod.ts
View file @
ac124f5c
...
@@ -15,6 +15,7 @@ import {
...
@@ -15,6 +15,7 @@ import {
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
import
{
newPhaseImpl
}
from
"
./phaseSlice
"
;
import
{
newPhaseImpl
}
from
"
./phaseSlice
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
HintState
,
hintCase
}
from
"
./hint
"
;
import
{
import
{
ModalState
,
ModalState
,
setCardModalIsOpenImpl
,
setCardModalIsOpenImpl
,
...
@@ -31,6 +32,8 @@ export interface DuelState {
...
@@ -31,6 +32,8 @@ export interface DuelState {
opHands
?:
Hands
;
// 对手的手牌
opHands
?:
Hands
;
// 对手的手牌
meTimeLimit
?:
TimeLimit
;
// 自己的计时
meTimeLimit
?:
TimeLimit
;
// 自己的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
meHint
?:
HintState
;
// 自己的提示
opHint
?:
HintState
;
// 对手的提示
currentPlayer
?:
number
;
// 当前的操作方
currentPlayer
?:
number
;
// 当前的操作方
currentPhase
?:
string
;
// 当前的阶段
currentPhase
?:
string
;
// 当前的阶段
...
@@ -68,6 +71,7 @@ const duelSlice = createSlice({
...
@@ -68,6 +71,7 @@ const duelSlice = createSlice({
},
},
extraReducers
(
builder
)
{
extraReducers
(
builder
)
{
handsCase
(
builder
);
handsCase
(
builder
);
hintCase
(
builder
);
},
},
});
});
...
...
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