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
d02078d1
Commit
d02078d1
authored
Mar 25, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update monster slice
parent
49652094
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+3
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+41
-0
src/service/duel/updateCounter.ts
src/service/duel/updateCounter.ts
+2
-1
No files found.
src/reducers/duel/mod.ts
View file @
d02078d1
...
@@ -72,6 +72,7 @@ import {
...
@@ -72,6 +72,7 @@ import {
removeMonsterImpl
,
removeMonsterImpl
,
setMonsterPositionImpl
,
setMonsterPositionImpl
,
removeOverlayImpl
,
removeOverlayImpl
,
updateMonsterCountersImpl
,
monsterCase
,
monsterCase
,
}
from
"
./monstersSlice
"
;
}
from
"
./monstersSlice
"
;
import
{
import
{
...
@@ -213,6 +214,7 @@ const duelSlice = createSlice({
...
@@ -213,6 +214,7 @@ const duelSlice = createSlice({
setMonsterPosition
:
setMonsterPositionImpl
,
setMonsterPosition
:
setMonsterPositionImpl
,
removeMonster
:
removeMonsterImpl
,
removeMonster
:
removeMonsterImpl
,
removeOverlay
:
removeOverlayImpl
,
removeOverlay
:
removeOverlayImpl
,
updateMonsterCounters
:
updateMonsterCountersImpl
,
// 魔法陷阱区相关`Reducer`
// 魔法陷阱区相关`Reducer`
initMagics
:
initMagicsImpl
,
initMagics
:
initMagicsImpl
,
...
@@ -337,6 +339,7 @@ export const {
...
@@ -337,6 +339,7 @@ export const {
clearMonsterIdleInteractivities
,
clearMonsterIdleInteractivities
,
setMonsterPosition
,
setMonsterPosition
,
removeMonster
,
removeMonster
,
updateMonsterCounters
,
removeOverlay
,
removeOverlay
,
initMagics
,
initMagics
,
addMagicPlaceInteractivities
,
addMagicPlaceInteractivities
,
...
...
src/reducers/duel/monstersSlice.ts
View file @
d02078d1
...
@@ -22,6 +22,9 @@ import {
...
@@ -22,6 +22,9 @@ import {
removeOverlay
,
removeOverlay
,
}
from
"
./generic
"
;
}
from
"
./generic
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
type
MsgUpdateCounter
=
ReturnType
<
typeof
ygopro
.
StocGameMessage
.
MsgUpdateCounter
.
prototype
.
toObject
>
;
export
interface
MonsterState
extends
DuelFieldState
{}
export
interface
MonsterState
extends
DuelFieldState
{}
...
@@ -155,6 +158,44 @@ export const addMonsterIdleInteractivitiesImpl: CaseReducer<
...
@@ -155,6 +158,44 @@ export const addMonsterIdleInteractivitiesImpl: CaseReducer<
);
);
};
};
export
const
updateMonsterCountersImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
MsgUpdateCounter
>
>
=
(
state
,
action
)
=>
{
const
monsters
=
judgeSelf
(
action
.
payload
.
location
?.
controler
!
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
if
(
monsters
)
{
const
target
=
monsters
.
inner
.
find
(
(
_
,
idx
)
=>
idx
==
action
.
payload
.
location
?.
sequence
!
);
if
(
target
)
{
const
count
=
action
.
payload
.
count
!
;
const
counterType
=
action
.
payload
.
action_type
!
;
switch
(
action
.
payload
.
action_type
!
)
{
case
ygopro
.
StocGameMessage
.
MsgUpdateCounter
.
ActionType
.
ADD
:
{
if
(
counterType
in
target
.
counters
)
{
target
.
counters
[
counterType
]
+=
count
;
}
else
{
target
.
counters
[
counterType
]
=
count
;
}
break
;
}
case
ygopro
.
StocGameMessage
.
MsgUpdateCounter
.
ActionType
.
REMOVE
:
{
if
(
counterType
in
target
.
counters
)
{
target
.
counters
[
counterType
]
-=
count
;
}
break
;
}
default
:
{
break
;
}
}
}
}
};
export
const
clearMonsterIdleInteractivitiesImpl
:
CaseReducer
<
export
const
clearMonsterIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
number
>
PayloadAction
<
number
>
...
...
src/service/duel/updateCounter.ts
View file @
d02078d1
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
updateMonsterCounters
}
from
"
../../reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgUpdateCounter
=
ygopro
.
StocGameMessage
.
MsgUpdateCounter
;
import
MsgUpdateCounter
=
ygopro
.
StocGameMessage
.
MsgUpdateCounter
;
export
default
(
updateCounter
:
MsgUpdateCounter
,
dispatch
:
AppDispatch
)
=>
{
export
default
(
updateCounter
:
MsgUpdateCounter
,
dispatch
:
AppDispatch
)
=>
{
console
.
log
(
updateCounter
);
dispatch
(
updateMonsterCounters
(
updateCounter
.
toObject
())
);
};
};
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