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
b2bfeb73
Commit
b2bfeb73
authored
Jan 17, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pos change service
parent
e11559a6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
9 deletions
+49
-9
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+11
-0
src/reducers/duel/magicSlice.ts
src/reducers/duel/magicSlice.ts
+18
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+3
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+4
-7
src/service/duel/posChange.ts
src/service/duel/posChange.ts
+13
-2
No files found.
src/reducers/duel/generic.ts
View file @
b2bfeb73
...
...
@@ -251,3 +251,14 @@ export function clearIdleInteractivities<T extends DuelFieldState>(
});
}
}
export
function
setPosition
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
sequence
:
number
,
position
:
ygopro
.
CardPosition
)
{
const
target
=
state
?.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
&&
target
.
occupant
)
{
target
.
location
.
position
=
position
;
}
}
src/reducers/duel/magicSlice.ts
View file @
b2bfeb73
...
...
@@ -17,6 +17,7 @@ import {
Interactivity
,
extendIdleInteractivities
,
clearIdleInteractivities
,
setPosition
,
}
from
"
./generic
"
;
export
interface
MagicState
extends
DuelFieldState
{}
...
...
@@ -172,6 +173,23 @@ export const removeMagicImpl: CaseReducer<
removeOccupant
(
magics
,
action
.
payload
.
sequence
);
};
// 改变魔法表示形式
export
const
setMagicPositionImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
controler
:
number
;
sequence
:
number
;
position
:
ygopro
.
CardPosition
;
}
>
>
=
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
sequence
=
action
.
payload
.
sequence
;
const
position
=
action
.
payload
.
position
;
const
magics
=
judgeSelf
(
controler
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
setPosition
(
magics
,
sequence
,
position
);
};
export
const
selectMeMagics
=
(
state
:
RootState
)
=>
state
.
duel
.
meMagics
||
{
inner
:
[]
};
export
const
selectOpMagics
=
(
state
:
RootState
)
=>
...
...
src/reducers/duel/mod.ts
View file @
b2bfeb73
...
...
@@ -66,6 +66,7 @@ import {
addMagicIdleInteractivitiesImpl
,
clearMagicIdleInteractivitiesImpl
,
removeMagicImpl
,
setMagicPositionImpl
,
magicCase
,
}
from
"
./magicSlice
"
;
import
{
CemeteryState
,
initCemeteryImpl
,
cemeteryCase
}
from
"
./cemeretySlice
"
;
...
...
@@ -166,6 +167,7 @@ const duelSlice = createSlice({
clearMagicPlaceInteractivities
:
clearMagicPlaceInteractivitiesImpl
,
addMagicIdleInteractivities
:
addMagicIdleInteractivitiesImpl
,
clearMagicIdleInteractivities
:
clearMagicIdleInteractivitiesImpl
,
setMagicPosition
:
setMagicPositionImpl
,
removeMagic
:
removeMagicImpl
,
// 墓地相关`Reducer`
...
...
@@ -250,6 +252,7 @@ export const {
clearMagicPlaceInteractivities
,
addMagicIdleInteractivities
,
clearMagicIdleInteractivities
,
setMagicPosition
,
removeMagic
,
removeHand
,
initCemetery
,
...
...
src/reducers/duel/monstersSlice.ts
View file @
b2bfeb73
...
...
@@ -17,6 +17,7 @@ import {
removeOccupant
,
extendIdleInteractivities
,
clearIdleInteractivities
,
setPosition
,
}
from
"
./generic
"
;
export
interface
MonsterState
extends
DuelFieldState
{}
...
...
@@ -190,21 +191,17 @@ export const setMonsterPositionImpl: CaseReducer<
PayloadAction
<
{
controler
:
number
;
sequence
:
number
;
currentP
osition
:
ygopro
.
CardPosition
;
p
osition
:
ygopro
.
CardPosition
;
}
>
>
=
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
sequence
=
action
.
payload
.
sequence
;
const
currentPosition
=
action
.
payload
.
currentP
osition
;
const
position
=
action
.
payload
.
p
osition
;
const
monsters
=
judgeSelf
(
controler
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
const
monster
=
monsters
?.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
monster
&&
monster
.
occupant
)
{
monster
.
location
.
position
=
currentPosition
;
}
setPosition
(
monsters
,
sequence
,
position
);
};
export
const
selectMeMonsters
=
(
state
:
RootState
)
=>
...
...
src/service/duel/posChange.ts
View file @
b2bfeb73
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
setMonsterPosition
}
from
"
../../reducers/duel/mod
"
;
import
{
setM
agicPosition
,
setM
onsterPosition
}
from
"
../../reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgPosChange
=
ygopro
.
StocGameMessage
.
MsgPosChange
;
...
...
@@ -12,7 +12,18 @@ export default (posChange: MsgPosChange, dispatch: AppDispatch) => {
setMonsterPosition
({
controler
:
cardInfo
.
controler
,
sequence
:
cardInfo
.
sequence
,
currentPosition
:
posChange
.
cur_position
,
position
:
posChange
.
cur_position
,
})
);
break
;
}
case
ygopro
.
CardZone
.
SZONE
:
{
dispatch
(
setMagicPosition
({
controler
:
cardInfo
.
controler
,
sequence
:
cardInfo
.
sequence
,
position
:
posChange
.
cur_position
,
})
);
...
...
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