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
25910ff5
Commit
25910ff5
authored
Jan 15, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
33ae53a7
Pipeline
#19514
passed with stages
in 3 minutes and 2 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
45 deletions
+95
-45
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+10
-0
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+77
-45
src/service/duel/move.ts
src/service/duel/move.ts
+8
-0
No files found.
src/reducers/duel/generic.ts
View file @
25910ff5
...
...
@@ -170,3 +170,13 @@ export function removeOccupant<T extends DuelFieldState>(
}
}
}
export
function
insertCard
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
sequence
:
number
,
card
:
CardState
)
{
if
(
state
)
{
state
.
inner
.
splice
(
sequence
,
0
,
card
);
}
}
src/reducers/duel/handsSlice.ts
View file @
25910ff5
...
...
@@ -8,7 +8,14 @@ import { DuelState } from "./mod";
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
,
CardMeta
}
from
"
../../api/cards
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
Interactivity
,
DuelFieldState
}
from
"
./generic
"
;
import
{
Interactivity
,
DuelFieldState
,
removeCard
,
createAsyncMetaThunk
,
insertCard
,
extendMeta
,
}
from
"
./generic
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
export
interface
HandState
extends
DuelFieldState
{}
...
...
@@ -35,6 +42,56 @@ export const fetchHandsMeta = createAsyncThunk(
}
);
// 清空手牌互动性
export
const
clearHandsIdleInteractivityImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
for
(
let
hand
of
hands
.
inner
)
{
hand
.
idleInteractivities
=
[];
}
}
};
// 添加手牌互动性
export
const
addHandsIdleInteractivityImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
sequence
:
number
;
interactivity
:
Interactivity
<
number
>
;
}
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
const
sequence
=
action
.
payload
.
sequence
;
const
interactivity
=
action
.
payload
.
interactivity
;
hands
.
inner
[
sequence
].
idleInteractivities
.
push
(
interactivity
);
}
};
// 删除手牌
export
const
removeHandImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
[
number
,
number
]
>
>
=
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
[
0
];
const
sequence
=
action
.
payload
[
1
];
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
removeCard
(
hands
,
sequence
);
};
export
const
insertHandMeta
=
createAsyncMetaThunk
(
"
duel/insertHandMeta
"
);
export
const
handsCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchHandsMeta
.
pending
,
(
state
,
action
)
=>
{
// Meta结果没返回之前先更新手牌`ID`
...
...
@@ -82,58 +139,33 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
}
}
});
};
// 清空手牌互动性
export
const
clearHandsIdleInteractivityImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
for
(
let
hand
of
hands
.
inner
)
{
hand
.
idleInteractivities
=
[];
}
}
};
builder
.
addCase
(
insertHandMeta
.
pending
,
(
state
,
action
)
=>
{
const
controler
=
action
.
meta
.
arg
.
controler
;
const
sequence
=
action
.
meta
.
arg
.
sequence
;
const
code
=
action
.
meta
.
arg
.
code
;
// 添加手牌互动性
export
const
addHandsIdleInteractivityImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
sequence
:
number
;
interactivity
:
Interactivity
<
number
>
;
}
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
insertCard
(
hands
,
sequence
,
{
occupant
:
{
id
:
code
,
data
:
{},
text
:
{}
},
location
:
{
controler
},
idleInteractivities
:
[],
});
});
builder
.
addCase
(
insertHandMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
sequence
=
action
.
payload
.
sequence
;
const
interactivity
=
action
.
payload
.
interactivity
;
hands
.
inner
[
sequence
].
idleInteractivities
.
push
(
interactivity
);
}
};
const
meta
=
action
.
payload
.
meta
;
// 删除手牌
export
const
removeHandImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
[
number
,
number
]
>
>
=
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
[
0
];
const
sequence
=
action
.
payload
[
1
];
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
hands
.
inner
=
hands
.
inner
.
filter
((
_
,
idx
)
=>
idx
!=
sequence
);
}
extendMeta
(
hands
,
meta
,
sequence
);
});
};
// 在特定位置增加手牌
export
const
selectMeHands
=
(
state
:
RootState
)
=>
state
.
duel
.
meHands
||
{
inner
:
[]
};
export
const
selectOpHands
=
(
state
:
RootState
)
=>
...
...
src/service/duel/move.ts
View file @
25910ff5
...
...
@@ -9,6 +9,7 @@ import {
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchMagicMeta
}
from
"
../../reducers/duel/magicSlice
"
;
import
{
fetchCemeteryMeta
}
from
"
../../reducers/duel/cemeretySlice
"
;
import
{
insertHandMeta
}
from
"
../../reducers/duel/handsSlice
"
;
export
default
(
move
:
MsgMove
,
dispatch
:
AppDispatch
)
=>
{
const
code
=
move
.
code
;
...
...
@@ -78,6 +79,13 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
break
;
}
case
ygopro
.
CardZone
.
HAND
:
{
dispatch
(
insertHandMeta
({
controler
:
to
.
controler
,
sequence
:
to
.
sequence
,
code
})
);
break
;
}
default
:
{
console
.
log
(
`Unhandled zone type
${
to
.
location
}
`
);
...
...
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