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
bbd382a2
Commit
bbd382a2
authored
Dec 30, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add monsterCase
parent
77a984a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
1 deletion
+75
-1
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+2
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+73
-1
No files found.
src/reducers/duel/mod.ts
View file @
bbd382a2
...
...
@@ -29,6 +29,7 @@ import {
initMonstersImpl
,
addMonsterPlaceSelectAbleImpl
,
clearMonsterSelectInfoImpl
,
monsterCase
,
}
from
"
./monstersSlice
"
;
import
{
MagicState
,
...
...
@@ -106,6 +107,7 @@ const duelSlice = createSlice({
extraReducers
(
builder
)
{
handsCase
(
builder
);
hintCase
(
builder
);
monsterCase
(
builder
);
},
});
...
...
src/reducers/duel/monstersSlice.ts
View file @
bbd382a2
import
{
judgeSelf
,
Monster
,
InteractType
}
from
"
./util
"
;
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
PayloadAction
,
CaseReducer
,
createAsyncThunk
,
ActionReducerMapBuilder
,
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
CardMeta
,
fetchCard
}
from
"
../../api/cards
"
;
export
interface
MonsterState
{
monsters
:
Monster
[];
...
...
@@ -82,5 +88,71 @@ export const clearMonsterSelectInfoImpl: CaseReducer<
}
};
// 增加怪兽
export
const
fetchMonsterMeta
=
createAsyncThunk
(
"
duel/fetchMonsterMeta
"
,
async
(
param
:
[
number
,
number
,
number
])
=>
{
const
controler
=
param
[
0
];
const
sequence
=
param
[
1
];
const
code
=
param
[
2
];
const
meta
=
await
fetchCard
(
code
);
const
response
:
[
number
,
number
,
CardMeta
]
=
[
controler
,
sequence
,
meta
];
return
response
;
}
);
export
const
monsterCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchMonsterMeta
.
pending
,
(
state
,
action
)
=>
{
// Meta结果没返回之前先更新`ID`
const
controler
=
action
.
meta
.
arg
[
0
];
const
sequence
=
action
.
meta
.
arg
[
1
];
const
code
=
action
.
meta
.
arg
[
2
];
const
cardMeta
=
{
id
:
code
,
data
:
{},
text
:
{}
};
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meMonsters
)
{
for
(
const
monster
of
state
.
meMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
monster
.
occupant
=
cardMeta
;
}
}
}
}
else
{
if
(
state
.
opMonsters
)
{
for
(
const
monster
of
state
.
opMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
monster
.
occupant
=
cardMeta
;
}
}
}
}
});
builder
.
addCase
(
fetchMonsterMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
controler
=
action
.
payload
[
0
];
const
sequence
=
action
.
payload
[
1
];
const
meta
=
action
.
payload
[
2
];
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meMonsters
)
{
for
(
const
monster
of
state
.
meMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
monster
.
occupant
=
meta
;
}
}
}
}
else
{
if
(
state
.
opMonsters
)
{
for
(
const
monster
of
state
.
opMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
monster
.
occupant
=
meta
;
}
}
}
}
});
};
export
const
selectMeMonsters
=
(
state
:
RootState
)
=>
state
.
duel
.
meMonsters
||
{
monsters
:
[]
};
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