Commit 9a562f46 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/menu' into 'main'

修复偶现的进入不了战阶的问题

See merge request mycard/Neos!318
parents 08c20a9b c434241e
Pipeline #23492 passed with stages
in 21 minutes and 1 second
...@@ -8,8 +8,6 @@ export const DESCRIPTION_LIMIT = 10000; ...@@ -8,8 +8,6 @@ export const DESCRIPTION_LIMIT = 10000;
export async function initStrings() { export async function initStrings() {
const strings = await (await fetch(stringsUrl)).text(); const strings = await (await fetch(stringsUrl)).text();
console.log({ strings });
const lineIter = strings.split("\n"); const lineIter = strings.split("\n");
for (const line of lineIter) { for (const line of lineIter) {
if (!line.startsWith("#") && line !== "") { if (!line.startsWith("#") && line !== "") {
......
...@@ -30,14 +30,10 @@ import { IconFont } from "@/ui/Shared"; ...@@ -30,14 +30,10 @@ import { IconFont } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType; import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
const { phase } = matStore; const { phase: store } = matStore;
const { useToken } = theme; const { useToken } = theme;
export const Menu = () => { export const Menu = () => {
const snapPhase = useSnapshot(phase); const { enableBp, enableM2, enableEp, currentPhase } = useSnapshot(store);
const currentPhase = snapPhase.currentPhase;
const enableBp = snapPhase.enableBp;
const enableM2 = snapPhase.enableM2;
const enableEp = snapPhase.enableEp;
const { currentPlayer, chainSetting } = useSnapshot(matStore); const { currentPlayer, chainSetting } = useSnapshot(matStore);
const clearAllIdleInteractivities = () => { const clearAllIdleInteractivities = () => {
...@@ -56,52 +52,40 @@ export const Menu = () => { ...@@ -56,52 +52,40 @@ export const Menu = () => {
? 3 ? 3
: 7; : 7;
// PhaseType, 中文, response, 是否显示 // PhaseType, 中文, response, 是否显示,是否禁用
const phaseBind: [ const phaseBind: [
phase: PhaseType, phase: PhaseType,
label: string, label: string,
response: number, response: number,
show: boolean, show: boolean,
disabled: boolean,
][] = [ ][] = [
[PhaseType.DRAW, "抽卡阶段", -1, true], [PhaseType.DRAW, "抽卡阶段", -1, true, true],
[PhaseType.STANDBY, "准备阶段", -1, true], [PhaseType.STANDBY, "准备阶段", -1, true, true],
[PhaseType.MAIN1, "主要阶段 1", -1, true], [PhaseType.MAIN1, "主要阶段 1", -1, true, true],
[PhaseType.BATTLE, "战斗阶段", 6, true], [PhaseType.BATTLE, "战斗阶段", 6, true, !enableBp],
[PhaseType.BATTLE_START, "战斗开始", 3, false], [PhaseType.BATTLE_START, "战斗开始", 3, false, true],
[PhaseType.BATTLE_STEP, "战斗步骤", 3, false], [PhaseType.BATTLE_STEP, "战斗步骤", 3, false, true],
[PhaseType.DAMAGE, "伤害步骤", 3, false], [PhaseType.DAMAGE, "伤害步骤", 3, false, true],
[PhaseType.DAMAGE_GAL, "伤害步骤(伤害计算)", 3, false], [PhaseType.DAMAGE_GAL, "伤害步骤(伤害计算)", 3, false, true],
[PhaseType.MAIN2, "主要阶段 2", 2, true], [PhaseType.MAIN2, "主要阶段 2", 2, true, !enableM2],
[PhaseType.END, "结束阶段", endResponse, true], [PhaseType.END, "结束阶段", endResponse, true, !enableEp],
[PhaseType.UNKNOWN, "未知阶段", -1, false], [PhaseType.UNKNOWN, "未知阶段", -1, false, true],
]; ];
const checkPhaseEnabled = (phase: PhaseType) => {
switch (phase) {
case PhaseType.BATTLE:
return enableBp;
case PhaseType.MAIN2:
return enableM2;
case PhaseType.END:
return enableEp;
default:
return true;
}
};
const phaseSwitchItems: MenuProps["items"] = phaseBind const phaseSwitchItems: MenuProps["items"] = phaseBind
.filter(([, , , show]) => show) .filter(([, , , show]) => show)
.map(([phase, label, response, _], key) => ({ .map(([phase, label, response, _, disabled], key) => ({
key, key,
label, label,
disabled: currentPhase >= phase || !checkPhaseEnabled(phase), disabled: store.currentPhase >= phase || disabled,
onClick: () => { onClick: () => {
if (response === 2) sendSelectIdleCmdResponse(response); if (response === 2) sendSelectIdleCmdResponse(response);
else sendSelectBattleCmdResponse(response); else sendSelectBattleCmdResponse(response);
clearAllIdleInteractivities(); clearAllIdleInteractivities();
}, },
icon: icon:
currentPhase >= phase || !checkPhaseEnabled(phase) ? ( store.currentPhase >= phase || disabled ? (
<CheckOutlined /> <CheckOutlined />
) : ( ) : (
<ArrowRightOutlined /> <ArrowRightOutlined />
......
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