Commit d2f7bbd2 authored by chechunchi's avatar chechunchi

update playerStore

parent 9cb94232
Pipeline #21801 passed with stages
in 19 minutes and 19 seconds
......@@ -8,6 +8,7 @@ export default function handleTypeChange(pb: ygopro.YgoStocMsg) {
const assertHost = pb.stoc_type_change.is_host;
playerStore.isHost = assertHost;
playerStore.selfType = selfType;
if (assertHost) {
switch (selfType) {
......
import { proxy } from "valtio";
import { ygopro } from "@/api";
import SelfType = ygopro.StocTypeChange.SelfType;
export interface Player {
name?: string;
state?: string;
......@@ -18,6 +21,9 @@ export interface PlayerState {
player1: Player;
observerCount: number;
isHost: boolean;
selfType: SelfType;
getMePlayer: () => Player;
getOpPlayer: () => Player;
}
export const playerStore = proxy<PlayerState>({
......@@ -25,4 +31,13 @@ export const playerStore = proxy<PlayerState>({
player1: {},
observerCount: 0,
isHost: false,
selfType: SelfType.UNKNOWN,
getMePlayer() {
if (this.selfType == SelfType.PLAYER1) return this.player0;
return this.player1;
},
getOpPlayer() {
if (this.selfType == SelfType.PLAYER1) return this.player1;
return this.player0;
},
});
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