Commit 6e793797 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feature/forbidden-alias' into 'main'

feat: add forbidden alias icon

See merge request mycard/Neos!304
parents e7f6cf8c bf99d9a6
Pipeline #23403 passed with stages
in 10 minutes and 31 seconds
......@@ -21,28 +21,16 @@ export interface CardData {
rscale?: number;
}
export interface CardText {
export type CardStrRange = `str${IntRange<1, 17>}`;
export type CardText = {
id?: number;
name?: string;
types?: string;
desc?: string;
str1?: string;
str2?: string;
str3?: string;
str4?: string;
str5?: string;
str6?: string;
str7?: string;
str8?: string;
str9?: string;
str10?: string;
str11?: string;
str12?: string;
str13?: string;
str14?: string;
str15?: string;
str16?: string;
}
} & {
[str in CardStrRange]?: string;
};
/*
* 返回卡片元数据
......@@ -80,57 +68,6 @@ window.fetchCard = fetchCard;
window.searchCard = searchCards;
export function getCardStr(meta: CardMeta, idx: number): string | undefined {
switch (idx) {
case 0: {
return meta.text.str1;
}
case 1: {
return meta.text.str2;
}
case 2: {
return meta.text.str3;
}
case 3: {
return meta.text.str4;
}
case 4: {
return meta.text.str5;
}
case 5: {
return meta.text.str6;
}
case 6: {
return meta.text.str7;
}
case 7: {
return meta.text.str8;
}
case 8: {
return meta.text.str9;
}
case 9: {
return meta.text.str10;
}
case 10: {
return meta.text.str11;
}
case 11: {
return meta.text.str12;
}
case 12: {
return meta.text.str13;
}
case 13: {
return meta.text.str14;
}
case 14: {
return meta.text.str15;
}
case 15: {
return meta.text.str16;
}
default: {
return undefined;
}
}
const str = `str${idx + 1}` as CardStrRange;
return meta.text[str];
}
import { isNil } from "lodash-es";
import { useConfig } from "@/config";
import { CardMeta } from "./cards";
const { lflistUrl } = useConfig();
class Forbidden {
......@@ -16,8 +20,12 @@ class Forbidden {
this.data.set(cardId, limitCount);
}
public get(id: number): number | undefined {
return this.data.get(id);
public get(card: CardMeta): number | undefined {
let cardForbiddenById = this.data.get(card.id);
if (isNil(cardForbiddenById) && !isNil(card.data.alias)) {
cardForbiddenById = this.data.get(card.data.alias);
}
return cardForbiddenById;
}
private setForbiddens(forbiddens: Map<number, number>): void {
......
type Enumerate<
N extends number,
Acc extends number[] = [],
> = Acc["length"] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc["length"]]>;
type IntRange<F extends number, T extends number> = Exclude<
Enumerate<T>,
Enumerate<F>
>;
......@@ -32,7 +32,8 @@ export const DeckCard: React.FC<{
});
drag(ref);
const [showText, setShowText] = useState(true);
const limitCnt = forbidden.get(value.id);
const limitCnt = forbidden.get(value);
return (
<div
className={styles.card}
......
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