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