Commit 6ab710fe authored by Chunchi Che's avatar Chunchi Che

optimize

parent 9eea2046
......@@ -71,7 +71,9 @@
"hint":{
"waitingDuration":1.5,
"maxCount": 1
}
},
"moveDelay": 500,
"chainingDelay": 800
},
"unimplementedWhiteList":[
1,
......
......@@ -71,7 +71,9 @@
"hint":{
"waitingDuration":1.5,
"maxCount": 1
}
},
"moveDelay": 500,
"chainingDelay": 800
},
"unimplementedWhiteList":[
1,
......
import { ygopro } from "@/api";
import { useConfig } from "@/config";
import { fetchEsHintMeta, matStore } from "@/stores";
export default (chaining: ygopro.StocGameMessage.MsgChaining) => {
fetchEsHintMeta({
originMsg: "「[?]」被发动时",
......@@ -11,5 +13,5 @@ export default (chaining: ygopro.StocGameMessage.MsgChaining) => {
setTimeout(() => {
matStore.setChaining(chaining.location, chaining.code, false);
// TODO: set chained
}, 500);
}, useConfig().ui.chainingDelay);
};
import { ygopro } from "@/api";
import { useConfig } from "@/config";
import { matStore } from "@/stores";
import onMsgAttack from "./attack";
......@@ -56,7 +57,7 @@ const ActiveList = [
"select_yes_no",
];
const TIME_GAP = 200;
const NeosConfig = useConfig();
export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
// 防止MSG更新太频繁,做下控频
......@@ -69,6 +70,9 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
matStore.waiting = false;
}
// 先重置`delay`
matStore.delay = 0;
switch (msg.gameMsg) {
case "start": {
onMsgStart(msg.start);
......@@ -108,6 +112,8 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
case "move": {
onMsgMove(msg.move);
matStore.delay = NeosConfig.ui.moveDelay;
break;
}
case "select_card": {
......@@ -233,6 +239,8 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
case "chaining": {
onMsgChaining(msg.chaining);
matStore.delay = NeosConfig.ui.chainingDelay;
break;
}
case "chain_solved": {
......@@ -279,5 +287,5 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
}
}, TIME_GAP);
}, matStore.delay);
}
......@@ -255,6 +255,7 @@ export const matStore: MatState = proxy<MatState>({
result: ygopro.StocGameMessage.MsgWin.ActionType.UNKNOWN,
waiting: false,
unimplemented: 0,
delay: 0,
// methods
in: getZone,
isMe,
......
......@@ -94,6 +94,8 @@ export interface MatState {
unimplemented: number; // 未处理的`Message`
delay: number; // MSG处理的延迟时间,目的时为了让一些动画处理完后再开始处理下一个MSG
// >>> methods >>>
/** 根据zone获取hands/masters/magics... */
in: (zone: ygopro.CardZone) => BothSide<DuelFieldState>;
......
......@@ -59,7 +59,9 @@ export const Card: React.FC<{
"--shadow": hight > 0 ? 1 : 0,
"--opponent-deg": opponent ? "180deg" : "0deg",
"--vertical": vertical ? 1 : 0,
"--trans-time": `${transTime}s`,
"--trans-time": `${
chaining ? NeosConfig.ui.chainingDelay / 1000 : transTime
}s`,
"--highlight-on": highlight ? 1 : 0,
"--scale-focus": focus ? FOCUS_SCALE : 1,
"--card-img": facedown
......
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