Commit 11a974ad authored by Chunchi Che's avatar Chunchi Che

add auto return to single mode

parent 102cf9fc
Pipeline #28717 passed with stages
in 19 minutes and 53 seconds
......@@ -3,6 +3,11 @@ import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
import { CardMeta } from "@/api";
//! 一些Neos中基础的数据结构
// Mode
export const MODE_SINGLE = 0x0;
export const MODE_MATCH = 0x1;
export const MODE_TAG = 0x2;
// Position
export const FACEUP_ATTACK = 0x1;
......
......@@ -5,6 +5,5 @@ export default function handleDuelEnd(
container: Container,
_pb: ygopro.YgoStocMsg,
) {
console.log("duel end");
container.context.matStore.duelEnd = true;
}
......@@ -5,6 +5,11 @@ export default function handleJoinGame(
container: Container,
pb: ygopro.YgoStocMsg,
) {
const _msg = pb.stoc_join_game;
container.context.roomStore.joined = true;
const context = container.context;
const msg = pb.stoc_join_game;
console.log(msg.mode);
context.roomStore.joined = true;
context.roomStore.mode = msg.mode;
}
......@@ -5,6 +5,8 @@ import { ygopro } from "@/api";
import StocHsPlayerChange = ygopro.StocHsPlayerChange;
import SelfType = ygopro.StocTypeChange.SelfType;
import HandType = ygopro.HandType;
import { MODE_MATCH, MODE_SINGLE, MODE_TAG } from "@/common";
import { type NeosStore } from "./shared";
export interface Player {
......@@ -33,6 +35,13 @@ export enum RoomStage {
DUEL_START = 6, // 决斗开始
}
// Duel Mode
export enum DuelMode {
SINGLE = MODE_SINGLE,
MATCH = MODE_MATCH,
TAG = MODE_TAG,
}
export class RoomStore implements NeosStore {
joined: boolean = false; // 是否已经加入房间
players: (Player | undefined)[] = Array.from({ length: 4 }).map(
......@@ -43,6 +52,7 @@ export class RoomStore implements NeosStore {
selfType: SelfType = 0; // 当前玩家的类型
stage: RoomStage = RoomStage.WAITING;
errorMsg?: string = undefined; // 错误信息
mode?: DuelMode = undefined; // 当前对局模式
getMePlayer() {
return this.players.find((player) => player?.isMe);
......@@ -58,6 +68,7 @@ export class RoomStore implements NeosStore {
this.isHost = false;
this.stage = RoomStage.WAITING;
this.errorMsg = undefined;
this.mode = undefined;
}
}
......
import React, { CSSProperties } from "react";
import { useNavigate } from "react-router-dom";
import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region } from "@/api";
import { replayStore, resetDuel } from "@/stores";
import { DuelMode, replayStore, resetDuel, roomStore } from "@/stores";
import { NeosModal } from "../NeosModal";
import styles from "./index.module.scss";
......@@ -23,10 +24,16 @@ const localStore = proxy(defaultProps);
export const EndModal: React.FC = () => {
const { isOpen, isWin, reason } = useSnapshot(localStore);
const { isReplay } = useSnapshot(replayStore);
const navigate = useNavigate();
const onReturn = () => {
resetDuel();
rs();
if (roomStore.mode === DuelMode.SINGLE) {
// duel end in single mode, return to match page
navigate("/match");
}
};
return (
......
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