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
1a5e0584
Commit
1a5e0584
authored
Jan 22, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/select_card' into 'main'
Fix/select card See merge request
mycard/Neos!89
parents
b8eca8c7
e1585af1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
12 deletions
+90
-12
src/reducers/duel/modal/checkCardModalSlice.ts
src/reducers/duel/modal/checkCardModalSlice.ts
+29
-11
src/reducers/duel/util.ts
src/reducers/duel/util.ts
+55
-0
src/service/duel/selectCard.ts
src/service/duel/selectCard.ts
+6
-1
No files found.
src/reducers/duel/modal/checkCardModalSlice.ts
View file @
1a5e0584
...
@@ -6,8 +6,9 @@ import {
...
@@ -6,8 +6,9 @@ import {
}
from
"
@reduxjs/toolkit
"
;
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
judgeSelf
}
from
"
../util
"
;
import
{
findCardByLocation
,
judgeSelf
}
from
"
../util
"
;
import
{
fetchCard
,
getCardStr
}
from
"
../../../api/cards
"
;
import
{
fetchCard
,
getCardStr
}
from
"
../../../api/cards
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
// 更新卡牌选择弹窗打开状态
// 更新卡牌选择弹窗打开状态
export
const
setCheckCardModalIsOpenImpl
:
CaseReducer
<
export
const
setCheckCardModalIsOpenImpl
:
CaseReducer
<
...
@@ -56,7 +57,13 @@ export const fetchCheckCardMeta = createAsyncThunk(
...
@@ -56,7 +57,13 @@ export const fetchCheckCardMeta = createAsyncThunk(
async
(
param
:
{
async
(
param
:
{
controler
:
number
;
controler
:
number
;
tagName
:
string
;
tagName
:
string
;
option
:
{
code
:
number
;
response
:
number
;
effectDescCode
?:
number
};
option
:
{
code
:
number
;
zone
?:
ygopro
.
CardZone
;
sequence
?:
number
;
response
:
number
;
effectDescCode
?:
number
;
};
})
=>
{
})
=>
{
const
meta
=
await
fetchCard
(
param
.
option
.
code
,
true
);
const
meta
=
await
fetchCard
(
param
.
option
.
code
,
true
);
const
effectDesc
=
param
.
option
.
effectDescCode
const
effectDesc
=
param
.
option
.
effectDescCode
...
@@ -84,23 +91,34 @@ export const checkCardModalCase = (
...
@@ -84,23 +91,34 @@ export const checkCardModalCase = (
const
controler
=
action
.
meta
.
arg
.
controler
;
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
zone
=
action
.
meta
.
arg
.
option
.
zone
;
const
sequence
=
action
.
meta
.
arg
.
option
.
sequence
;
const
response
=
action
.
meta
.
arg
.
option
.
response
;
const
response
=
action
.
meta
.
arg
.
option
.
response
;
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
const
combinedTagName
=
judgeSelf
(
controler
,
state
)
?
`我方的
${
tagName
}
`
?
`我方的
${
tagName
}
`
:
`对方的
${
tagName
}
`
;
:
`对方的
${
tagName
}
`
;
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
const
newID
=
if
(
tag
.
tagName
===
combinedTagName
)
{
code
!=
0
tag
.
options
.
push
({
code
,
response
});
?
code
return
;
:
zone
&&
sequence
?
findCardByLocation
(
state
,
controler
,
zone
,
sequence
)?.
occupant
?.
id
:
undefined
;
if
(
newID
)
{
for
(
const
tag
of
state
.
modalState
.
checkCardModal
.
tags
)
{
if
(
tag
.
tagName
===
combinedTagName
)
{
tag
.
options
.
push
({
code
:
newID
,
response
});
return
;
}
}
}
}
state
.
modalState
.
checkCardModal
.
tags
.
push
({
state
.
modalState
.
checkCardModal
.
tags
.
push
({
tagName
:
combinedTagName
,
tagName
:
combinedTagName
,
options
:
[{
code
,
response
}],
options
:
[{
code
:
newID
,
response
}],
});
});
}
});
});
builder
.
addCase
(
fetchCheckCardMeta
.
fulfilled
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchCheckCardMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
controler
=
action
.
payload
.
controler
;
...
...
src/reducers/duel/util.ts
View file @
1a5e0584
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
Draft
}
from
"
@reduxjs/toolkit
"
;
import
{
Draft
}
from
"
@reduxjs/toolkit
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
CardState
}
from
"
./generic
"
;
/*
/*
* 通过`player`和`selfType`判断是应该处理自己还是对手
* 通过`player`和`selfType`判断是应该处理自己还是对手
...
@@ -22,3 +24,56 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
...
@@ -22,3 +24,56 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
return
false
;
return
false
;
}
}
}
}
/*
* 通过`controler`,`zone`和`sequence`获取卡牌状态*/
export
function
findCardByLocation
(
state
:
Draft
<
DuelState
>
,
controler
:
number
,
zone
:
ygopro
.
CardZone
,
sequence
:
number
):
CardState
|
undefined
{
const
finder
=
(
_
:
any
,
idx
:
number
)
=>
idx
==
sequence
;
switch
(
zone
)
{
case
ygopro
.
CardZone
.
HAND
:
{
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
return
hands
?.
inner
.
find
(
finder
);
}
case
ygopro
.
CardZone
.
MZONE
:
{
const
monsters
=
judgeSelf
(
controler
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
return
monsters
?.
inner
.
find
(
finder
);
}
case
ygopro
.
CardZone
.
SZONE
:
{
const
magics
=
judgeSelf
(
controler
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
return
magics
?.
inner
.
find
(
finder
);
}
case
ygopro
.
CardZone
.
REMOVED
:
{
const
exclusions
=
judgeSelf
(
controler
,
state
)
?
state
.
meExclusion
:
state
.
opExclusion
;
return
exclusions
?.
inner
.
find
(
finder
);
}
case
ygopro
.
CardZone
.
GRAVE
:
{
const
cemerety
=
judgeSelf
(
controler
,
state
)
?
state
.
meCemetery
:
state
.
opCemetery
;
return
cemerety
?.
inner
.
find
(
finder
);
}
case
ygopro
.
CardZone
.
ONFIELD
:
{
const
field
=
judgeSelf
(
controler
,
state
)
?
state
.
meField
:
state
.
opField
;
if
(
sequence
==
0
)
{
return
field
?.
inner
;
}
else
{
return
undefined
;
}
}
default
:
{
return
undefined
;
}
}
}
src/service/duel/selectCard.ts
View file @
1a5e0584
...
@@ -25,7 +25,12 @@ export default (selectCard: MsgSelectCard, dispatch: AppDispatch) => {
...
@@ -25,7 +25,12 @@ export default (selectCard: MsgSelectCard, dispatch: AppDispatch) => {
fetchCheckCardMeta
({
fetchCheckCardMeta
({
controler
:
card
.
location
.
controler
,
controler
:
card
.
location
.
controler
,
tagName
,
tagName
,
option
:
{
code
:
card
.
code
,
response
:
card
.
response
},
option
:
{
code
:
card
.
code
,
zone
:
card
.
location
.
location
,
sequence
:
card
.
location
.
sequence
,
response
:
card
.
response
,
},
})
})
);
);
}
}
...
...
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