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
69b4f458
Commit
69b4f458
authored
Feb 11, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle overlay logic in service
parent
3459e7b8
Pipeline
#20048
passed with stages
in 3 minutes and 24 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
2 deletions
+103
-2
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+13
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+66
-0
src/service/duel/move.ts
src/service/duel/move.ts
+24
-2
No files found.
src/reducers/duel/generic.ts
View file @
69b4f458
...
@@ -29,6 +29,7 @@ export interface CardState {
...
@@ -29,6 +29,7 @@ export interface CardState {
zone
:
ygopro
.
CardZone
;
zone
:
ygopro
.
CardZone
;
sequence
:
number
;
sequence
:
number
;
}
>
;
// 选择位置状态下的互动信息
}
>
;
// 选择位置状态下的互动信息
overlay_materials
?:
CardMeta
[];
// 超量素材
}
}
export
enum
InteractType
{
export
enum
InteractType
{
...
@@ -212,6 +213,18 @@ export function removeOccupant<T extends DuelFieldState>(
...
@@ -212,6 +213,18 @@ export function removeOccupant<T extends DuelFieldState>(
}
}
}
}
export
function
removeOverlay
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
sequence
:
number
)
{
if
(
state
)
{
const
target
=
state
.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
)
{
target
.
overlay_materials
=
[];
}
}
}
export
function
insertCard
<
T
extends
DuelFieldState
>
(
export
function
insertCard
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
state
:
T
|
undefined
,
sequence
:
number
,
sequence
:
number
,
...
...
src/reducers/duel/monstersSlice.ts
View file @
69b4f458
...
@@ -3,6 +3,7 @@ import {
...
@@ -3,6 +3,7 @@ import {
PayloadAction
,
PayloadAction
,
CaseReducer
,
CaseReducer
,
ActionReducerMapBuilder
,
ActionReducerMapBuilder
,
createAsyncThunk
,
}
from
"
@reduxjs/toolkit
"
;
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
...
@@ -18,7 +19,9 @@ import {
...
@@ -18,7 +19,9 @@ import {
extendIdleInteractivities
,
extendIdleInteractivities
,
clearIdleInteractivities
,
clearIdleInteractivities
,
setPosition
,
setPosition
,
removeOverlay
,
}
from
"
./generic
"
;
}
from
"
./generic
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
export
interface
MonsterState
extends
DuelFieldState
{}
export
interface
MonsterState
extends
DuelFieldState
{}
...
@@ -159,6 +162,33 @@ export const clearMonsterIdleInteractivitiesImpl: CaseReducer<
...
@@ -159,6 +162,33 @@ export const clearMonsterIdleInteractivitiesImpl: CaseReducer<
// 增加怪兽
// 增加怪兽
export
const
fetchMonsterMeta
=
createAsyncMetaThunk
(
"
duel/fetchMonsterMeta
"
);
export
const
fetchMonsterMeta
=
createAsyncMetaThunk
(
"
duel/fetchMonsterMeta
"
);
// 增加怪兽的超量素材
export
const
fetchOverlayMeta
=
createAsyncThunk
(
"
duel/fetchOverlayMeta
"
,
async
(
param
:
{
controler
:
number
;
sequence
:
number
;
overlayCodes
:
number
[];
})
=>
{
const
controler
=
param
.
controler
;
const
sequence
=
param
.
sequence
;
const
overlayCodes
=
param
.
overlayCodes
;
const
metas
=
await
Promise
.
all
(
overlayCodes
.
map
(
async
(
id
)
=>
{
if
(
id
==
0
)
{
return
{
id
,
data
:
{},
text
:
{}
};
}
else
{
return
await
fetchCard
(
id
,
true
);
}
})
);
const
response
=
{
controler
,
sequence
,
metas
};
return
response
;
}
);
export
const
monsterCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
export
const
monsterCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchMonsterMeta
.
pending
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchMonsterMeta
.
pending
,
(
state
,
action
)
=>
{
// Meta结果没返回之前先更新`ID`
// Meta结果没返回之前先更新`ID`
...
@@ -185,6 +215,41 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -185,6 +215,41 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
extendOccupant
(
state
.
opMonsters
,
meta
,
sequence
);
extendOccupant
(
state
.
opMonsters
,
meta
,
sequence
);
}
}
});
});
builder
.
addCase
(
fetchOverlayMeta
.
pending
,
(
state
,
action
)
=>
{
// Meta结果没返回之前先更新`ID`
const
controler
=
action
.
meta
.
arg
.
controler
;
const
sequence
=
action
.
meta
.
arg
.
sequence
;
const
overlayCodes
=
action
.
meta
.
arg
.
overlayCodes
;
const
metas
=
overlayCodes
.
map
((
id
)
=>
{
return
{
id
,
data
:
{},
text
:
{}
};
});
const
monsters
=
judgeSelf
(
controler
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
if
(
monsters
)
{
const
target
=
monsters
.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
&&
target
.
occupant
)
{
target
.
overlay_materials
=
metas
;
}
}
});
builder
.
addCase
(
fetchOverlayMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
.
controler
;
const
sequence
=
action
.
payload
.
sequence
;
const
overlayMetas
=
action
.
payload
.
metas
;
const
monsters
=
judgeSelf
(
controler
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
if
(
monsters
)
{
const
target
=
monsters
.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
&&
target
.
occupant
)
{
target
.
overlay_materials
=
overlayMetas
;
}
}
});
};
};
// 删除怪兽
// 删除怪兽
...
@@ -199,6 +264,7 @@ export const removeMonsterImpl: CaseReducer<
...
@@ -199,6 +264,7 @@ export const removeMonsterImpl: CaseReducer<
:
state
.
opMonsters
;
:
state
.
opMonsters
;
removeOccupant
(
monsters
,
action
.
payload
.
sequence
);
removeOccupant
(
monsters
,
action
.
payload
.
sequence
);
removeOverlay
(
monsters
,
action
.
payload
.
sequence
);
};
};
// 改变怪兽表示形式
// 改变怪兽表示形式
...
...
src/service/duel/move.ts
View file @
69b4f458
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
import
MsgMove
=
ygopro
.
StocGameMessage
.
MsgMove
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
fetchMonsterMeta
}
from
"
../../reducers/duel/monstersSlice
"
;
import
{
fetchMonsterMeta
,
fetchOverlayMeta
,
}
from
"
../../reducers/duel/monstersSlice
"
;
import
{
import
{
removeCemetery
,
removeCemetery
,
removeExclusion
,
removeExclusion
,
...
@@ -16,11 +19,12 @@ import { insertHandMeta } from "../../reducers/duel/handsSlice";
...
@@ -16,11 +19,12 @@ import { insertHandMeta } from "../../reducers/duel/handsSlice";
import
{
fetchExclusionMeta
}
from
"
../../reducers/duel/exclusionSlice
"
;
import
{
fetchExclusionMeta
}
from
"
../../reducers/duel/exclusionSlice
"
;
import
{
fetchExtraDeckMeta
}
from
"
../../reducers/duel/extraDeckSlice
"
;
import
{
fetchExtraDeckMeta
}
from
"
../../reducers/duel/extraDeckSlice
"
;
const
OVERLAY_STACK
:
{
code
:
number
;
sequence
:
number
}[]
=
[];
export
default
(
move
:
MsgMove
,
dispatch
:
AppDispatch
)
=>
{
export
default
(
move
:
MsgMove
,
dispatch
:
AppDispatch
)
=>
{
const
code
=
move
.
code
;
const
code
=
move
.
code
;
const
from
=
move
.
from
;
const
from
=
move
.
from
;
const
to
=
move
.
to
;
const
to
=
move
.
to
;
console
.
log
(
to
);
// TODO: reason
// TODO: reason
switch
(
from
.
location
)
{
switch
(
from
.
location
)
{
...
@@ -81,6 +85,19 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
...
@@ -81,6 +85,19 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
})
})
);
);
// 处理超量素材
const
overlayMetarials
=
OVERLAY_STACK
.
splice
(
0
,
OVERLAY_STACK
.
length
);
let
sorted
=
overlayMetarials
.
sort
((
a
,
b
)
=>
a
.
sequence
-
b
.
sequence
)
.
map
((
overlay
)
=>
overlay
.
code
);
dispatch
(
fetchOverlayMeta
({
controler
:
to
.
controler
,
sequence
:
to
.
sequence
,
overlayCodes
:
sorted
,
})
);
break
;
break
;
}
}
case
ygopro
.
CardZone
.
SZONE
:
{
case
ygopro
.
CardZone
.
SZONE
:
{
...
@@ -135,6 +152,11 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
...
@@ -135,6 +152,11 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
break
;
break
;
}
}
case
ygopro
.
CardZone
.
OVERLAY
:
{
OVERLAY_STACK
.
push
({
code
,
sequence
:
to
.
overlay_sequence
});
break
;
}
default
:
{
default
:
{
console
.
log
(
`Unhandled zone type
${
to
.
location
}
`
);
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