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