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
bc23ca62
Commit
bc23ca62
authored
Apr 05, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udpate hintSlice
parent
c3751b96
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
81 deletions
+37
-81
src/reducers/duel/hintSlice.ts
src/reducers/duel/hintSlice.ts
+19
-49
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+1
-2
src/service/duel/hint.ts
src/service/duel/hint.ts
+2
-3
src/service/duel/selectChain.ts
src/service/duel/selectChain.ts
+0
-1
src/service/duel/start.ts
src/service/duel/start.ts
+1
-2
src/ui/Duel/checkCardModal.tsx
src/ui/Duel/checkCardModal.tsx
+3
-3
src/ui/Duel/checkCardModalV2.tsx
src/ui/Duel/checkCardModalV2.tsx
+3
-3
src/ui/Duel/checkCardModalV3.tsx
src/ui/Duel/checkCardModalV3.tsx
+3
-3
src/ui/Duel/hintNotification.tsx
src/ui/Duel/hintNotification.tsx
+5
-15
No files found.
src/reducers/duel/hintSlice.ts
View file @
bc23ca62
...
...
@@ -2,7 +2,7 @@ import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit";
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
DESCRIPTION_LIMIT
,
fetchStrings
,
getStrings
}
from
"
../../api/strings
"
;
import
{
findCardByLocation
,
judgeSelf
}
from
"
./util
"
;
import
{
findCardByLocation
}
from
"
./util
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
DuelReducer
}
from
"
./generic
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
...
...
@@ -14,37 +14,20 @@ export interface HintState {
esSelectHint
?:
string
;
}
export
const
initHintImpl
:
DuelReducer
<
number
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
;
if
(
judgeSelf
(
player
,
state
))
{
state
.
meHint
=
{
code
:
0
};
}
else
{
state
.
opHint
=
{
code
:
0
};
}
export
const
initHintImpl
:
DuelReducer
<
void
>
=
(
state
)
=>
{
state
.
hint
=
{
code
:
0
};
};
export
const
fetchCommonHintMeta
=
createAsyncThunk
(
"
duel/fetchCommonHintMeta
"
,
async
(
param
:
[
number
,
number
])
=>
{
const
player
=
param
[
0
];
const
hintData
=
param
[
1
];
const
hintMeta
=
fetchStrings
(
"
!system
"
,
hintData
);
const
response
:
[
number
,
string
]
=
[
player
,
hintMeta
];
return
response
;
async
(
hintData
:
number
)
=>
{
return
fetchStrings
(
"
!system
"
,
hintData
);
}
);
export
const
fetchSelectHintMeta
=
createAsyncThunk
(
"
duel/fetchSelectHintMeta
"
,
async
(
param
:
{
player
:
number
;
selectHintData
:
number
;
esHint
?:
string
;
})
=>
{
const
player
=
param
.
player
;
async
(
param
:
{
selectHintData
:
number
;
esHint
?:
string
})
=>
{
const
selectHintData
=
param
.
selectHintData
;
let
selectHintMeta
=
""
;
...
...
@@ -60,7 +43,6 @@ export const fetchSelectHintMeta = createAsyncThunk(
}
return
{
player
,
selectHintMeta
,
esHint
:
param
.
esHint
,
};
...
...
@@ -70,12 +52,10 @@ 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
...
...
@@ -86,49 +66,41 @@ export const fetchEsHintMeta = createAsyncThunk(
if
(
param
.
cardID
)
{
const
cardMeta
=
await
fetchCard
(
param
.
cardID
);
return
{
player
,
originMsg
,
cardMeta
,
location
};
return
{
originMsg
,
cardMeta
,
location
};
}
else
{
return
{
player
,
originMsg
,
location
};
return
{
originMsg
,
location
};
}
}
);
export
const
hintCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchCommonHintMeta
.
pending
,
(
state
,
action
)
=>
{
const
player
=
action
.
meta
.
arg
[
0
];
const
code
=
action
.
meta
.
arg
[
1
];
const
code
=
action
.
meta
.
arg
;
if
(
judgeSelf
(
player
,
state
))
{
state
.
meHint
=
{
code
};
}
else
{
state
.
opHint
=
{
code
};
if
(
state
.
hint
)
{
state
.
hint
.
code
=
code
;
}
});
builder
.
addCase
(
fetchCommonHintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
hintMeta
=
action
.
payload
[
1
];
const
hintMeta
=
action
.
payload
;
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opHint
;
if
(
hint
)
{
hint
.
msg
=
hintMeta
;
if
(
state
.
hint
)
{
state
.
hint
.
msg
=
hintMeta
;
}
});
builder
.
addCase
(
fetchSelectHintMeta
.
pending
,
(
state
,
action
)
=>
{
const
player
=
action
.
meta
.
arg
.
player
;
const
code
=
action
.
meta
.
arg
.
selectHintData
;
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opHint
;
if
(
hint
)
{
hint
.
code
=
code
;
if
(
state
.
hint
)
{
state
.
hint
.
code
=
code
;
}
});
builder
.
addCase
(
fetchSelectHintMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
selectHintMsg
=
action
.
payload
.
selectHintMeta
;
const
esHint
=
action
.
payload
.
esHint
;
const
hint
=
judgeSelf
(
player
,
state
)
?
state
.
meHint
:
state
.
opH
int
;
const
hint
=
state
.
h
int
;
if
(
hint
)
{
if
(
hint
.
code
>
DESCRIPTION_LIMIT
)
{
// 针对`MSG_SELECT_PLACE`的特化逻辑
...
...
@@ -140,12 +112,11 @@ 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
.
opH
int
;
const
hint
=
state
.
h
int
;
if
(
hint
)
{
let
esHint
=
originMsg
;
...
...
@@ -165,5 +136,4 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
});
};
export
const
selectMeHint
=
(
state
:
RootState
)
=>
state
.
duel
.
meHint
;
export
const
selectOpHint
=
(
state
:
RootState
)
=>
state
.
duel
.
opHint
;
export
const
selectHint
=
(
state
:
RootState
)
=>
state
.
duel
.
hint
;
src/reducers/duel/mod.ts
View file @
bc23ca62
...
...
@@ -149,8 +149,7 @@ export interface DuelState {
meTimeLimit
?:
TimeLimit
;
// 自己的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
meHint
?:
HintState
;
// 自己的提示
opHint
?:
HintState
;
// 对手的提示
hint
?:
HintState
;
currentPlayer
?:
number
;
// 当前的操作方
...
...
src/service/duel/hint.ts
View file @
bc23ca62
...
...
@@ -7,15 +7,14 @@ import {
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
:
{
dispatch
(
fetchCommonHintMeta
(
[
player
,
hint
.
hint_data
]
));
dispatch
(
fetchCommonHintMeta
(
hint
.
hint_data
));
break
;
}
case
MsgHint
.
HintType
.
HINT_SELECTMSG
:
{
dispatch
(
fetchSelectHintMeta
({
player
,
selectHintData
:
hint
.
hint_data
}));
dispatch
(
fetchSelectHintMeta
({
selectHintData
:
hint
.
hint_data
}));
break
;
}
default
:
{
...
...
src/service/duel/selectChain.ts
View file @
bc23ca62
...
...
@@ -86,7 +86,6 @@ export default (selectChain: MsgSelectChain, dispatch: AppDispatch) => {
}
dispatch
(
fetchSelectHintMeta
({
player
,
selectHintData
:
203
,
})
);
...
...
src/service/duel/start.ts
View file @
bc23ca62
...
...
@@ -46,6 +46,5 @@ export default (
dispatch
(
initDeck
({
player
:
1
,
deskSize
:
start
.
deckSize2
}));
dispatch
(
initExclusion
(
0
));
dispatch
(
initExclusion
(
1
));
dispatch
(
initHint
(
0
));
dispatch
(
initHint
(
1
));
dispatch
(
initHint
());
};
src/ui/Duel/checkCardModal.tsx
View file @
bc23ca62
...
...
@@ -22,7 +22,7 @@ import {
import
{
ThunderboltOutlined
}
from
"
@ant-design/icons
"
;
import
NeosConfig
from
"
../../../neos.config.json
"
;
import
DragModal
from
"
./dragModal
"
;
import
{
select
Me
Hint
}
from
"
../../reducers/duel/hintSlice
"
;
import
{
selectHint
}
from
"
../../reducers/duel/hintSlice
"
;
const
CheckCardModal
=
()
=>
{
const
dispatch
=
store
.
dispatch
;
...
...
@@ -34,7 +34,7 @@ const CheckCardModal = () => {
const
cancelResponse
=
useAppSelector
(
selectCheckCardModalCacnelResponse
);
const
[
response
,
setResponse
]
=
useState
<
number
[]
>
([]);
const
defaultValue
:
number
[]
=
[];
const
selectHint
=
useAppSelector
(
selectMe
Hint
)?.
esSelectHint
||
"
请选择卡片
"
;
const
selectHint
Msg
=
useAppSelector
(
select
Hint
)?.
esSelectHint
||
"
请选择卡片
"
;
// TODO: 这里可以考虑更好地封装
const
sendResponseHandler
=
(
...
...
@@ -57,7 +57,7 @@ const CheckCardModal = () => {
return
(
<
DragModal
title=
{
`${selectHint} ${min}-${max}`
}
title=
{
`${selectHint
Msg
} ${min}-${max}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
...
...
src/ui/Duel/checkCardModalV2.tsx
View file @
bc23ca62
...
...
@@ -20,7 +20,7 @@ import {
}
from
"
../../reducers/duel/mod
"
;
import
NeosConfig
from
"
../../../neos.config.json
"
;
import
DragModal
from
"
./dragModal
"
;
import
{
select
Me
Hint
}
from
"
../../reducers/duel/hintSlice
"
;
import
{
selectHint
}
from
"
../../reducers/duel/hintSlice
"
;
const
CheckCardModalV2
=
()
=>
{
const
dispatch
=
store
.
dispatch
;
...
...
@@ -33,7 +33,7 @@ const CheckCardModalV2 = () => {
);
const
selectedOptions
=
useAppSelector
(
selectCheckCardModalV2SelectedOptions
);
const
responseable
=
useAppSelector
(
selectCheckCardModalV2ResponseAble
);
const
selectHint
=
useAppSelector
(
selectMe
Hint
)?.
esSelectHint
||
"
请选择卡片
"
;
const
selectHint
Msg
=
useAppSelector
(
select
Hint
)?.
esSelectHint
||
"
请选择卡片
"
;
const
onFinishOrCancel
=
()
=>
{
sendSelectUnselectCardResponse
({
cancel_or_finish
:
true
});
...
...
@@ -44,7 +44,7 @@ const CheckCardModalV2 = () => {
return
(
<
DragModal
title=
{
`${selectHint} ${min}-${max}`
}
title=
{
`${selectHint
Msg
} ${min}-${max}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
...
...
src/ui/Duel/checkCardModalV3.tsx
View file @
bc23ca62
...
...
@@ -12,7 +12,7 @@ import {
import
NeosConfig
from
"
../../../neos.config.json
"
;
import
{
selectCheckCardModalV3
}
from
"
../../reducers/duel/modal/checkCardModalV3Slice
"
;
import
DragModal
from
"
./dragModal
"
;
import
{
select
Me
Hint
}
from
"
../../reducers/duel/hintSlice
"
;
import
{
selectHint
}
from
"
../../reducers/duel/hintSlice
"
;
const
CheckCardModalV3
=
()
=>
{
const
dispatch
=
store
.
dispatch
;
...
...
@@ -33,7 +33,7 @@ const CheckCardModalV3 = () => {
.
concat
(
selectedOptions
)
.
map
((
option
)
=>
option
.
level2
)
.
reduce
((
sum
,
current
)
=>
sum
+
current
,
0
);
const
selectHint
=
useAppSelector
(
selectMe
Hint
)?.
esSelectHint
||
"
请选择卡片
"
;
const
selectHint
Msg
=
useAppSelector
(
select
Hint
)?.
esSelectHint
||
"
请选择卡片
"
;
const
responseable
=
(
overflow
...
...
@@ -52,7 +52,7 @@ const CheckCardModalV3 = () => {
return
(
<
DragModal
title=
{
`${selectHint} ${min}-${max}`
}
title=
{
`${selectHint
Msg
} ${min}-${max}`
}
open=
{
isOpen
}
closable=
{
false
}
footer=
{
...
...
src/ui/Duel/hintNotification.tsx
View file @
bc23ca62
import
React
,
{
useEffect
}
from
"
react
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
select
MeHint
,
selectOp
Hint
}
from
"
../../reducers/duel/hintSlice
"
;
import
{
selectHint
}
from
"
../../reducers/duel/hintSlice
"
;
import
{
selectCurrentPhase
}
from
"
../../reducers/duel/phaseSlice
"
;
import
{
notification
}
from
"
antd
"
;
import
{
selectDuelResult
,
selectWaiting
}
from
"
../../reducers/duel/mod
"
;
...
...
@@ -10,8 +10,7 @@ import MsgWin = ygopro.StocGameMessage.MsgWin;
import
NeosConfig
from
"
../../../neos.config.json
"
;
const
HintNotification
=
()
=>
{
const
meHint
=
useAppSelector
(
selectMeHint
);
const
opHint
=
useAppSelector
(
selectOpHint
);
const
hint
=
useAppSelector
(
selectHint
);
const
currentPhase
=
useAppSelector
(
selectCurrentPhase
);
const
waiting
=
useAppSelector
(
selectWaiting
);
const
result
=
useAppSelector
(
selectDuelResult
);
...
...
@@ -21,22 +20,13 @@ const HintNotification = () => {
maxCount
:
NeosConfig
.
ui
.
hint
.
maxCount
,
});
useEffect
(()
=>
{
if
(
meHint
&&
meH
int
.
msg
)
{
if
(
hint
&&
h
int
.
msg
)
{
api
.
info
({
message
:
`<我方>
${
meHint
.
msg
}
`
,
placement
:
"
bottom
"
,
});
}
},
[
meHint
?.
msg
]);
useEffect
(()
=>
{
if
(
opHint
&&
opHint
.
msg
)
{
api
.
info
({
message
:
`<对方>
${
opHint
.
msg
}
`
,
message
:
`
${
hint
.
msg
}
`
,
placement
:
"
top
"
,
});
}
},
[
opH
int
?.
msg
]);
},
[
h
int
?.
msg
]);
useEffect
(()
=>
{
if
(
currentPhase
)
{
...
...
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