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