Commit 1dda3b3f authored by timel's avatar timel

fix: limit forbidden

parent e74d25d2
import { proxy } from "valtio"; import { proxy } from "valtio";
import { type CardMeta, forbidden } from "@/api"; import { type CardMeta } from "@/api";
import { isExtraDeckCard, isToken } from "@/common"; import { isExtraDeckCard, isToken } from "@/common";
import { compareCards, type EditingDeck, type Type } from "./utils"; import { compareCards, type EditingDeck, type Type } from "./utils";
...@@ -78,7 +78,7 @@ export const editDeckStore = proxy({ ...@@ -78,7 +78,7 @@ export const editDeckStore = proxy({
reason = "卡片种类不符合"; reason = "卡片种类不符合";
} }
const max = forbidden.get(card.id) ?? 3; // TODO: 禁卡表 const max = 3; // 这里无需参考禁卡表
const numOfSameCards = const numOfSameCards =
editDeckStore.getAll().filter((c) => c.id === card.id).length - editDeckStore.getAll().filter((c) => c.id === card.id).length -
(source !== "search" ? 1 : 0); (source !== "search" ? 1 : 0);
...@@ -87,6 +87,7 @@ export const editDeckStore = proxy({ ...@@ -87,6 +87,7 @@ export const editDeckStore = proxy({
result = false; result = false;
reason = `超过同名卡 ${max} 张的上限`; reason = `超过同名卡 ${max} 张的上限`;
} }
return { result, reason }; return { result, reason };
}, },
}) satisfies EditingDeck; }) satisfies EditingDeck;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment