Commit 8f88a541 authored by Chunchi Che's avatar Chunchi Che

add chains in matStore

parent d7e76762
import { ygopro } from "@/api";
import { matStore } from "@/stores";
export default (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => {
console.log(chainSolved);
const location = matStore.chains
.splice(chainSolved.solved_index - 1, 1)
.at(0);
if (location) {
// 设置被连锁状态为false
matStore.setChained(location, false);
} else {
console.warn("pop from chains return null!");
}
};
......@@ -12,6 +12,12 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
matStore.setChaining(chaining.location, chaining.code, true);
await sleep(useConfig().ui.chainingDelay);
matStore.setChaining(chaining.location, chaining.code, false);
// TODO: set chained
const location = chaining.location;
// 恢复成非`chaining`状态
matStore.setChaining(location, chaining.code, false);
// 将`location`添加到连锁栈
matStore.chains.push(location);
// 设置被连锁状态
matStore.setChained(location, true);
};
......@@ -52,6 +52,7 @@ function reloadDuelField(
counters: {},
focus: false,
chaining: false,
chained: false, // TODO: 这里是否能简单设置成false?
directAttack: false,
reload: true,
};
......
......@@ -41,6 +41,7 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
},
focus: false,
chaining: false,
chained: false,
directAttack: false,
counters: {},
idleInteractivities: [],
......@@ -60,6 +61,7 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
},
focus: false,
chaining: false,
chained: false,
directAttack: false,
counters: {},
idleInteractivities: [],
......@@ -80,6 +82,7 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
},
focus: false,
chaining: false,
chained: false,
directAttack: false,
counters: {},
idleInteractivities: [],
......
......@@ -43,6 +43,7 @@ class CardArray extends Array<CardState> implements ArrayCardState {
},
focus: focus ?? false,
chaining: false,
chained: false,
directAttack: false,
counters: {},
idleInteractivities: [],
......@@ -165,6 +166,7 @@ const genBlock = (zone: ygopro.CardZone, n: number) =>
},
focus: false,
chaining: false,
chained: false,
directAttack: false,
idleInteractivities: [],
counters: {},
......@@ -234,6 +236,8 @@ export const matStore: MatState = proxy<MatState>({
decks: genDuelCardArray([], DECK),
extraDecks: genDuelCardArray([], EXTRA),
chains: [],
timeLimits: {
// 时间限制
me: -1,
......@@ -279,6 +283,14 @@ export const matStore: MatState = proxy<MatState>({
}
}
},
setChained(location, isChained) {
const target = this.in(location.location)
.of(location.controler)
.at(location.sequence);
if (target) {
target.chained = isChained;
}
},
});
// @ts-ignore 挂到全局,便于调试
......
......@@ -78,6 +78,8 @@ export interface MatState {
extraDecks: BothSide<ExtraDeckState>; // 双方的额外卡组状态
chains: ygopro.CardLocation[]; // 连锁的卡片位置
timeLimits: BothSide<number> & {
set: (controller: number, time: number) => void;
}; // 双方的时间限制
......@@ -109,6 +111,8 @@ export interface MatState {
code: number,
isChaining: boolean
) => void;
// 添加被连锁状态
setChained: (location: ygopro.CardLocation, isChained: boolean) => void;
}
export interface InitInfo {
......@@ -132,6 +136,7 @@ export interface CardState {
}; // 位置信息,叫location的原因是为了和ygo对齐
focus: boolean; // 用于实现动画效果,当这个字段为true时,该张卡片会被放大并在屏幕中央展示
chaining: boolean; // 是否在连锁中
chained: boolean; // 是否被连锁,如果为true,这张卡片表面会加上枷锁
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