Commit 16aaeaa3 authored by Chunchi Che's avatar Chunchi Che

add block state in matStore

parent 4691e0ef
......@@ -7,8 +7,11 @@ import { fetchCard, ygopro } from "@/api";
import { cardStore, CardType, playerStore, store } from "@/stores";
const { matStore } = store;
const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token
const MZONE_SIZE = 7; // 普通怪兽区 + 额外怪兽区
const SZONE_SIZE = 6; // 普通魔陷区 + 场地区
export default (start: ygopro.StocGameMessage.MsgStart) => {
// 先初始化`matStore`
matStore.selfType = start.playerType;
const opponent =
start.playerType == ygopro.StocGameMessage.MsgStart.PlayerType.FirstStrike
......@@ -31,7 +34,41 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
extraSize: start.extraSize2,
});
// 下面是cardStore的初始化
for (let sequence = 0; sequence < MZONE_SIZE; sequence++) {
matStore.blocks.push({
location: {
zone: ygopro.CardZone.MZONE,
controller: 0,
sequence,
},
});
matStore.blocks.push({
location: {
zone: ygopro.CardZone.MZONE,
controller: 1,
sequence,
},
});
}
for (let sequence = 0; sequence < SZONE_SIZE; sequence++) {
matStore.blocks.push({
location: {
zone: ygopro.CardZone.SZONE,
controller: 0,
sequence,
},
});
matStore.blocks.push({
location: {
zone: ygopro.CardZone.SZONE,
controller: 1,
sequence,
},
});
}
// 再初始化`cardStore`
const cards = flatten(
[
......
......@@ -16,6 +16,8 @@ export interface MatState {
set: (controller: number, obj: Partial<InitInfo>) => void;
}; // 双方的初始化信息
blocks: BlockState[]; // 场上`Block`信息,比如怪兽区,墓地等
chains: ygopro.CardLocation[]; // 连锁的卡片位置
timeLimits: BothSide<number> & {
......@@ -38,6 +40,22 @@ export interface MatState {
isMe: (player: number) => boolean;
}
export interface BlockState {
// `Block`的位置
location: {
controller: number;
zone: ygopro.CardZone;
sequence: number;
};
// 位置选择信息,如果当前`Block`可以被选择作为
// 怪兽召唤/发动魔陷的位置时,该字段会被设置
selectInfo?: Interactivity<{
controler: number;
zone: ygopro.CardZone;
sequence: number;
}>;
}
export interface InitInfo {
masterRule?: string;
name: string;
......
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