Commit e2ad4284 authored by Chunchi Che's avatar Chunchi Che

add chainSettnigs

parent 7a0a763c
Pipeline #22841 passed with stages
in 13 minutes and 32 seconds
import { sendSelectSingleResponse, ygopro } from "@/api";
import { useConfig } from "@/config";
import { fetchSelectHintMeta } from "@/stores";
import { ChainSetting, fetchSelectHintMeta, matStore } from "@/stores";
import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal";
import { fetchCheckCardMeta } from "../utils";
const NeosConfig = useConfig();
type MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain;
export default async (selectChain: MsgSelectChain) => {
const spCount = selectChain.special_count;
......@@ -14,6 +11,13 @@ export default async (selectChain: MsgSelectChain) => {
const _hint0 = selectChain.hint0;
const _hint1 = selectChain.hint1;
const chains = selectChain.chains;
const chainSetting = matStore.chainSetting;
if (chainSetting == ChainSetting.CHAIN_IGNORE) {
// 如果玩家配置了忽略连锁,直接回应后端并返回
sendSelectSingleResponse(-1);
return;
}
let handle_flag = 0;
if (!forced) {
......@@ -24,7 +28,7 @@ export default async (selectChain: MsgSelectChain) => {
// 直接回答
handle_flag = 0;
} else {
if (NeosConfig.chainALL) {
if (chainSetting == ChainSetting.CHAIN_ALL) {
// 配置了全部连锁,则处理多张
handle_flag = 2;
} else {
......
......@@ -3,7 +3,7 @@ import { proxy } from "valtio";
import { ygopro } from "@/api";
import type { InitInfo, MatState } from "./types";
import { ChainSetting, InitInfo, MatState } from "./types";
/**
* 根据controller判断是自己还是对方。
......@@ -53,6 +53,7 @@ const initInfo: MatState["initInfo"] = proxy({
const initialState: Omit<MatState, "reset"> = {
chains: [],
chainSetting: ChainSetting.CHAIN_SMART,
timeLimits: {
// 时间限制
......
......@@ -20,6 +20,8 @@ export interface MatState extends NeosStore {
chains: ygopro.CardLocation[]; // 连锁的卡片位置
chainSetting: ChainSetting; // 连锁类型
timeLimits: BothSide<number> & {
set: (controller: number, time: number) => void;
}; // 双方的时间限制
......@@ -104,4 +106,10 @@ export enum HandResult {
ROCK = 2,
PAPER = 3,
}
export enum ChainSetting {
CHAIN_ALL = 0, // 打开全部时点
CHAIN_IGNORE = 1, // 关闭连锁时点
CHAIN_SMART = 2, // 只打开关键时点
}
// <<< play mat state <<<
......@@ -3,6 +3,7 @@ import {
CheckOutlined,
CloseCircleFilled,
MessageFilled,
SettingOutlined,
StepForwardFilled,
} from "@ant-design/icons";
import {
......@@ -33,11 +34,12 @@ const { phase } = matStore;
const { useToken } = theme;
export const Menu = () => {
const snapPhase = useSnapshot(phase);
const { currentPlayer } = useSnapshot(matStore);
const currentPhase = snapPhase.currentPhase;
const enableBp = snapPhase.enableBp;
const enableM2 = snapPhase.enableM2;
const enableEp = snapPhase.enableEp;
const { currentPlayer } = useSnapshot(matStore);
const { chainSetting } = useSnapshot(matStore);
const clearAllIdleInteractivities = () => {
for (const card of cardStore.inner) {
......@@ -108,6 +110,16 @@ export const Menu = () => {
danger: phase === PhaseType.END,
}));
const chainSettingTexts = ["全部连锁", "忽略连锁", "智能连锁"];
const chainSettingItems: MenuProps["items"] = chainSettingTexts
.map((text, i) => ({
label: text,
onClick: () => {
matStore.chainSetting = i;
},
}))
.map((item, i) => ({ key: i, ...item }));
const surrenderMenuItems: MenuProps["items"] = [
{
label: "取消",
......@@ -135,17 +147,22 @@ export const Menu = () => {
{phaseBind.find(([key]) => key === currentPhase)?.[1]}
</Button>
</DropdownWithTitle>
<DropdownWithTitle
title={chainSettingTexts[chainSetting]}
menu={{
items: chainSettingItems,
selectable: true,
defaultSelectedKeys: ["3"],
}}
>
<Button icon={<SettingOutlined />} type="text"></Button>
</DropdownWithTitle>
<Tooltip title="聊天室">
<Button
icon={<MessageFilled />}
type="text"
disabled={globalDisable}
></Button>
<Button icon={<MessageFilled />} type="text"></Button>
</Tooltip>
<DropdownWithTitle
title="是否投降?"
menu={{ items: surrenderMenuItems }}
disabled={globalDisable}
>
<Button icon={<CloseCircleFilled />} type="text"></Button>
</DropdownWithTitle>
......
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