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
c7f3bbcf
Commit
c7f3bbcf
authored
Jan 15, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update hand slice and service
parent
e28b64d3
Pipeline
#19527
passed with stages
in 3 minutes and 11 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
12 deletions
+55
-12
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+15
-0
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+36
-11
src/service/duel/shuffleHand.ts
src/service/duel/shuffleHand.ts
+4
-1
No files found.
src/reducers/duel/generic.ts
View file @
c7f3bbcf
...
...
@@ -209,3 +209,18 @@ export function insertCard<T extends DuelFieldState>(
state
.
inner
.
splice
(
sequence
,
0
,
card
);
}
}
export
function
updateCardMeta
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
metas
:
CardMeta
[]
)
{
if
(
state
)
{
state
.
inner
.
forEach
((
item
)
=>
{
metas
.
forEach
((
meta
)
=>
{
if
(
item
.
occupant
?.
id
===
meta
.
id
)
{
item
.
occupant
=
meta
;
}
});
});
}
}
src/reducers/duel/handsSlice.ts
View file @
c7f3bbcf
...
...
@@ -14,6 +14,7 @@ import {
insertCard
,
extendMeta
,
createAsyncRepeatedMetaThunk
,
updateCardMeta
,
}
from
"
./generic
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
...
...
@@ -74,19 +75,22 @@ export const removeHandImpl: CaseReducer<
export
const
insertHandMeta
=
createAsyncMetaThunk
(
"
duel/insertHandMeta
"
);
export
const
updateHandsMeta
=
createAsyncRepeatedMetaThunk
(
"
duel/updateHandsMeta
"
);
export
const
handsCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchHandsMeta
.
pending
,
(
state
,
action
)
=>
{
// Meta结果没返回之前先更新手牌`ID`
const
player
=
action
.
meta
.
arg
.
controler
;
const
ids
=
action
.
meta
.
arg
.
codes
;
const
cards
=
ids
.
map
((
id
,
idx
)
=>
{
const
cards
=
ids
.
map
((
id
)
=>
{
return
{
occupant
:
{
id
,
data
:
{},
text
:
{}
},
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
HAND
,
sequence
:
idx
,
},
idleInteractivities
:
[],
};
...
...
@@ -111,15 +115,7 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
const
metas
=
action
.
payload
.
metas
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
for
(
let
hand
of
hands
.
inner
)
{
for
(
let
meta
of
metas
)
{
if
(
hand
.
occupant
?.
id
===
meta
.
id
)
{
hand
.
occupant
=
meta
;
}
}
}
}
updateCardMeta
(
hands
,
metas
);
});
builder
.
addCase
(
insertHandMeta
.
pending
,
(
state
,
action
)
=>
{
...
...
@@ -144,6 +140,35 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
extendMeta
(
hands
,
meta
,
sequence
);
});
builder
.
addCase
(
updateHandsMeta
.
pending
,
(
state
,
action
)
=>
{
const
controler
=
action
.
meta
.
arg
.
controler
;
const
codes
=
action
.
meta
.
arg
.
codes
;
const
metas
=
codes
.
map
((
code
)
=>
{
return
{
occupant
:
{
id
:
code
,
data
:
{},
text
:
{}
},
location
:
{
controler
,
location
:
ygopro
.
CardZone
.
HAND
,
},
idleInteractivities
:
[],
};
});
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
hands
.
inner
=
metas
;
}
});
builder
.
addCase
(
updateHandsMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
metas
=
action
.
payload
.
metas
;
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
updateCardMeta
(
hands
,
metas
);
});
};
// 在特定位置增加手牌
...
...
src/service/duel/shuffleHand.ts
View file @
c7f3bbcf
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
updateHandsMeta
}
from
"
../../reducers/duel/handsSlice
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgShuffleHand
=
ygopro
.
StocGameMessage
.
MsgShuffleHand
;
export
default
(
shuffleHand
:
MsgShuffleHand
,
dispatch
:
AppDispatch
)
=>
{
console
.
log
(
shuffleHand
);
dispatch
(
updateHandsMeta
({
controler
:
shuffleHand
.
player
,
codes
:
shuffleHand
.
hands
})
);
};
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