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
296eaf09
Commit
296eaf09
authored
Jan 22, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add findCardByLocation
parent
b8eca8c7
Pipeline
#19750
passed with stages
in 4 minutes and 58 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
src/reducers/duel/util.ts
src/reducers/duel/util.ts
+55
-0
No files found.
src/reducers/duel/util.ts
View file @
296eaf09
...
...
@@ -5,6 +5,8 @@
import
{
DuelState
}
from
"
./mod
"
;
import
{
Draft
}
from
"
@reduxjs/toolkit
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
CardState
}
from
"
./generic
"
;
/*
* 通过`player`和`selfType`判断是应该处理自己还是对手
...
...
@@ -22,3 +24,56 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
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
;
}
}
}
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