Commit e2a917bf authored by chechunchi's avatar chechunchi

optimize phase hint

parent 2d11321c
import { ygopro } from "@/api";
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
//! 一些Neos中基础的数据结构
// 类型
......@@ -220,3 +222,16 @@ export const QUERY_STATUS = 0x80000;
export const QUERY_LSCALE = 0x200000;
export const QUERY_RSCALE = 0x400000;
export const QUERY_LINK = 0x800000;
export const Phase2StringCodeMap: Map<number, number> = new Map([
[PhaseType.DRAW, 20],
[PhaseType.STANDBY, 21],
[PhaseType.MAIN1, 22],
[PhaseType.BATTLE_START, 28],
[PhaseType.BATTLE_STEP, 29],
[PhaseType.DAMAGE, 40],
[PhaseType.DAMAGE_GAL, 42],
[PhaseType.BATTLE, 24],
[PhaseType.MAIN2, 22],
[PhaseType.END, 26],
]);
import { ygopro } from "@/api";
import { matStore, type PhaseName } from "@/stores";
import { matStore } from "@/stores";
export default (newPhase: ygopro.StocGameMessage.MsgNewPhase) => {
// ts本身还没有这么智能,所以需要手动指定类型
const currentPhase = ygopro.StocGameMessage.MsgNewPhase.PhaseType[
newPhase.phase_type
] as PhaseName;
matStore.phase.currentPhase = currentPhase;
matStore.phase.currentPhase = newPhase.phase_type;
};
......@@ -232,7 +232,7 @@ export const matStore: MatState = proxy<MatState>({
hint,
currentPlayer: -1,
phase: {
currentPhase: "UNKNOWN", // TODO 当前的阶段 应该改成enum
currentPhase: ygopro.StocGameMessage.MsgNewPhase.PhaseType.UNKNOWN, // TODO 当前的阶段 应该改成enum
enableBp: false, // 允许进入战斗阶段
enableM2: false, // 允许进入M2阶段
enableEp: false, // 允许回合结束
......
......@@ -189,11 +189,8 @@ export interface HintState {
esSelectHint?: string;
}
export type PhaseName =
keyof typeof ygopro.StocGameMessage.MsgNewPhase.PhaseType;
export interface PhaseState {
currentPhase: PhaseName; // TODO 当前的阶段 应该改成enum
currentPhase: ygopro.StocGameMessage.MsgNewPhase.PhaseType; // TODO 当前的阶段 应该改成enum
enableBp: boolean; // 允许进入战斗阶段
enableM2: boolean; // 允许进入M2阶段
enableEp: boolean; // 允许回合结束
......
......@@ -3,7 +3,8 @@ import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useSnapshot } from "valtio";
import { ygopro } from "@/api";
import { fetchStrings, ygopro } from "@/api";
import { Phase2StringCodeMap } from "@/common";
import { useConfig } from "@/config";
import { matStore } from "@/stores";
......@@ -41,7 +42,10 @@ export const HintNotification = () => {
useEffect(() => {
if (currentPhase) {
api.open({
message: `<当前阶段>${currentPhase}`,
message: fetchStrings(
"!system",
Phase2StringCodeMap.get(currentPhase) ?? 0
),
placement: "topRight",
style: style,
});
......@@ -51,7 +55,7 @@ export const HintNotification = () => {
useEffect(() => {
if (waiting) {
api.open({
message: "...等待对方行动中...",
message: fetchStrings("!system", 1390),
placement: "top",
duration: NeosConfig.ui.hint.waitingDuration,
style: style,
......
......@@ -8,23 +8,13 @@ import {
sendSelectBattleCmdResponse,
sendSelectIdleCmdResponse,
sendSurrender,
ygopro,
} from "@/api";
import {
clearAllIdleInteractivities as clearAllIdleInteractivities,
matStore,
} from "@/stores";
const PhaseButton = (props: {
text: string;
enable: boolean;
onClick: () => void;
}) => {
return (
<button disabled={!props.enable} onClick={props.onClick}>
{props.text}
</button>
);
};
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
const { phase } = matStore;
......@@ -38,11 +28,11 @@ export const Menu = () => {
const [modalOpen, setModalOpen] = useState(false);
const response =
currentPhase === "BATTLE_START" ||
currentPhase === "BATTLE_STEP" ||
currentPhase === "DAMAGE" ||
currentPhase === "DAMAGE_GAL" ||
currentPhase === "BATTLE"
currentPhase === PhaseType.BATTLE_START ||
currentPhase === PhaseType.BATTLE_STEP ||
currentPhase === PhaseType.DAMAGE ||
currentPhase === PhaseType.DAMAGE_GAL ||
currentPhase === PhaseType.BATTLE
? 3
: 7;
......
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