Commit 79611cf5 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'opt/hint/phase' into 'main'

Opt/hint/phase

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