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