Commit 3906d069 authored by Chunchi Che's avatar Chunchi Che

integrate side

parent 31f9205a
Pipeline #23181 passed with stages
in 10 minutes and 27 seconds
...@@ -6,7 +6,14 @@ import PlayerType = ygopro.StocGameMessage.MsgStart.PlayerType; ...@@ -6,7 +6,14 @@ import PlayerType = ygopro.StocGameMessage.MsgStart.PlayerType;
import { fetchCard, ygopro } from "@/api"; import { fetchCard, ygopro } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { sleep } from "@/infra"; import { sleep } from "@/infra";
import { cardStore, CardType, matStore, RoomStage, roomStore } from "@/stores"; import {
cardStore,
CardType,
matStore,
RoomStage,
roomStore,
sideStore,
} from "@/stores";
import { replayStart } from "@/ui/Match/ReplayModal"; import { replayStart } from "@/ui/Match/ReplayModal";
const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token
...@@ -23,6 +30,11 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -23,6 +30,11 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
// 这行在该函数中的位置不能随便放,否则可能会block住 // 这行在该函数中的位置不能随便放,否则可能会block住
roomStore.stage = RoomStage.DUEL_START; roomStore.stage = RoomStage.DUEL_START;
// 关闭side
sideStore.siding = false;
sideStore.waiting = false;
sideStore.ready = false;
matStore.initInfo.set(0, { matStore.initInfo.set(0, {
life: start.life1, life: start.life1,
deckSize: start.deckSize1, deckSize: start.deckSize1,
......
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { RoomStage, roomStore } from "@/stores"; import { RoomStage, roomStore, sideStore } from "@/stores";
export default function handleDuelStart(_pb: ygopro.YgoStocMsg) { export default function handleDuelStart(_pb: ygopro.YgoStocMsg) {
roomStore.stage = RoomStage.MORA; roomStore.stage = RoomStage.MORA;
if (sideStore.siding) {
// 副卡组更换完毕
sideStore.ready = true;
}
} }
import React from "react"; import React from "react";
import { SideModal } from "../Side";
import { import {
Alert, Alert,
AnnounceModal, AnnounceModal,
...@@ -37,6 +38,7 @@ export const Component: React.FC = () => { ...@@ -37,6 +38,7 @@ export const Component: React.FC = () => {
<AnnounceModal /> <AnnounceModal />
<SimpleSelectCardsModal /> <SimpleSelectCardsModal />
<EndModal /> <EndModal />
<SideModal />
</> </>
); );
}; };
......
import React, { CSSProperties } from "react"; import React, { CSSProperties } from "react";
import { useNavigate } from "react-router-dom";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region } from "@/api"; import { fetchStrings, Region } from "@/api";
...@@ -25,11 +24,10 @@ export const EndModal: React.FC = () => { ...@@ -25,11 +24,10 @@ export const EndModal: React.FC = () => {
const { isOpen, isWin, reason } = useSnapshot(localStore); const { isOpen, isWin, reason } = useSnapshot(localStore);
const { isReplay } = useSnapshot(matStore); const { isReplay } = useSnapshot(matStore);
const navigate = useNavigate();
const onReturn = () => { const onReturn = () => {
resetUniverse(); resetUniverse();
rs(); rs();
navigate("/match"); // TODO: 这里暂时不自动跳转,决斗结束后让玩家自己手动选择回到主页
}; };
return ( return (
......
...@@ -28,10 +28,6 @@ const router = createBrowserRouter([ ...@@ -28,10 +28,6 @@ const router = createBrowserRouter([
path: "/duel", path: "/duel",
lazy: () => import("./Duel/Main"), lazy: () => import("./Duel/Main"),
}, },
{
path: "/side",
lazy: () => import("./Side"),
},
], ],
}, },
]); ]);
......
...@@ -2,23 +2,40 @@ import { App, Button, Modal } from "antd"; ...@@ -2,23 +2,40 @@ import { App, Button, Modal } from "antd";
import React from "react"; import React from "react";
import { DndProvider } from "react-dnd"; import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend"; import { HTML5Backend } from "react-dnd-html5-backend";
import { useSnapshot } from "valtio";
import { deckStore } from "@/stores"; import { CardMeta, sendUpdateDeck } from "@/api";
import { deckStore, sideStore } from "@/stores";
import { DeckEditor } from "../BuildDeck"; import { DeckEditor } from "../BuildDeck";
import { editDeckStore } from "../BuildDeck/store"; import { editDeckStore } from "../BuildDeck/store";
import { iDeckToEditingDeck } from "../BuildDeck/utils"; import { iDeckToEditingDeck } from "../BuildDeck/utils";
import { Background } from "../Shared"; import { Background } from "../Shared";
export const Component: React.FC = () => { export const SideModal: React.FC = () => {
const deck = deckStore.decks[0]; const deck = deckStore.decks[0];
const { message } = App.useApp(); const { message } = App.useApp();
const { deckName, main, extra, side } = editDeckStore;
const { siding } = useSnapshot(sideStore);
const cardMeta2Id = (meta: CardMeta) => meta.id;
const handleSummit = () => {
const newDeck = {
deckName: deckName,
main: main.map(cardMeta2Id),
extra: extra.map(cardMeta2Id),
side: side.map(cardMeta2Id),
};
sendUpdateDeck(newDeck);
editDeckStore.edited = false;
};
return ( return (
<Modal <Modal
title="请选择更换副卡组" title="请选择更换副卡组"
open={true} open={siding}
width={700} width={700}
footer={<Button onClick={() => {}}>副卡组更换完毕</Button>} footer={<Button onClick={handleSummit}>副卡组更换完毕</Button>}
> >
<DndProvider backend={HTML5Backend}> <DndProvider backend={HTML5Backend}>
<Background /> <Background />
......
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