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
75a1a49e
Commit
75a1a49e
authored
Jan 15, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add removeOccupant
parent
5e1e0834
Pipeline
#19510
passed with stages
in 4 minutes and 4 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+21
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+3
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+14
-0
src/service/duel/move.ts
src/service/duel/move.ts
+8
-1
No files found.
src/reducers/duel/generic.ts
View file @
75a1a49e
...
...
@@ -149,3 +149,24 @@ export function clearPlaceInteractivities<T extends DuelFieldState>(
}
}
}
export
function
removeCard
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
sequence
:
number
)
{
if
(
state
)
{
state
.
inner
=
state
.
inner
.
filter
((
_
,
idx
)
=>
idx
!=
sequence
);
}
}
export
function
removeOccupant
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
sequence
:
number
)
{
if
(
state
)
{
const
target
=
state
.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
)
{
target
.
occupant
=
undefined
;
}
}
}
src/reducers/duel/mod.ts
View file @
75a1a49e
...
...
@@ -46,6 +46,7 @@ import {
initMonstersImpl
,
addMonsterPlaceInteractivitiesImpl
,
clearMonsterPlaceInteractivitiesImpl
,
removeMonsterImpl
,
monsterCase
,
}
from
"
./monstersSlice
"
;
import
{
...
...
@@ -135,6 +136,7 @@ const duelSlice = createSlice({
initMonsters
:
initMonstersImpl
,
addMonsterPlaceInteractivities
:
addMonsterPlaceInteractivitiesImpl
,
clearMonsterPlaceInteractivities
:
clearMonsterPlaceInteractivitiesImpl
,
removeMonster
:
removeMonsterImpl
,
// 魔法陷阱区相关`Reducer`
initMagics
:
initMagicsImpl
,
...
...
@@ -201,6 +203,7 @@ export const {
initMonsters
,
addMonsterPlaceInteractivities
,
clearMonsterPlaceInteractivities
,
removeMonster
,
initMagics
,
addMagicPlaceInteractivities
,
clearMagicPlaceInteractivities
,
...
...
src/reducers/duel/monstersSlice.ts
View file @
75a1a49e
...
...
@@ -13,6 +13,7 @@ import {
extendOccupant
,
extendPlaceInteractivity
,
clearPlaceInteractivities
,
removeOccupant
,
}
from
"
./generic
"
;
export
interface
MonsterState
extends
DuelFieldState
{}
...
...
@@ -137,6 +138,19 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
});
};
export
const
removeMonsterImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
controler
:
number
;
sequence
:
number
}
>
>
=
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
monsters
=
judgeSelf
(
controler
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
removeOccupant
(
monsters
,
action
.
payload
.
sequence
);
};
export
const
selectMeMonsters
=
(
state
:
RootState
)
=>
state
.
duel
.
meMonsters
||
{
inner
:
[]
};
export
const
selectOpMonsters
=
(
state
:
RootState
)
=>
...
...
src/service/duel/move.ts
View file @
75a1a49e
...
...
@@ -2,7 +2,7 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
fetchMonsterMeta
}
from
"
../../reducers/duel/monstersSlice
"
;
import
{
removeHand
}
from
"
../../reducers/duel/mod
"
;
import
{
removeHand
,
removeMonster
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchMagicMeta
}
from
"
../../reducers/duel/magicSlice
"
;
import
{
fetchCemeteryMeta
}
from
"
../../reducers/duel/cemeretySlice
"
;
...
...
@@ -18,6 +18,13 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
break
;
}
case
ygopro
.
CardZone
.
MZONE
:
{
dispatch
(
removeMonster
({
controler
:
from
.
controler
,
sequence
:
from
.
sequence
})
);
break
;
}
default
:
{
console
.
log
(
`Unhandled zone type
${
from
.
location
}
`
);
break
;
...
...
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