Commit 2aaf7b86 authored by Chunchi Che's avatar Chunchi Che

修复一些小问题

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