Commit 667cb96c authored by chechunchi's avatar chechunchi

remove chaining props in CardType

parent 131e1918
...@@ -8,18 +8,17 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => { ...@@ -8,18 +8,17 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
cardID: chaining.code, cardID: chaining.code,
}); });
await cardStore.setChaining(chaining.location, chaining.code, true);
const location = chaining.location; const location = chaining.location;
// 恢复成非`chaining`状态
await cardStore.setChaining(location, chaining.code, false);
// 将`location`添加到连锁栈 // 将`location`添加到连锁栈
matStore.chains.push(location); matStore.chains.push(location);
// 设置被连锁状态
const target = cardStore.find(location); const target = cardStore.find(location);
if (target) { if (target) {
// 设置连锁序号
target.chainIndex = matStore.chains.length; target.chainIndex = matStore.chains.length;
// 发动效果动画
await eventbus.call(Task.Focus, target.uuid); await eventbus.call(Task.Focus, target.uuid);
console.color("blue")(`${target.meta.text.name} chaining`); console.color("blue")(`${target.meta.text.name} chaining`);
} else { } else {
......
...@@ -63,7 +63,6 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -63,7 +63,6 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
text: {}, text: {},
}, },
isToken: !((i + 1) % 3), isToken: !((i + 1) % 3),
chaining: false,
}) })
) )
) )
......
import { proxy } from "valtio"; import { proxy } from "valtio";
import { CardMeta, fetchCard, ygopro } from "@/api"; import { CardMeta, ygopro } from "@/api";
import type { Interactivity } from "./matStore/types"; import type { Interactivity } from "./matStore/types";
...@@ -23,7 +23,6 @@ export interface CardType { ...@@ -23,7 +23,6 @@ export interface CardType {
reload?: boolean; // 这个字段会在收到MSG_RELOAD_FIELD的时候设置成true,在收到MSG_UPDATE_DATE的时候设置成false reload?: boolean; // 这个字段会在收到MSG_RELOAD_FIELD的时候设置成true,在收到MSG_UPDATE_DATE的时候设置成false
isToken: boolean; // 是否是token isToken: boolean; // 是否是token
chaining: boolean; // 是否在连锁中
chainIndex?: number /*连锁的序号,如果为空表示不在连锁 chainIndex?: number /*连锁的序号,如果为空表示不在连锁
TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/; TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/;
} }
...@@ -92,30 +91,6 @@ class CardStore { ...@@ -92,30 +91,6 @@ class CardStore {
card.location.is_overlay card.location.is_overlay
); );
} }
async setChaining(
location: ygopro.CardLocation,
code: number,
isChaining: boolean
): Promise<void> {
const target = this.find(location);
if (target) {
target.chaining = isChaining;
if (isChaining) {
// 目前需要判断`isChaining`为ture才设置meta,因为有些手坑发效果后会move到墓地,
// 运行到这里的时候已经和原来的位置对不上了,这时候不设置meta
const meta = await fetchCard(code);
// 这里不能设置`code`,因为存在一个场景:
// 对方的`魔神仪-曼德拉护肤草`发动效果后,后端会发一次`MSG_SHUFFLE_HAND`,但传给前端的codes全是0,如果这里设置了`code`的话,在后面的`MSG_SHUFFLE_HAND`处理就会有问题。
// target.code = meta.id;
target.meta = meta;
}
if (target.location.zone == ygopro.CardZone.HAND) {
target.location.position = isChaining
? ygopro.CardPosition.FACEUP_ATTACK
: ygopro.CardPosition.FACEDOWN_ATTACK;
}
}
}
} }
export const cardStore = proxy(new CardStore()); export const cardStore = proxy(new CardStore());
......
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