Commit bb9cecc2 authored by timel's avatar timel

fix: remove players' names in matStore

parent 1a692983
...@@ -16,18 +16,13 @@ export default (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -16,18 +16,13 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
? 1 ? 1
: 0; : 0;
const meName = playerStore.getMePlayer().name;
const opName = playerStore.getOpPlayer().name;
matStore.initInfo.set(0, { matStore.initInfo.set(0, {
life: start.life1, life: start.life1,
name: opponent == 0 ? opName : meName,
deckSize: start.deckSize1, deckSize: start.deckSize1,
extraSize: start.extraSize1, extraSize: start.extraSize1,
}); });
matStore.initInfo.set(1, { matStore.initInfo.set(1, {
life: start.life2, life: start.life2,
name: opponent == 1 ? opName : meName,
deckSize: start.deckSize2, deckSize: start.deckSize2,
extraSize: start.extraSize2, extraSize: start.extraSize2,
}); });
......
...@@ -52,10 +52,6 @@ const initInfo: MatState["initInfo"] = (() => { ...@@ -52,10 +52,6 @@ const initInfo: MatState["initInfo"] = (() => {
}); });
})(); })();
const hint: MatState["hint"] = proxy({
code: -1,
});
/** /**
* 💡 决斗盘状态仓库,本文件核心, * 💡 决斗盘状态仓库,本文件核心,
* 具体介绍可以点进`MatState`去看 * 具体介绍可以点进`MatState`去看
...@@ -76,7 +72,7 @@ export const matStore: MatState = proxy<MatState>({ ...@@ -76,7 +72,7 @@ export const matStore: MatState = proxy<MatState>({
initInfo, initInfo,
selfType: ygopro.StocTypeChange.SelfType.UNKNOWN, selfType: ygopro.StocTypeChange.SelfType.UNKNOWN,
hint, hint: { code: -1 },
currentPlayer: -1, currentPlayer: -1,
phase: { phase: {
currentPhase: ygopro.StocGameMessage.MsgNewPhase.PhaseType.UNKNOWN, // TODO 当前的阶段 应该改成enum currentPhase: ygopro.StocGameMessage.MsgNewPhase.PhaseType.UNKNOWN, // TODO 当前的阶段 应该改成enum
......
...@@ -40,7 +40,6 @@ export interface MatState { ...@@ -40,7 +40,6 @@ export interface MatState {
export interface InitInfo { export interface InitInfo {
masterRule?: string; masterRule?: string;
name: string;
life: number; life: number;
deckSize: number; deckSize: number;
extraSize: number; extraSize: number;
......
...@@ -3,15 +3,20 @@ import "./index.scss"; ...@@ -3,15 +3,20 @@ import "./index.scss";
import React from "react"; import React from "react";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { matStore } from "@/stores"; import { matStore, playerStore } from "@/stores";
export const LifeBar: React.FC = () => { export const LifeBar: React.FC = () => {
const snap = useSnapshot(matStore.initInfo); const snap = useSnapshot(matStore.initInfo);
const snapPlayer = useSnapshot(playerStore);
return ( return (
<div id="life-bar-container"> <div id="life-bar-container">
<div id="life-bar">{`${snap.me.name}: ${snap.me.life}`}</div> <div id="life-bar">{`${snapPlayer.getMePlayer().name}: ${
<div id="life-bar">{`${snap.op.name}: ${snap.op.life}`}</div> snap.me.life
}`}</div>
<div id="life-bar">{`${snapPlayer.getOpPlayer().name}: ${
snap.op.life
}`}</div>
</div> </div>
); );
}; };
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