Commit d6f16bf0 authored by Chunchi Che's avatar Chunchi Che

fix matStore compile error

parent 42a9b174
Pipeline #22927 failed with stages
in 15 minutes and 46 seconds
......@@ -3,6 +3,7 @@ import { proxy } from "valtio";
import { ygopro } from "@/api";
import { type NeosStore } from "../shared";
import { ChainSetting, InitInfo, MatState } from "./types";
/**
......@@ -53,8 +54,6 @@ const initInfo: MatState["initInfo"] = proxy({
const initialState: Omit<MatState, "reset"> = {
chains: [],
chainSetting: ChainSetting.CHAIN_SMART,
timeLimits: {
// 时间限制
me: -1,
......@@ -64,9 +63,7 @@ const initialState: Omit<MatState, "reset"> = {
matStore.timeLimits[getWhom(controller)] = time;
},
},
initInfo,
selfType: ygopro.StocTypeChange.SelfType.UNKNOWN,
hint: { code: -1 },
currentPlayer: -1,
......@@ -86,22 +83,28 @@ const initialState: Omit<MatState, "reset"> = {
matStore.handResults[getWhom(controller)] = result;
},
},
tossResult: undefined,
chainSetting: ChainSetting.CHAIN_SMART,
// methods
isMe,
};
/**
* 💡 决斗盘状态仓库,本文件核心,
* 具体介绍可以点进`MatState`去看
*/
export const matStore: MatState = proxy<MatState>({
...initialState,
reset() {
// const resetObj = _.cloneDeep(initialState);
// Object.keys(resetObj).forEach((key) => {
// // @ts-ignore
// matStore[key] = initialState[key];
// });
class MatStore implements MatState, NeosStore {
chains = initialState.chains;
chainSetting = initialState.chainSetting;
timeLimits = initialState.timeLimits;
initInfo = initialState.initInfo;
selfType = initialState.selfType;
hint = initialState.hint;
currentPlayer = initialState.currentPlayer;
phase = initialState.phase;
isReplay = initialState.isReplay;
unimplemented = initialState.unimplemented;
handResults = initialState.handResults;
tossResult = initialState.tossResult;
// methods
isMe = initialState.isMe;
reset(): void {
this.chains = [];
this.timeLimits.me = -1;
this.timeLimits.op = -1;
......@@ -120,8 +123,14 @@ export const matStore: MatState = proxy<MatState>({
this.unimplemented = 0;
this.handResults.me = 0;
this.handResults.op = 0;
},
});
}
}
/**
* 💡 决斗盘状态仓库,本文件核心,
* 具体介绍可以点进`MatState`去看
*/
export const matStore = proxy<MatStore>(new MatStore());
// @ts-ignore 挂到全局,便于调试
window.matStore = matStore;
import type { ygopro } from "@/api";
import { NeosStore } from "../shared";
// >>> play mat state >>>
export interface BothSide<T> {
......@@ -11,7 +9,7 @@ export interface BothSide<T> {
of: (controller: number) => T;
}
export interface MatState extends NeosStore {
export interface MatState {
selfType: number;
initInfo: BothSide<InitInfo> & {
......
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