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
BBeretta
Neos
Commits
ac2b7630
Commit
ac2b7630
authored
Aug 23, 2023
by
timel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/max-in-build-card' into 'main'
fix: max in build deck See merge request
mycard/Neos!285
parents
5c9a4632
ba2015e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
src/ui/BuildDeck/index.tsx
src/ui/BuildDeck/index.tsx
+6
-4
src/ui/BuildDeck/store.ts
src/ui/BuildDeck/store.ts
+12
-7
No files found.
src/ui/BuildDeck/index.tsx
View file @
ac2b7630
...
...
@@ -26,8 +26,9 @@ import { LoaderFunction } from "react-router-dom";
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
subscribeKey
}
from
"
valtio/utils
"
;
import
{
type
CardMeta
,
searchCards
,
forbidden
}
from
"
@/api
"
;
import
{
type
CardMeta
,
forbidden
,
searchCards
}
from
"
@/api
"
;
import
{
isToken
}
from
"
@/common
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
FtsConditions
}
from
"
@/middleware/sqlite/fts
"
;
import
{
deckStore
,
type
IDeck
,
initStore
}
from
"
@/stores
"
;
import
{
...
...
@@ -50,7 +51,6 @@ import {
iDeckToEditingDeck
,
type
Type
,
}
from
"
./utils
"
;
import
{
useConfig
}
from
"
@/config
"
;
const
{
assetsPath
}
=
useConfig
();
...
...
@@ -407,7 +407,7 @@ const DeckZone: React.FC<{
// 当拖拽物在这个拖放区域放下时触发,这个item就是拖拽物的item(拖拽物携带的数据)
drop
:
({
value
,
source
}:
{
value
:
CardMeta
;
source
:
Type
|
"
search
"
})
=>
{
if
(
type
===
source
)
return
;
const
{
result
,
reason
}
=
editDeckStore
.
canAdd
(
value
,
type
);
const
{
result
,
reason
}
=
editDeckStore
.
canAdd
(
value
,
type
,
source
);
if
(
result
)
{
editDeckStore
.
add
(
type
,
value
);
if
(
source
!==
"
search
"
)
{
...
...
@@ -419,7 +419,9 @@ const DeckZone: React.FC<{
},
hover
:
({
value
,
source
})
=>
{
setAllowToDrop
(
type
!==
source
?
editDeckStore
.
canAdd
(
value
,
type
).
result
:
true
,
type
!==
source
?
editDeckStore
.
canAdd
(
value
,
type
,
source
).
result
:
true
,
);
},
collect
:
(
monitor
)
=>
({
...
...
src/ui/BuildDeck/store.ts
View file @
ac2b7630
...
...
@@ -48,7 +48,11 @@ export const editDeckStore = proxy({
];
},
/** 一张卡能不能放入某个区 */
canAdd
(
card
:
CardMeta
,
type
:
Type
):
{
result
:
boolean
;
reason
:
string
}
{
canAdd
(
card
:
CardMeta
,
type
:
Type
,
source
:
Type
|
"
search
"
,
):
{
result
:
boolean
;
reason
:
string
}
{
const
deckType
=
editDeckStore
[
type
];
const
cardType
=
card
.
data
.
type
??
0
;
...
...
@@ -74,13 +78,14 @@ export const editDeckStore = proxy({
reason
=
"
卡片种类不符合
"
;
}
const
maxSameCard
=
forbidden
.
get
(
card
.
id
)
??
3
;
// TODO: 禁卡表
const
sameCardCount
=
editDeckStore
.
getAll
()
.
filter
((
c
)
=>
c
.
id
===
card
.
id
).
length
;
if
(
sameCardCount
>=
maxSameCard
)
{
const
max
=
forbidden
.
get
(
card
.
id
)
??
3
;
// TODO: 禁卡表
const
numOfSameCards
=
editDeckStore
.
getAll
().
filter
((
c
)
=>
c
.
id
===
card
.
id
).
length
-
(
source
!==
"
search
"
?
1
:
0
);
if
(
numOfSameCards
>=
max
)
{
result
=
false
;
reason
=
`超过同名卡
${
max
SameCard
}
张的上限`
;
reason
=
`超过同名卡
${
max
}
张的上限`
;
}
return
{
result
,
reason
};
},
...
...
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