Commit 26cf22d9 authored by timel's avatar timel

fix: hp never change

parent 5908057f
Pipeline #21380 passed with stages
in 18 minutes and 56 seconds
...@@ -132,16 +132,6 @@ const isMe = (controller: number): boolean => { ...@@ -132,16 +132,6 @@ const isMe = (controller: number): boolean => {
} }
}; };
const genDuelNormal = <T extends {}>(meObj: T): BothSide<T> => {
// 提供opObj是为了让meObj和opObj的类型可以不同,避免深拷贝的坑...
const res = {
me: { ...meObj },
op: { ...meObj },
of: (controller: number) => res[getWhom(controller)],
};
return res;
};
/** /**
* 生成一个指定长度的卡片数组 * 生成一个指定长度的卡片数组
*/ */
...@@ -156,20 +146,25 @@ const genBlock = (location: ygopro.CardZone, n: number) => ...@@ -156,20 +146,25 @@ const genBlock = (location: ygopro.CardZone, n: number) =>
counters: {}, counters: {},
})); }));
const initInfo: MatState["initInfo"] = proxy({ const initInfo: MatState["initInfo"] = (() => {
...genDuelNormal({ const defaultInitInfo = {
masterRule: "UNKNOWN", masterRule: "UNKNOWN",
life: -1, // 特地设置一个不可能的值 life: -1, // 特地设置一个不可能的值
deckSize: 0, deckSize: 0,
extraSize: 0, extraSize: 0,
}), };
set: (controller: number, obj: Partial<InitInfo>) => { return proxy({
initInfo[getWhom(controller)] = { me: { ...defaultInitInfo },
...initInfo[getWhom(controller)], op: { ...defaultInitInfo },
...obj, of: (controller: number) => initInfo[getWhom(controller)],
}; set: (controller: number, obj: Partial<InitInfo>) => {
}, initInfo[getWhom(controller)] = {
}); ...initInfo[getWhom(controller)],
...obj,
};
},
});
})();
const hint: MatState["hint"] = proxy({ const hint: MatState["hint"] = proxy({
code: -1, code: -1,
...@@ -217,7 +212,8 @@ export const matStore: MatState = proxy<MatState>({ ...@@ -217,7 +212,8 @@ export const matStore: MatState = proxy<MatState>({
timeLimits: { timeLimits: {
// 时间限制 // 时间限制
...genDuelNormal(-1), me: -1,
op: -1,
of: (controller: number) => matStore.timeLimits[getWhom(controller)], of: (controller: number) => matStore.timeLimits[getWhom(controller)],
set: (controller: number, time: number) => { set: (controller: number, time: number) => {
matStore.timeLimits[getWhom(controller)] = time; matStore.timeLimits[getWhom(controller)] = time;
......
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