Commit 60488335 authored by chechunchi's avatar chechunchi

setup 408 lflist

parent d58778dc
Pipeline #30304 passed with stages
in 7 minutes and 31 seconds
......@@ -39,6 +39,9 @@
"lflist": "https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf",
"config": "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json"
},
"env408Resource": {
"lflist": "https://cdn02.moecube.com:444/cn-database/env408-zh-CN/expansions/lflist.conf"
},
"stringsUrl": "https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"replayUrl": "replay.neos.moe",
"loginUrl": "https://accounts.moecube.com/signin",
......
......@@ -39,6 +39,9 @@
"lflist": "https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf",
"config": "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json"
},
"env408Resource": {
"lflist": "https://cdn02.moecube.com:444/cn-database/env408-zh-CN/expansions/lflist.conf"
},
"stringsUrl": "https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"replayUrl": "replay.neos.moe",
"loginUrl": "https://accounts.moecube.com/signin",
......
import { isNil } from "lodash-es";
import { useConfig } from "@/config";
import { CardMeta } from "./cards";
const {
releaseResource: { lflist },
} = useConfig();
class Forbidden {
private data: Map<number, number> = new Map<number, number>();
public time: string = "?";
public async init(): Promise<void> {
public async init(lflist: string): Promise<void> {
const text = await (await fetch(lflist)).text();
const { time, forbiddens } = this.extractForbiddensFromText(text);
this.time = time;
......@@ -87,3 +82,4 @@ class Forbidden {
}
export const forbidden = new Forbidden();
export const forbidden_408 = new Forbidden();
......@@ -26,6 +26,7 @@ import {
DeckZone,
Loading,
ScrollableArea,
Select,
} from "@/ui/Shared";
import { Type } from "@/ui/Shared/DeckZone";
......@@ -41,6 +42,9 @@ import {
iDeckToEditingDeck,
} from "./utils";
const ENV_OCG = 0;
const ENV_408 = 1;
export const loader: LoaderFunction = async () => {
// 必须先加载卡组,不然页面会崩溃
if (!initStore.decks) {
......@@ -182,6 +186,9 @@ export const DeckEditor: React.FC<{
}> = ({ deck, onClear, onReset, onSave, onShuffle, onSort }) => {
const snapEditDeck = useSnapshot(editDeckStore);
const [deckName, setDeckName] = useState(editDeckStore.deckName);
const [env, setEnv] = useState(ENV_OCG);
const handleEnvChange = (value: any) => setEnv(value);
useEffect(() => {
iDeckToEditingDeck(deck).then(editDeckStore.set);
......@@ -249,6 +256,21 @@ export const DeckEditor: React.FC<{
value={deckName}
/>
<Space style={{ marginRight: "0.4rem" }} size={5}>
<Select
title={i18n("Environment")}
value={env}
options={[
{
value: ENV_OCG,
label: "OCG",
},
{
value: ENV_408,
label: "408",
},
]}
onChange={handleEnvChange}
/>
<Button
type="text"
size="small"
......@@ -313,6 +335,7 @@ export const DeckEditor: React.FC<{
editDeckStore.add(type, card);
}
}}
is408={env === ENV_408}
/>
))}
</ScrollableArea>
......
......@@ -42,6 +42,7 @@
},
"BuildDeck": {
"EnterTheDeckName": "请输入卡组名字",
"Environment": "环境",
"Shuffle": "打乱",
"Sort": "排序",
"Clear": "清空",
......
......@@ -42,6 +42,7 @@
},
"BuildDeck": {
"EnterTheDeckName": "Deck name",
"Environment": "Environment",
"Shuffle": "Shuffle",
"Sort": "Sort",
"Clear": "Clear",
......
......@@ -40,6 +40,7 @@
},
"BuildDeck": {
"EnterTheDeckName": "デッキ名を入力",
"Environment": "環境",
"Shuffle": "シャッフル",
"Sort": "ソート",
"Clear": "クリア",
......
......@@ -3,6 +3,7 @@ import rustInit from "rust-src";
import {
CookieKeys,
forbidden,
forbidden_408,
getCookie,
initStrings,
initSuperPrerelease,
......@@ -12,7 +13,7 @@ import { useConfig } from "@/config";
import { useEnv } from "@/hook";
import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite";
import { accountStore, deckStore, initStore, type User } from "@/stores";
const { releaseResource, preReleaseResource } = useConfig();
const { releaseResource, preReleaseResource, env408Resource } = useConfig();
const { BASE_URL } = useEnv();
/** 加载ygodb */
......@@ -55,7 +56,8 @@ export const initWASM = async () => {
/** 加载禁限卡表 */
export const initForbidden = async () => {
if (!initStore.forbidden) {
await forbidden.init();
await forbidden.init(releaseResource.lflist);
await forbidden_408.init(env408Resource.lflist);
initStore.forbidden = true;
}
};
......
import React, { memo, useRef, useState } from "react";
import { useDrag } from "react-dnd";
import { CardMeta, forbidden } from "@/api";
import { CardMeta, forbidden, forbidden_408 } from "@/api";
import { useConfig } from "@/config";
import { Type } from "../DeckZone";
......@@ -22,48 +22,51 @@ export const DeckCard: React.FC<{
onMouseUp?: (event: DeckCardMouseUpEvent) => void;
onMouseEnter?: () => void;
onDoubleClick?: (card: CardMeta) => void;
}> = memo(({ value, source, onMouseUp, onMouseEnter, onDoubleClick }) => {
const ref = useRef<HTMLDivElement>(null);
const [{ isDragging }, drag] = useDrag({
type: "Card",
item: { value, source },
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
});
drag(ref);
const [showText, setShowText] = useState(true);
const limitCnt = forbidden.get(value);
is408?: boolean;
}> = memo(
({ value, source, onMouseUp, onMouseEnter, onDoubleClick, is408 }) => {
const ref = useRef<HTMLDivElement>(null);
const [{ isDragging }, drag] = useDrag({
type: "Card",
item: { value, source },
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
});
drag(ref);
const [showText, setShowText] = useState(true);
const limitCnt = is408 ? forbidden_408.get(value) : forbidden.get(value);
return (
<div
className={styles.card}
ref={ref}
style={{ opacity: isDragging && source !== "search" ? 0 : 1 }}
onMouseUp={(event) =>
onMouseUp?.({
event,
card: value,
})
}
onMouseEnter={onMouseEnter}
onDoubleClick={() => onDoubleClick?.(value)}
onContextMenu={(e) => {
e.preventDefault();
}}
>
{showText && <div className={styles.cardname}>{value.text.name}</div>}
<YgoCard
className={styles.cardcover}
code={value.id}
onLoad={() => setShowText(false)}
/>
{limitCnt !== undefined && (
<img
className={styles.cardlimit}
src={`${assetsPath}/Limit0${limitCnt}.png`}
return (
<div
className={styles.card}
ref={ref}
style={{ opacity: isDragging && source !== "search" ? 0 : 1 }}
onMouseUp={(event) =>
onMouseUp?.({
event,
card: value,
})
}
onMouseEnter={onMouseEnter}
onDoubleClick={() => onDoubleClick?.(value)}
onContextMenu={(e) => {
e.preventDefault();
}}
>
{showText && <div className={styles.cardname}>{value.text.name}</div>}
<YgoCard
className={styles.cardcover}
code={value.id}
onLoad={() => setShowText(false)}
/>
)}
</div>
);
});
{limitCnt !== undefined && (
<img
className={styles.cardlimit}
src={`${assetsPath}/Limit0${limitCnt}.png`}
/>
)}
</div>
);
},
);
......@@ -26,6 +26,7 @@ export const DeckZone: React.FC<{
) => void;
onElementMouseUp: (event: DeckCardMouseUpEvent) => void;
onDoubleClick?: (card: CardMeta) => void;
is408?: boolean;
}> = ({
type,
cards,
......@@ -33,6 +34,7 @@ export const DeckZone: React.FC<{
onChange,
onElementMouseUp: onElementMouseUp,
onDoubleClick,
is408,
}) => {
const { message } = App.useApp();
const [allowToDrop, setAllowToDrop] = useState(false);
......@@ -74,6 +76,7 @@ export const DeckZone: React.FC<{
source={type}
onMouseUp={onElementMouseUp}
onDoubleClick={onDoubleClick}
is408={is408}
/>
))}
<div className={styles["editing-zone-name"]}>
......
......@@ -2,8 +2,8 @@
display: flex;
align-items: center;
.prefix {
height: 40px;
line-height: 40px;
height: 2rem;
line-height: 2rem;
padding: 0 1rem;
border-radius: 6px;
border-right: none;
......
......@@ -10,7 +10,7 @@ export const Select: React.FC<
{title && <span className={styles.prefix}>{title}</span>}
<AntdSelect
className={classNames(styles.select, className)}
size="large"
size="middle"
dropdownStyle={{
backdropFilter: "blur(20px)",
...dropdownStyle,
......
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