Commit d5800458 authored by timel's avatar timel

fix: timing of ai mode in waitroom

parent 489aea76
...@@ -90,20 +90,7 @@ const WaitRoom = () => { ...@@ -90,20 +90,7 @@ const WaitRoom = () => {
await rustInit(url); await rustInit(url);
}; };
/** 如果是开发者模式下的人机对战,应该自动选择卡组,并自动准备和开始 */ init();
const runAiMode = async () => {
await new Promise((resolve) => setTimeout(resolve, 500));
await handleChoseDeck(defaultDeck!);
handleChoseReady();
handleChoseStart();
};
(async () => {
await init();
if (isAiMode) {
await runAiMode();
}
})();
} }
}, []); }, []);
...@@ -181,6 +168,18 @@ const WaitRoom = () => { ...@@ -181,6 +168,18 @@ const WaitRoom = () => {
useEffect(() => { useEffect(() => {
if (joined) { if (joined) {
api.info({ message: "成功加入房间!", placement: "top" }); api.info({ message: "成功加入房间!", placement: "top" });
/** 如果是开发者模式下的人机对战,应该自动选择卡组,并自动准备和开始 */
const runAiMode = async () => {
await new Promise((resolve) => setTimeout(resolve, 500));
await handleChoseDeck(defaultDeck!);
handleChoseReady();
handleChoseStart();
};
(async () => {
if (isAiMode) {
await runAiMode();
}
})();
} }
}, [joined]); }, [joined]);
useEffect(() => { useEffect(() => {
......
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