Commit 5d46d097 authored by chechunchi's avatar chechunchi

add delay on start

parent 6ef9a17f
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false, "chainALL": false,
"streamInterval": 20, "streamInterval": 20,
"startDelay": 1000,
"ui":{ "ui":{
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false, "chainALL": false,
"streamInterval": 20, "streamInterval": 20,
"startDelay": 1000,
"ui":{ "ui":{
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
......
...@@ -2,8 +2,6 @@ import { fetchCard, ygopro } from "@/api"; ...@@ -2,8 +2,6 @@ import { fetchCard, ygopro } from "@/api";
import { eventbus, Task } from "@/infra"; import { eventbus, Task } from "@/infra";
import { cardStore, fetchEsHintMeta } from "@/stores"; import { cardStore, fetchEsHintMeta } from "@/stores";
let cnt = 0;
export default async (draw: ygopro.StocGameMessage.MsgDraw) => { export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
fetchEsHintMeta({ originMsg: "玩家抽卡时" }); fetchEsHintMeta({ originMsg: "玩家抽卡时" });
...@@ -25,11 +23,6 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => { ...@@ -25,11 +23,6 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
card.location.sequence = Number(idx) + handsLength; card.location.sequence = Number(idx) + handsLength;
} }
if (cnt++ < 2) {
// FIXME 暂时性的解决方案,头两回抽卡(双方各自初始手卡)先屏蔽掉
// 不然会出现一些问题...
return;
}
// 抽卡动画 // 抽卡动画
await Promise.all( await Promise.all(
cardStore cardStore
......
...@@ -76,7 +76,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -76,7 +76,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
switch (msg.gameMsg) { switch (msg.gameMsg) {
case "start": { case "start": {
onMsgStart(msg.start); await onMsgStart(msg.start);
break; break;
} }
......
...@@ -4,11 +4,13 @@ import { proxy } from "valtio"; ...@@ -4,11 +4,13 @@ import { proxy } from "valtio";
import { subscribeKey } from "valtio/utils"; import { subscribeKey } from "valtio/utils";
import { fetchCard, ygopro } from "@/api"; import { fetchCard, ygopro } from "@/api";
import { useConfig } from "@/config";
import { sleep } from "@/infra";
import { cardStore, CardType, store } from "@/stores"; import { cardStore, CardType, store } from "@/stores";
const { matStore } = store; const { matStore } = store;
const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token
export default (start: ygopro.StocGameMessage.MsgStart) => { export default async (start: ygopro.StocGameMessage.MsgStart) => {
// 先初始化`matStore` // 先初始化`matStore`
matStore.selfType = start.playerType; matStore.selfType = start.playerType;
const opponent = const opponent =
...@@ -73,6 +75,10 @@ export default (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -73,6 +75,10 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
cardStore cardStore
.at(ygopro.CardZone.EXTRA, 1 - opponent) .at(ygopro.CardZone.EXTRA, 1 - opponent)
.forEach((card) => (card.code = myExtraDeckCodes.pop()!)); .forEach((card) => (card.code = myExtraDeckCodes.pop()!));
// 初始化完后,sleep 1s,让UI初始化完成,
// 否则在和AI对战时,由于后端给传给前端的`MSG`频率太高,会导致一些问题。
await sleep(useConfig().startDelay);
}; };
// 自动从code推断出occupant // 自动从code推断出occupant
......
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