Commit ba5bc248 authored by Chunchi Che's avatar Chunchi Che

add isAllOnField

parent ec460b80
Pipeline #27173 failed with stages
in 11 minutes and 26 seconds
......@@ -3,6 +3,7 @@ import { cardStore, matStore } from "@/stores";
import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal";
import { fetchCheckCardMeta } from "../utils";
import { isAllOnField } from "./util";
type MsgSelectUnselectCard = ygopro.StocGameMessage.MsgSelectUnselectCard;
const { MZONE, SZONE, HAND } = ygopro.CardZone;
......@@ -15,9 +16,9 @@ export default async ({
selected_cards: selectedCards,
}: MsgSelectUnselectCard) => {
if (
selectableCards
.concat(selectedCards)
.find((info) => !isOnField(info.location)) === undefined
isAllOnField(
selectableCards.concat(selectedCards).map((info) => info.location),
)
) {
// 所有可选卡和已选卡都是在场上或手牌
// 通过让玩家点击场上的卡来进行选择
......@@ -65,7 +66,3 @@ export default async ({
});
}
};
function isOnField(location: ygopro.CardLocation): boolean {
return [MZONE, SZONE, HAND].includes(location.zone);
}
import { ygopro } from "@/api";
const { MZONE, SZONE, HAND } = ygopro.CardZone;
export function isAllOnField(locations: ygopro.CardLocation[]): boolean {
const isOnField = (location: ygopro.CardLocation) => {
return [MZONE, SZONE, HAND].includes(location.zone);
};
return locations.find((location) => !isOnField(location)) === undefined;
}
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