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
a1013c25
Commit
a1013c25
authored
Mar 19, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add updateCardData
parent
bb56f260
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+43
-0
No files found.
src/reducers/duel/generic.ts
View file @
a1013c25
...
...
@@ -8,6 +8,7 @@ import { CardMeta } from "../../api/cards";
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
UpdateDataAction
=
ygopro
.
StocGameMessage
.
MsgUpdateData
.
Action
;
export
type
DuelReducer
<
T
>
=
CaseReducer
<
DuelState
,
PayloadAction
<
T
>>
;
...
...
@@ -283,3 +284,45 @@ export function setPosition<T extends DuelFieldState>(
target
.
location
.
position
=
position
;
}
}
export
function
updateCardData
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
actions
:
UpdateDataAction
[]
)
{
for
(
const
action
of
actions
)
{
const
payload
=
action
.
toObject
();
const
sequence
=
payload
.
location
?.
sequence
;
if
(
typeof
sequence
!==
"
undefined
"
)
{
const
target
=
state
?.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
&&
target
.
occupant
)
{
const
occupant
=
target
.
occupant
;
// 目前只更新以下字段
if
(
payload
.
code
!==
undefined
)
{
occupant
.
id
=
payload
.
code
;
occupant
.
text
.
id
=
payload
.
code
;
}
if
(
payload
.
location
!==
undefined
)
{
target
.
location
.
position
=
payload
.
location
.
position
;
}
if
(
payload
.
type_
!==
undefined
)
{
occupant
.
data
.
type
=
payload
.
type_
;
}
if
(
payload
.
level
!==
undefined
)
{
occupant
.
data
.
level
=
payload
.
level
;
}
if
(
payload
.
attribute
!==
undefined
)
{
occupant
.
data
.
attribute
=
payload
.
attribute
;
}
if
(
payload
.
race
!==
undefined
)
{
occupant
.
data
.
race
=
payload
.
race
;
}
if
(
payload
.
attack
!==
undefined
)
{
occupant
.
data
.
atk
=
payload
.
attack
;
}
if
(
payload
.
defense
!==
undefined
)
{
occupant
.
data
.
def
=
payload
.
defense
;
}
}
}
}
}
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