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
86e4e7f3
Commit
86e4e7f3
authored
Mar 19, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish handling MsgUpdateData
parent
a1013c25
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
1 deletion
+65
-1
src/reducers/duel/commonSlice.ts
src/reducers/duel/commonSlice.ts
+60
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+3
-0
src/service/duel/updateData.ts
src/service/duel/updateData.ts
+2
-1
No files found.
src/reducers/duel/commonSlice.ts
View file @
86e4e7f3
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
clearIdleInteractivities
,
clearPlaceInteractivities
,
DuelReducer
,
updateCardData
,
}
from
"
./generic
"
;
import
{
judgeSelf
}
from
"
./util
"
;
...
...
@@ -56,3 +58,61 @@ export const clearAllPlaceInteractivitiesImpl: DuelReducer<number> = (
states
.
forEach
((
item
)
=>
clearPlaceInteractivities
(
item
));
};
export
const
updateFieldDataImpl
:
DuelReducer
<
ygopro
.
StocGameMessage
.
MsgUpdateData
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
zone
=
action
.
payload
.
zone
;
const
actions
=
action
.
payload
.
actions
;
switch
(
zone
)
{
case
ygopro
.
CardZone
.
HAND
:
{
const
hand
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
updateCardData
(
hand
,
actions
);
break
;
}
case
ygopro
.
CardZone
.
EXTRA
:
{
const
extra
=
judgeSelf
(
player
,
state
)
?
state
.
meExtraDeck
:
state
.
opExtraDeck
;
updateCardData
(
extra
,
actions
);
break
;
}
case
ygopro
.
CardZone
.
MZONE
:
{
const
monster
=
judgeSelf
(
player
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
updateCardData
(
monster
,
actions
);
break
;
}
case
ygopro
.
CardZone
.
SZONE
:
{
const
magics
=
judgeSelf
(
player
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
updateCardData
(
magics
,
actions
);
break
;
}
case
ygopro
.
CardZone
.
GRAVE
:
{
const
cemetery
=
judgeSelf
(
player
,
state
)
?
state
.
meCemetery
:
state
.
opCemetery
;
updateCardData
(
cemetery
,
actions
);
break
;
}
case
ygopro
.
CardZone
.
REMOVED
:
{
const
exclusion
=
judgeSelf
(
player
,
state
)
?
state
.
meExclusion
:
state
.
opExclusion
;
updateCardData
(
exclusion
,
actions
);
break
;
}
default
:
{
break
;
}
}
};
src/reducers/duel/mod.ts
View file @
86e4e7f3
...
...
@@ -95,6 +95,7 @@ import { DeckState, initDeckImpl } from "./deckSlice";
import
{
clearAllIdleInteractivitiesImpl
,
clearAllPlaceInteractivitiesImpl
,
updateFieldDataImpl
,
}
from
"
./commonSlice
"
;
import
{
ExtraDeckState
,
...
...
@@ -256,6 +257,7 @@ const duelSlice = createSlice({
// 通用的`Reducer`
clearAllIdleInteractivities
:
clearAllIdleInteractivitiesImpl
,
clearAllPlaceInteractivities
:
clearAllPlaceInteractivitiesImpl
,
updateFieldData
:
updateFieldDataImpl
,
// 对局结果`Reducer`
setResult
:
(
state
,
action
:
PayloadAction
<
MsgWin
.
ActionType
>
)
=>
{
...
...
@@ -352,6 +354,7 @@ export const {
setResult
,
setWaiting
,
setUnimplemented
,
updateFieldData
,
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
return
state
.
duel
.
meInitInfo
!=
null
;
...
...
src/service/duel/updateData.ts
View file @
86e4e7f3
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
updateFieldData
}
from
"
../../reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgUpdateData
=
ygopro
.
StocGameMessage
.
MsgUpdateData
;
export
default
(
updateData
:
MsgUpdateData
,
dispatch
:
AppDispatch
)
=>
{
console
.
log
(
updateData
);
dispatch
(
updateFieldData
(
updateData
)
);
};
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