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