Commit 87d860af authored by Chunchi Che's avatar Chunchi Che

handle createRoom

parent d0b02466
......@@ -10,6 +10,11 @@
"ip": "tiramisu.moecube.com",
"port": "8912"
},
{
"name": "mycard-custom",
"ip": "tiramisu.moecube.com",
"port": "7912"
},
{
"name": "pre-release",
"ip": "koishi.momobako.com",
......
......@@ -195,11 +195,18 @@ export const CustomRoomContent: React.FC = () => {
);
};
export const CustomRoomFooter: React.FC = () => {
export const CustomRoomFooter: React.FC<{
onCreateRoom: () => void;
onJoinRoom: () => void;
}> = ({ onCreateRoom, onJoinRoom }) => {
return (
<div className={styles.footer}>
<Button className={styles.btn}>创建私密房间</Button>
<Button className={styles.btn}>加入私密房间</Button>
<Button className={styles.btn} onClick={onCreateRoom}>
创建私密房间
</Button>
<Button className={styles.btn} onClick={onJoinRoom}>
加入私密房间
</Button>
</div>
);
};
......@@ -5,17 +5,26 @@ import {
PlayCircleFilled,
SettingFilled,
} from "@ant-design/icons";
import { App, Button, Space } from "antd";
import { App, Button, Modal, Space } from "antd";
import { useEffect, useState } from "react";
import { LoaderFunction, useNavigate } from "react-router-dom";
import { useSnapshot } from "valtio";
import { getJoinRoomPasswd, match } from "@/api";
import {
getCreateRoomPasswd,
getJoinRoomPasswd,
getPrivateRoomID,
match,
} from "@/api";
import { useConfig } from "@/config";
import { accountStore, deckStore, resetUniverse, roomStore } from "@/stores";
import { Background, IconFont, Select } from "@/ui/Shared";
import { CustomRoomContent, CustomRoomFooter } from "./CustomRoomContent";
import {
CustomRoomContent,
CustomRoomFooter,
mcCustomRoomStore,
} from "./CustomRoomContent";
import styles from "./index.module.scss";
import { MatchModal, matchStore } from "./MatchModal";
import { ReplayModal, replayOpen } from "./ReplayModal";
......@@ -37,6 +46,7 @@ export const Component: React.FC = () => {
const [deckName, setDeckName] = useState(decks.at(0)?.deckName ?? "");
const user = accountStore.user;
const { joined } = useSnapshot(roomStore);
const { options, friendPrivateID } = mcCustomRoomStore;
const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态
const [athleticMatchLoading, setAthleticMatchLoading] = useState(false); // 竞技匹配的loading状态
const [entertainMatchLoading, setEntertainMatchLoading] = useState(false); // 娱乐匹配的loading状态
......@@ -81,11 +91,40 @@ export const Component: React.FC = () => {
centered: true,
maskClosable: true,
content: <CustomRoomContent />,
footer: <CustomRoomFooter />,
footer: (
<CustomRoomFooter
onCreateRoom={onCreateMCRoom}
onJoinRoom={onJoinMCRoom}
/>
),
});
}
};
// 创建MC自定义房间
const onCreateMCRoom = async () => {
if (user) {
const mcServer = serverList.find(
(server) => server.name === "mycard-custom",
);
if (mcServer) {
const passWd = getCreateRoomPasswd(
options,
String(getPrivateRoomID(user.external_id)),
user.external_id,
true,
);
await connectSrvpro({
ip: mcServer.ip + ":" + mcServer.port,
player: user.username,
passWd,
});
}
}
};
// 加入MC自定义房间
const onJoinMCRoom = () => {};
// MC观战
const onMCWatch = () => {
if (!user) {
......@@ -150,6 +189,7 @@ export const Component: React.FC = () => {
setAthleticMatchLoading(false);
setEntertainMatchLoading(false);
setWatchLoading(false);
Modal.destroyAll(); // 销毁当前所有modal
navigate(`/waitroom`);
}
}, [joined]);
......
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