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
83f4f98e
Commit
83f4f98e
authored
May 11, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update selectUnselectCard service
parent
43439502
Pipeline
#26999
passed with stages
in 10 minutes and 43 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
20 deletions
+54
-20
src/service/duel/selectUnselectCard.ts
src/service/duel/selectUnselectCard.ts
+54
-20
No files found.
src/service/duel/selectUnselectCard.ts
View file @
83f4f98e
import
{
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
matStore
}
from
"
@/stores
"
;
import
{
displaySelectActionsModal
}
from
"
@/ui/Duel/Message/SelectActionsModal
"
;
import
{
fetchCheckCardMeta
}
from
"
../utils
"
;
type
MsgSelectUnselectCard
=
ygopro
.
StocGameMessage
.
MsgSelectUnselectCard
;
const
{
MZONE
,
SZONE
,
HAND
}
=
ygopro
.
CardZone
;
export
default
async
({
finishable
,
...
...
@@ -12,24 +14,56 @@ export default async ({
selectable_cards
:
selectableCards
,
selected_cards
:
selectedCards
,
}:
MsgSelectUnselectCard
)
=>
{
const
{
selecteds
:
selecteds1
,
mustSelects
:
mustSelect1
,
selectables
:
selectable1
,
}
=
await
fetchCheckCardMeta
(
selectableCards
);
const
{
selecteds
:
selecteds2
,
mustSelects
:
mustSelect2
,
selectables
:
selectable2
,
}
=
await
fetchCheckCardMeta
(
selectedCards
,
true
);
await
displaySelectActionsModal
({
finishable
,
cancelable
,
min
:
min
,
max
:
max
,
single
:
true
,
selecteds
:
[...
selecteds1
,
...
selecteds2
],
mustSelects
:
[...
mustSelect1
,
...
mustSelect2
],
selectables
:
[...
selectable1
,
...
selectable2
],
});
if
(
selectableCards
.
concat
(
selectedCards
)
.
find
((
info
)
=>
!
isOnField
(
info
.
location
))
===
undefined
)
{
// 所有可选卡和已选卡都是在场上或手牌
// 通过让玩家点击场上的卡来进行选择
for
(
const
info
of
selectableCards
)
{
const
card
=
cardStore
.
find
(
info
.
location
);
if
(
card
)
{
matStore
.
selectUnselectInfo
.
selectableList
.
push
(
info
.
location
);
card
.
selectInfo
.
selectable
=
true
;
}
}
for
(
const
info
of
selectedCards
)
{
const
card
=
cardStore
.
find
(
info
.
location
);
if
(
card
)
{
matStore
.
selectUnselectInfo
.
selectedList
.
push
(
info
.
location
);
card
.
selectInfo
.
selected
=
true
;
}
}
matStore
.
selectUnselectInfo
.
finishable
=
finishable
;
matStore
.
selectUnselectInfo
.
cancelable
=
cancelable
;
}
else
{
// 有一些卡不在场上或手牌,因此无法通过点击卡片来选择
// 这里通过让玩家点击Modal中的卡来进行选择
const
{
selecteds
:
selecteds1
,
mustSelects
:
mustSelect1
,
selectables
:
selectable1
,
}
=
await
fetchCheckCardMeta
(
selectableCards
);
const
{
selecteds
:
selecteds2
,
mustSelects
:
mustSelect2
,
selectables
:
selectable2
,
}
=
await
fetchCheckCardMeta
(
selectedCards
,
true
);
await
displaySelectActionsModal
({
finishable
,
cancelable
,
min
:
min
,
max
:
max
,
single
:
true
,
selecteds
:
[...
selecteds1
,
...
selecteds2
],
mustSelects
:
[...
mustSelect1
,
...
mustSelect2
],
selectables
:
[...
selectable1
,
...
selectable2
],
});
}
};
function
isOnField
(
location
:
ygopro
.
CardLocation
):
boolean
{
return
[
MZONE
,
SZONE
,
HAND
].
includes
(
location
.
zone
);
}
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