Commit 421c3731 authored by Chunchi Che's avatar Chunchi Che

update small

parent 4cf436dc
Pipeline #22699 passed with stages
in 12 minutes and 29 seconds
/* eslint valtio/avoid-this-in-proxy: 0 */ /* eslint valtio/avoid-this-in-proxy: 0 */
import { Omit } from "@react-spring/web"; import { Omit } from "@react-spring/web";
import { proxy } from "valtio"; import { proxy } from "valtio";
import _ from "lodash";
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import type { InitInfo, MatState } from "./types"; import type { InitInfo, MatState } from "./types";
...@@ -99,11 +99,11 @@ const initialState: Omit<MatState, "reset"> = { ...@@ -99,11 +99,11 @@ const initialState: Omit<MatState, "reset"> = {
export const matStore: MatState = proxy<MatState>({ export const matStore: MatState = proxy<MatState>({
...initialState, ...initialState,
reset() { reset() {
// Object.keys(initialState).forEach((key) => { // const resetObj = _.cloneDeep(initialState);
// Object.keys(resetObj).forEach((key) => {
// // @ts-ignore // // @ts-ignore
// matStore[key] = initialState[key]; // matStore[key] = initialState[key];
// }); // });
// 同`PlayerStore`,不知道为啥这样写状态不能更新,暂时采用比较笨的方法
this.chains = []; this.chains = [];
this.timeLimits.me = -1; this.timeLimits.me = -1;
this.timeLimits.op = -1; this.timeLimits.op = -1;
......
/* eslint valtio/avoid-this-in-proxy: 0 */ /* eslint valtio/avoid-this-in-proxy: 0 */
import _ from "lodash";
import { proxy } from "valtio"; import { proxy } from "valtio";
import { ygopro } from "@/api"; import { ygopro } from "@/api";
...@@ -47,15 +48,10 @@ export const playerStore = proxy<PlayerState>({ ...@@ -47,15 +48,10 @@ export const playerStore = proxy<PlayerState>({
return this.player0; return this.player0;
}, },
reset() { reset() {
// Object.keys(initialState).forEach((key) => { const resetObj = _.cloneDeep(initialState);
// // @ts-ignore Object.keys(resetObj).forEach((key) => {
// playerStore[key] = initialState[key]; // @ts-ignore
// }); playerStore[key] = resetObj[key];
// 不知道为啥上面这样写状态不能更新,暂时采用比较笨的方法 });
this.player0 = {};
this.player1 = {};
this.observerCount = 0;
this.isHost = false;
this.selfType = SelfType.UNKNOWN;
}, },
}); });
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