Commit c7647f21 authored by Chunchi Che's avatar Chunchi Che

fix small in chaining

parent d38980b4
Pipeline #21744 failed with stages
in 13 minutes and 20 seconds
......@@ -49,20 +49,12 @@ export interface CardText {
* @returns 卡片数据
*
* */
export async function fetchCard(
id: number,
local: boolean = true
): Promise<CardMeta> {
if (local) {
const res = await sqliteMiddleWare({
cmd: sqliteCmd.SELECT,
payload: { id },
});
return res.selectResult ? res.selectResult : { id, data: {}, text: {} };
}
const res = await axios.get<CardMeta>("http://localhost:3030/cards/" + id);
return res.data;
export async function fetchCard(id: number): Promise<CardMeta> {
const res = await sqliteMiddleWare({
cmd: sqliteCmd.SELECT,
payload: { id },
});
return res.selectResult ? res.selectResult : { id, data: {}, text: {} };
}
export function getCardStr(meta: CardMeta, idx: number): string | undefined {
......
......@@ -9,13 +9,13 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
cardID: chaining.code,
});
matStore.setChaining(chaining.location, chaining.code, true);
await matStore.setChaining(chaining.location, chaining.code, true);
await sleep(useConfig().ui.chainingDelay);
const location = chaining.location;
// 恢复成非`chaining`状态
matStore.setChaining(location, chaining.code, false);
await matStore.setChaining(location, chaining.code, false);
// 将`location`添加到连锁栈
matStore.chains.push(location);
// 设置被连锁状态
......
......@@ -267,15 +267,17 @@ export const matStore: MatState = proxy<MatState>({
// methods
in: getZone,
isMe,
setChaining(location, code, isChaining) {
async setChaining(location, code, isChaining) {
const target = this.in(location.location)
.of(location.controler)
.at(location.sequence);
if (target) {
target.chaining = isChaining;
if (target.occupant && isChaining) {
// 目前需要判断`isChaining`为ture才设置id,因为有些手坑发效果后会move到墓地,运行到这里的时候已经和原来的位置对不上了,这时候不设置id
target.occupant.id = code;
// 目前需要判断`isChaining`为ture才设置meta,因为有些手坑发效果后会move到墓地,
// 运行到这里的时候已经和原来的位置对不上了,这时候不设置meta
const meta = await fetchCard(code);
target.occupant = meta;
}
if (target.location.zone == ygopro.CardZone.HAND) {
target.location.position = isChaining
......
......@@ -111,7 +111,7 @@ export interface MatState {
location: ygopro.CardLocation,
code: number,
isChaining: boolean
) => void;
) => Promise<void>;
// 添加被连锁状态
setChained: (location: ygopro.CardLocation, chainIndex?: number) => void;
}
......@@ -137,7 +137,8 @@ export interface CardState {
}; // 位置信息,叫location的原因是为了和ygo对齐
focus: boolean; // 用于实现动画效果,当这个字段为true时,该张卡片会被放大并在屏幕中央展示
chaining: boolean; // 是否在连锁中
chainIndex?: number; // 连锁的序号,如果为空表示不在连锁
chainIndex?: number /*连锁的序号,如果为空表示不在连锁
TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/;
directAttack: boolean; // 是否正在直接攻击为玩家
attackTarget?: CardState & { sequence: number; opponent: boolean }; // 攻击目标。(嵌套结构可行么?)
idleInteractivities: Interactivity<number>[]; // IDLE状态下的互动信息
......
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