Commit c60754fd authored by Chunchi Che's avatar Chunchi Che

fix chaining

parent 3184d713
Pipeline #21649 passed with stages
in 17 minutes and 57 seconds
......@@ -61,8 +61,8 @@ const NeosConfig = useConfig();
export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
// 防止MSG更新太频繁,做下控频
//
// TODO: 细化需要控频的MSG
const delay = matStore.delay;
setTimeout(() => {
const msg = pb.stoc_game_msg;
......@@ -70,9 +70,6 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
matStore.waiting = false;
}
// 先重置`delay`
matStore.delay = NeosConfig.ui.commonDelay;
switch (msg.gameMsg) {
case "start": {
onMsgStart(msg.start);
......@@ -112,8 +109,6 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
case "move": {
onMsgMove(msg.move);
matStore.delay = NeosConfig.ui.moveDelay + 500;
break;
}
case "select_card": {
......@@ -239,8 +234,6 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
case "chaining": {
onMsgChaining(msg.chaining);
matStore.delay += NeosConfig.ui.chainingDelay;
break;
}
case "chain_solved": {
......@@ -287,5 +280,5 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
}
}, matStore.delay);
}, delay);
}
......@@ -4,6 +4,7 @@ import { proxy } from "valtio";
import { ygopro } from "@/api";
import { fetchCard } from "@/api/cards";
import { useConfig } from "@/config";
import type {
CardState,
......@@ -255,16 +256,18 @@ export const matStore: MatState = proxy<MatState>({
result: ygopro.StocGameMessage.MsgWin.ActionType.UNKNOWN,
waiting: false,
unimplemented: 0,
delay: 0,
delay: useConfig().ui.commonDelay,
// methods
in: getZone,
isMe,
setChaining(location, code, isChaining) {
const target = this.in(location.location).of(location.controler)[
location.sequence
];
const target = this.in(location.location)
.of(location.controler)
.at(location.sequence);
if (target) {
target.chaining = isChaining;
if (target.occupant) {
if (target.occupant && isChaining) {
// 目前需要判断`isChaining`为ture才设置id,因为有些手坑发效果后会move到墓地,运行到这里的时候已经和原来的位置对不上了,这时候不设置id
target.occupant.id = code;
}
if (target.location.zone == ygopro.CardZone.HAND) {
......@@ -272,6 +275,7 @@ export const matStore: MatState = proxy<MatState>({
? ygopro.CardPosition.FACEUP_ATTACK
: ygopro.CardPosition.FACEDOWN_ATTACK;
}
}
},
});
......
......@@ -94,7 +94,7 @@ export interface MatState {
unimplemented: number; // 未处理的`Message`
delay: number; // MSG处理的延迟时间,目的时为了让一些动画处理完后再开始处理下一个MSG
delay: number; // MSG处理的延迟时间,目的时为了让一些动画处理完后再开始处理下一个MSG。TODO:正确处理与`timeLimit`的关系
// >>> methods >>>
/** 根据zone获取hands/masters/magics... */
......
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