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
5c298ffe
Commit
5c298ffe
authored
Jan 02, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update select card service
parent
c6bdbcaa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
4 deletions
+83
-4
src/reducers/duel/modalSlice.ts
src/reducers/duel/modalSlice.ts
+15
-2
src/service/duel/selectCard.ts
src/service/duel/selectCard.ts
+26
-2
src/service/duel/util.ts
src/service/duel/util.ts
+42
-0
No files found.
src/reducers/duel/modalSlice.ts
View file @
5c298ffe
...
@@ -7,6 +7,7 @@ import {
...
@@ -7,6 +7,7 @@ import {
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
judgeSelf
}
from
"
./util
"
;
export
interface
ModalState
{
export
interface
ModalState
{
// 卡牌弹窗
// 卡牌弹窗
...
@@ -118,11 +119,13 @@ export const setCheckCardModalMinMaxImpl: CaseReducer<
...
@@ -118,11 +119,13 @@ export const setCheckCardModalMinMaxImpl: CaseReducer<
export
const
fetchCheckCardMeta
=
createAsyncThunk
(
export
const
fetchCheckCardMeta
=
createAsyncThunk
(
"
duel/fetchCheckCardMeta
"
,
"
duel/fetchCheckCardMeta
"
,
async
(
param
:
{
async
(
param
:
{
controler
:
number
;
tagName
:
string
;
tagName
:
string
;
option
:
{
code
:
number
;
response
:
number
};
option
:
{
code
:
number
;
response
:
number
};
})
=>
{
})
=>
{
const
meta
=
await
fetchCard
(
param
.
option
.
code
);
const
meta
=
await
fetchCard
(
param
.
option
.
code
);
const
response
=
{
const
response
=
{
controler
:
param
.
controler
,
tagName
:
param
.
tagName
,
tagName
:
param
.
tagName
,
meta
:
{
meta
:
{
code
:
meta
.
id
,
code
:
meta
.
id
,
...
@@ -139,12 +142,17 @@ export const checkCardModalCase = (
...
@@ -139,12 +142,17 @@ export const checkCardModalCase = (
builder
:
ActionReducerMapBuilder
<
DuelState
>
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
)
=>
{
builder
.
addCase
(
fetchCheckCardMeta
.
pending
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchCheckCardMeta
.
pending
,
(
state
,
action
)
=>
{
const
controler
=
action
.
meta
.
arg
.
controler
;
const
tagName
=
action
.
meta
.
arg
.
tagName
;
const
tagName
=
action
.
meta
.
arg
.
tagName
;
const
code
=
action
.
meta
.
arg
.
option
.
code
;
const
code
=
action
.
meta
.
arg
.
option
.
code
;
const
response
=
action
.
meta
.
arg
.
option
.
response
;
const
response
=
action
.
meta
.
arg
.
option
.
response
;
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
?
`我方的
${
tagName
}
`
:
`对方的
${
tagName
}
`
;
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
if
(
tag
.
tagName
===
t
agName
)
{
if
(
tag
.
tagName
===
combinedT
agName
)
{
tag
.
options
.
push
({
code
,
response
});
tag
.
options
.
push
({
code
,
response
});
return
;
return
;
}
}
...
@@ -156,11 +164,16 @@ export const checkCardModalCase = (
...
@@ -156,11 +164,16 @@ export const checkCardModalCase = (
});
});
});
});
builder
.
addCase
(
fetchCheckCardMeta
.
fulfilled
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchCheckCardMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
tagName
=
action
.
payload
.
tagName
;
const
tagName
=
action
.
payload
.
tagName
;
const
meta
=
action
.
payload
.
meta
;
const
meta
=
action
.
payload
.
meta
;
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
?
`我方的
${
tagName
}
`
:
`对方的
${
tagName
}
`
;
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
if
(
tag
.
tagName
===
t
agName
)
{
if
(
tag
.
tagName
===
combinedT
agName
)
{
for
(
const
option
of
tag
.
options
)
{
for
(
const
option
of
tag
.
options
)
{
if
(
option
.
code
==
meta
.
code
)
{
if
(
option
.
code
==
meta
.
code
)
{
option
.
name
=
meta
.
name
;
option
.
name
=
meta
.
name
;
...
...
src/service/duel/selectCard.ts
View file @
5c298ffe
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
setCheckCardModalIsOpen
,
setCheckCardModalMinMax
,
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchCheckCardMeta
}
from
"
../../reducers/duel/modalSlice
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
export
default
(
selectCard
:
MsgSelectCard
,
dispatch
:
AppDispatch
)
=>
{
export
default
(
selectCard
:
MsgSelectCard
,
dispatch
:
AppDispatch
)
=>
{
console
.
log
(
selectCard
);
const
_player
=
selectCard
.
player
;
// TODO
const
_cancelable
=
selectCard
.
cancelable
;
// TODO: 处理可取消逻辑
const
min
=
selectCard
.
min
;
const
max
=
selectCard
.
max
;
const
cards
=
selectCard
.
cards
;
dispatch
(
setCheckCardModalMinMax
({
min
,
max
}));
for
(
const
card
of
cards
)
{
const
tagName
=
CardZoneToChinese
(
card
.
location
.
location
);
dispatch
(
fetchCheckCardMeta
({
controler
:
card
.
location
.
controler
,
tagName
,
option
:
{
code
:
card
.
code
,
response
:
card
.
response
},
})
);
}
dispatch
(
setCheckCardModalIsOpen
(
true
));
};
};
src/service/duel/util.ts
0 → 100644
View file @
5c298ffe
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
export
function
CardZoneToChinese
(
zone
:
ygopro
.
CardZone
):
string
{
switch
(
zone
)
{
case
ygopro
.
CardZone
.
DECK
:
{
return
"
卡组
"
;
}
case
ygopro
.
CardZone
.
HAND
:
{
return
"
手牌
"
;
}
case
ygopro
.
CardZone
.
EXTRA
:
{
return
"
额外卡组
"
;
}
case
ygopro
.
CardZone
.
GRAVE
:
{
return
"
墓地
"
;
}
case
ygopro
.
CardZone
.
FZONE
:
{
return
"
FZONE
"
;
}
case
ygopro
.
CardZone
.
MZONE
:
{
return
"
怪兽区
"
;
}
case
ygopro
.
CardZone
.
SZONE
:
{
return
"
魔法陷阱区
"
;
}
case
ygopro
.
CardZone
.
REMOVED
:
{
return
"
除外区
"
;
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
return
"
超量区
"
;
}
case
ygopro
.
CardZone
.
PZONE
:
{
return
"
灵摆区
"
;
}
case
ygopro
.
CardZone
.
ONFIELD
:
{
return
"
场地区
"
;
}
default
:
{
return
"
未知区域
"
;
}
}
}
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