Commit 8e006333 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'optimize/select_action_modal' into 'main'

修复一些小问题

See merge request mycard/Neos!310
parents 79f1f957 2aaf7b86
Pipeline #23444 passed with stages
in 13 minutes and 38 seconds
import { ygopro } from "@/api";
import { matStore } from "@/stores";
import { replayStore } from "@/stores";
import { showWaiting } from "@/ui/Duel/Message";
import onAnnounce from "./announce";
......@@ -83,6 +83,7 @@ const ReplayIgnoreMsg = [
"select_yes_no",
"select_tribute",
"select_counter",
"select_sum",
"rock_paper_scissors",
"sort_card",
"announce",
......@@ -97,7 +98,7 @@ export default async function handleGameMsg(
showWaiting(false);
}
if (matStore.isReplay && ReplayIgnoreMsg.includes(msg.gameMsg)) return;
if (replayStore.isReplay && ReplayIgnoreMsg.includes(msg.gameMsg)) return;
switch (msg.gameMsg) {
case "start": {
......
......@@ -7,6 +7,7 @@ import { sleep } from "@/infra";
import {
cardStore,
matStore,
replayStore,
RoomStage,
roomStore,
SideStage,
......@@ -91,7 +92,7 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
.at(ygopro.CardZone.EXTRA, 1 - opponent)
.forEach((card) => (card.code = window.myExtraDeckCodes?.pop() ?? 0));
if (matStore.isReplay) {
if (replayStore.isReplay) {
replayStart();
}
......
......@@ -4,7 +4,7 @@
* */
import { adaptStoc } from "@/api/ocgcore/ocgAdapter/adapter";
import { YgoProPacket } from "@/api/ocgcore/ocgAdapter/packet";
import { matStore, replayStore } from "@/stores";
import { replayStore } from "@/stores";
import handleGameMsg from "./duel/gameMsg";
import handleTimeLimit from "./duel/timeLimit";
......@@ -93,7 +93,7 @@ async function _handle(e: MessageEvent) {
case "stoc_game_msg": {
await handleGameMsg(pb);
if (!matStore.isReplay) {
if (!replayStore.isReplay) {
// 如果不是回放模式,则记录回放数据
replayStore.record(packet);
}
......
......@@ -73,7 +73,6 @@ const initialState: Omit<MatState, "reset"> = {
enableM2: false, // 允许进入M2阶段
enableEp: false, // 允许回合结束
},
isReplay: false,
unimplemented: 0,
handResults: {
me: 0,
......@@ -99,7 +98,6 @@ class MatStore implements MatState, NeosStore {
hint = initialState.hint;
currentPlayer = initialState.currentPlayer;
phase = initialState.phase;
isReplay = initialState.isReplay;
unimplemented = initialState.unimplemented;
handResults = initialState.handResults;
tossResult = initialState.tossResult;
......@@ -121,7 +119,6 @@ class MatStore implements MatState, NeosStore {
enableM2: false, // 允许进入M2阶段
enableEp: false, // 允许回合结束
};
this.isReplay = false;
this.unimplemented = 0;
this.handResults.me = 0;
this.handResults.op = 0;
......
......@@ -30,8 +30,6 @@ export interface MatState {
phase: PhaseState;
isReplay: boolean; // 是否是回放模式
unimplemented: number; // 未处理的`Message`
tossResult?: string; // 骰子/硬币结果
......
......@@ -17,6 +17,7 @@ interface ReplayPacket {
// 保存对局回放数据的`Store`
class ReplayStore implements NeosStore {
isReplay: boolean = false; // 是否进入了回放模式
inner: ReplaySpot[] = ref([]);
record(ygoPacket: YgoProPacket) {
this.inner.push({
......@@ -28,6 +29,7 @@ class ReplayStore implements NeosStore {
}
reset() {
this.inner.splice(0);
this.isReplay = false;
}
}
......
......@@ -2,7 +2,7 @@ import React, { CSSProperties } from "react";
import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region } from "@/api";
import { matStore, replayStore, resetDuel } from "@/stores";
import { replayStore, resetDuel } from "@/stores";
import { NeosModal } from "../NeosModal";
import styles from "./index.module.scss";
......@@ -22,7 +22,7 @@ const localStore = proxy(defaultProps);
export const EndModal: React.FC = () => {
const { isOpen, isWin, reason } = useSnapshot(localStore);
const { isReplay } = useSnapshot(matStore);
const { isReplay } = useSnapshot(replayStore);
const onReturn = () => {
resetDuel();
......
......@@ -91,7 +91,7 @@ export const Menu = () => {
const phaseSwitchItems: MenuProps["items"] = phaseBind
.filter(([, , , show]) => show)
.map(([phase, label, response], key) => ({
.map(([phase, label, response, _], key) => ({
key,
label,
disabled: currentPhase >= phase || !checkPhaseEnabled(phase),
......
......@@ -3,7 +3,7 @@ import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { proxy, useSnapshot } from "valtio";
import { matStore } from "@/stores";
import { replayStore } from "@/stores";
import { Uploader } from "../Shared";
import { connectSrvpro } from "./util";
......@@ -39,7 +39,7 @@ export const ReplayModal: React.FC = () => {
setLoading(true);
// 标记为回放模式
matStore.isReplay = true;
replayStore.isReplay = true;
// 初始化额外卡组
// FIXME: 这样写应该不对,有空来修
......
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