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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
3a6ed8d6
Commit
3a6ed8d6
authored
Dec 25, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update hintSlice.ts
parent
2899ca4e
Pipeline
#18820
passed with stages
in 3 minutes and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
12 deletions
+53
-12
src/reducers/duel/hintSlice.ts
src/reducers/duel/hintSlice.ts
+44
-9
src/service/duel/hint.ts
src/service/duel/hint.ts
+9
-3
No files found.
src/reducers/duel/hintSlice.ts
View file @
3a6ed8d6
...
...
@@ -2,6 +2,7 @@ import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit";
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchStrings
}
from
"
../../api/strings
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
judgeSelf
}
from
"
./util
"
;
export
interface
HintState
{
...
...
@@ -9,17 +10,26 @@ export interface HintState {
msg
?:
string
;
}
export
const
fetchHintMeta
=
createAsyncThunk
(
"
duel/fetchHintMeta
"
,
export
const
fetch
Common
HintMeta
=
createAsyncThunk
(
"
duel/fetch
Common
HintMeta
"
,
async
(
param
:
[
number
,
number
])
=>
{
const
player
=
param
[
0
];
const
hintData
=
param
[
1
];
// TODO: 可以思考下这里怎么处理比较合理
const
hintMeta
=
hintData
<
10000
?
await
fetchStrings
(
"
!system
"
,
hintData
)
:
await
fetchStrings
(
"
!card
"
,
hintData
);
const
hintMeta
=
await
fetchStrings
(
"
!system
"
,
hintData
);
const
response
:
[
number
,
string
]
=
[
player
,
hintMeta
];
return
response
;
}
);
export
const
fetchSelectPlaceHintMeta
=
createAsyncThunk
(
"
duel/fetchSelectPlaceHintMeta
"
,
async
(
param
:
[
number
,
number
])
=>
{
const
player
=
param
[
0
];
const
hintData
=
param
[
1
];
const
hintMeta
=
(
await
fetchCard
(
hintData
)).
text
.
name
||
""
;
const
response
:
[
number
,
string
]
=
[
player
,
hintMeta
];
return
response
;
...
...
@@ -27,7 +37,7 @@ export const fetchHintMeta = createAsyncThunk(
);
export
const
hintCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchHintMeta
.
pending
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetch
Common
HintMeta
.
pending
,
(
state
,
action
)
=>
{
const
player
=
action
.
meta
.
arg
[
0
];
const
code
=
action
.
meta
.
arg
[
1
];
...
...
@@ -37,7 +47,7 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
state
.
opHint
=
{
code
};
}
});
builder
.
addCase
(
fetchHintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetch
Common
HintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
hintMeta
=
action
.
payload
[
1
];
...
...
@@ -46,6 +56,31 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
hint
.
msg
=
hintMeta
;
}
});
builder
.
addCase
(
fetchSelectPlaceHintMeta
.
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
(
fetchSelectPlaceHintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
hintMeta
=
action
.
payload
[
1
];
// TODO: 国际化文案
const
hintMsg
=
judgeSelf
(
player
,
state
)
?
`请为我方的<
${
hintMeta
}
>选择位置`
:
`请为对方的<
${
hintMeta
}
>选择位置`
;
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opHint
;
if
(
hint
)
{
hint
.
msg
=
hintMsg
;
}
});
};
export
const
selectMeHint
=
(
state
:
RootState
)
=>
state
.
duel
.
meHint
;
...
...
src/service/duel/hint.ts
View file @
3a6ed8d6
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
fetchHintMeta
}
from
"
../../reducers/duel/hintSlice
"
;
import
{
fetchCommonHintMeta
,
fetchSelectPlaceHintMeta
,
}
from
"
../../reducers/duel/hintSlice
"
;
import
MsgHint
=
ygopro
.
StocGameMessage
.
MsgHint
;
export
default
(
hint
:
MsgHint
,
dispatch
:
AppDispatch
)
=>
{
const
player
=
hint
.
player
;
switch
(
hint
.
hint_type
)
{
case
MsgHint
.
HintType
.
HINT_EVENT
:
case
MsgHint
.
HintType
.
HINT_MESSAGE
:
case
MsgHint
.
HintType
.
HINT_MESSAGE
:
{
dispatch
(
fetchCommonHintMeta
([
player
,
hint
.
hint_data
]));
break
;
}
case
MsgHint
.
HintType
.
HINT_SELECTMSG
:
{
dispatch
(
fetchHintMeta
([
player
,
hint
.
hint_data
]));
dispatch
(
fetch
SelectPlace
HintMeta
([
player
,
hint
.
hint_data
]));
break
;
}
default
:
{
...
...
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