Commit 65312b5b authored by Chunchi Che's avatar Chunchi Che

Merge branch 'optimize/select_action/tabs' into 'main'

Optimize/select action/tabs

See merge request mycard/Neos!189
parents 463345c1 0b947a16
Pipeline #21618 passed with stages
in 12 minutes and 15 seconds
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN", "cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN",
"cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb", "cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb",
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false,
"ui":{ "ui":{
"ground":{ "ground":{
"width":9.9, "width":9.9,
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
}, },
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
"maxCount": 3 "maxCount": 1
} }
}, },
"unimplementedWhiteList":[ "unimplementedWhiteList":[
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN", "cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN",
"cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb", "cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb",
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false,
"ui":{ "ui":{
"ground":{ "ground":{
"width":9.9, "width":9.9,
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
}, },
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
"maxCount": 3 "maxCount": 1
} }
}, },
"unimplementedWhiteList":[ "unimplementedWhiteList":[
......
import { sendSelectSingleResponse, ygopro } from "@/api"; import { sendSelectSingleResponse, ygopro } from "@/api";
import { useConfig } from "@/config";
import { import {
fetchCheckCardMeta, fetchCheckCardMeta,
fetchSelectHintMeta, fetchSelectHintMeta,
messageStore, messageStore,
} from "@/stores"; } from "@/stores";
const NeosConfig = useConfig();
type MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain; type MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain;
export default (selectChain: MsgSelectChain) => { export default (selectChain: MsgSelectChain) => {
const spCount = selectChain.special_count; const spCount = selectChain.special_count;
...@@ -22,8 +25,13 @@ export default (selectChain: MsgSelectChain) => { ...@@ -22,8 +25,13 @@ export default (selectChain: MsgSelectChain) => {
// 直接回答 // 直接回答
handle_flag = 0; handle_flag = 0;
} else { } else {
// 处理多张 if (NeosConfig.chainALL) {
handle_flag = 2; // 配置了全部连锁,则处理多张
handle_flag = 2;
} else {
// 否则不连锁
handle_flag = 0;
}
} }
} else { } else {
// 有关键卡 // 有关键卡
......
...@@ -2,7 +2,7 @@ import "@/styles/select-modal.scss"; ...@@ -2,7 +2,7 @@ import "@/styles/select-modal.scss";
import { MinusOutlined, ThunderboltOutlined } from "@ant-design/icons"; import { MinusOutlined, ThunderboltOutlined } from "@ant-design/icons";
import { CheckCard, CheckCardProps } from "@ant-design/pro-components"; import { CheckCard, CheckCardProps } from "@ant-design/pro-components";
import { Button, Card, Col, Popover, Row } from "antd"; import { Button, Card, Col, Popover, Row, Tabs } from "antd";
import React, { useState } from "react"; import React, { useState } from "react";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
...@@ -10,10 +10,12 @@ import { ...@@ -10,10 +10,12 @@ import {
fetchStrings, fetchStrings,
sendSelectMultiResponse, sendSelectMultiResponse,
sendSelectSingleResponse, sendSelectSingleResponse,
ygopro,
} from "@/api"; } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { clearSelectActions, matStore, messageStore } from "@/stores"; import { clearSelectActions, matStore, messageStore } from "@/stores";
import { groupBy } from "../utils";
import { DragModal } from "./DragModal"; import { DragModal } from "./DragModal";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
...@@ -58,6 +60,8 @@ export const SelectActionsModal = () => { ...@@ -58,6 +60,8 @@ export const SelectActionsModal = () => {
? response.length == 1 ? response.length == 1
: response.length >= min && response.length <= max && levelMatched; : response.length >= min && response.length <= max && levelMatched;
const grouped = groupBy(selectables, (option) => option.location?.location!);
return ( return (
<> <>
<DragModal <DragModal
...@@ -132,30 +136,47 @@ export const SelectActionsModal = () => { ...@@ -132,30 +136,47 @@ export const SelectActionsModal = () => {
setResponse(values); setResponse(values);
}} }}
> >
<Row> <Tabs
{selectables.map((option, idx) => { type="card"
return ( items={grouped.map((group, idx) => {
<Col span={4} key={idx}> return {
<HoverCheckCard label: fetchStrings("!system", group[0] + 1000),
hoverContent={option.effectDesc} key: idx.toString(),
style={{ width: 120 }} children: (
cover={ <Row>
<img {group[1].map((option, idx) => {
alt={option.meta.id.toString()} return (
src={ <Col span={4} key={idx}>
option.meta.id <HoverCheckCard
? `${NeosConfig.cardImgUrl}/${option.meta.id}.jpg` hoverContent={option.effectDesc}
: `${NeosConfig.assetsPath}/card_back.jpg` style={{
} width: 120,
style={{ width: 100 }} backgroundColor:
/> option.location?.controler === 0
} ? "white"
value={option} : "grey",
/> }}
</Col> cover={
); <img
alt={option.meta.id.toString()}
src={
option.meta.id
? `${NeosConfig.cardImgUrl}/${option.meta.id}.jpg`
: `${NeosConfig.assetsPath}/card_back.jpg`
}
style={{ width: 100 }}
/>
}
value={option}
/>
</Col>
);
})}
</Row>
),
};
})} })}
</Row> />
<p>{selecteds.length > 0 ? fetchStrings("!system", 212) : ""}</p> <p>{selecteds.length > 0 ? fetchStrings("!system", 212) : ""}</p>
<Row> <Row>
{selecteds.concat(mustSelects).map((option, idx) => { {selecteds.concat(mustSelects).map((option, idx) => {
......
export const groupBy = <K, V>(
array: readonly V[],
getKey: (cur: V, idx: number, src: readonly V[]) => K
): [K, V[]][] =>
Array.from(
array.reduce((map, cur, idx, src) => {
const key = getKey(cur, idx, src);
const list = map.get(key);
if (list) list.push(cur);
else map.set(key, [cur]);
return map;
}, new Map<K, V[]>())
);
export * from "./groupBy";
export * from "./interactTypeToString"; export * from "./interactTypeToString";
export * from "./zip"; export * from "./zip";
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