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
c3751b96
Commit
c3751b96
authored
Apr 05, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udpate hintSlice
parent
0ac4295b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
17 deletions
+53
-17
src/reducers/duel/hintSlice.ts
src/reducers/duel/hintSlice.ts
+52
-14
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+1
-3
No files found.
src/reducers/duel/hintSlice.ts
View file @
c3751b96
...
...
@@ -2,9 +2,10 @@ import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit";
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
DESCRIPTION_LIMIT
,
fetchStrings
,
getStrings
}
from
"
../../api/strings
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
findCardByLocation
,
judgeSelf
}
from
"
./util
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
DuelReducer
}
from
"
./generic
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
export
interface
HintState
{
code
:
number
;
...
...
@@ -23,19 +24,6 @@ export const initHintImpl: DuelReducer<number> = (state, action) => {
}
};
export
const
setEsHintImpl
:
DuelReducer
<
{
player
:
number
;
esHint
:
string
}
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
esHint
=
action
.
payload
.
esHint
;
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opHint
;
if
(
hint
)
{
hint
.
esHint
=
esHint
;
}
};
export
const
fetchCommonHintMeta
=
createAsyncThunk
(
"
duel/fetchCommonHintMeta
"
,
async
(
param
:
[
number
,
number
])
=>
{
...
...
@@ -79,6 +67,32 @@ export const fetchSelectHintMeta = createAsyncThunk(
}
);
export
const
fetchEsHintMeta
=
createAsyncThunk
(
"
duel/fetchEsHintMeta
"
,
async
(
param
:
{
player
:
number
;
originMsg
:
string
|
number
;
location
?:
ygopro
.
CardLocation
;
cardID
?:
number
;
})
=>
{
const
player
=
param
.
player
;
const
originMsg
=
typeof
param
.
originMsg
===
"
string
"
?
param
.
originMsg
:
fetchStrings
(
"
!system
"
,
param
.
originMsg
);
const
location
=
param
.
location
;
if
(
param
.
cardID
)
{
const
cardMeta
=
await
fetchCard
(
param
.
cardID
);
return
{
player
,
originMsg
,
cardMeta
,
location
};
}
else
{
return
{
player
,
originMsg
,
location
};
}
}
);
export
const
hintCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchCommonHintMeta
.
pending
,
(
state
,
action
)
=>
{
const
player
=
action
.
meta
.
arg
[
0
];
...
...
@@ -125,6 +139,30 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
}
}
});
builder
.
addCase
(
fetchEsHintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
originMsg
=
action
.
payload
.
originMsg
;
const
cardMeta
=
action
.
payload
.
cardMeta
;
const
location
=
action
.
payload
.
location
;
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opHint
;
if
(
hint
)
{
let
esHint
=
originMsg
;
if
(
cardMeta
?.
text
.
name
)
{
esHint
=
originMsg
.
replace
(
"
[?]
"
,
cardMeta
.
text
.
name
);
}
if
(
location
)
{
const
fieldMeta
=
findCardByLocation
(
state
,
location
);
if
(
fieldMeta
?.
occupant
?.
text
.
name
)
{
esHint
=
originMsg
.
replace
(
"
[?]
"
,
fieldMeta
.
occupant
.
text
.
name
);
}
}
hint
.
esHint
=
esHint
;
}
});
};
export
const
selectMeHint
=
(
state
:
RootState
)
=>
state
.
duel
.
meHint
;
...
...
src/reducers/duel/mod.ts
View file @
c3751b96
...
...
@@ -23,7 +23,7 @@ import {
setEnableEpImpl
,
}
from
"
./phaseSlice
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
HintState
,
hintCase
,
initHintImpl
,
setEsHintImpl
}
from
"
./hintSlice
"
;
import
{
HintState
,
hintCase
,
initHintImpl
}
from
"
./hintSlice
"
;
import
{
ModalState
,
setCardModalIsOpenImpl
,
...
...
@@ -298,7 +298,6 @@ const duelSlice = createSlice({
// 提示相关`Reducer`
initHint
:
initHintImpl
,
setEsHint
:
setEsHintImpl
,
// 通用的`Reducer`
clearAllIdleInteractivities
:
clearAllIdleInteractivitiesImpl
,
...
...
@@ -418,7 +417,6 @@ export const {
setSortCardModalIsOpen
,
resetSortCardModal
,
initHint
,
setEsHint
,
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
return
state
.
duel
.
meInitInfo
!=
null
;
...
...
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