Пример #1
0
        /// <summary>
        /// 清除指定卡组错误
        /// </summary>
        /// <param name="cardGroupName"></param>
        public static void ClearCardGroupError(string cardGroupName)
        {
            UserCardGroup userCardGroup = gameManagerInstance.GetUserData().GetCardGroupByName(cardGroupName);

            //检测卡牌的数量
            for (int i = userCardGroup.mainCardList.Count - 1; i >= 0; i--)
            {
                if (userCardGroup.GetMainCardCount() > DuelRuleManager.GetMainCardGroupNumberUpperLimit())
                {
                    userCardGroup.mainCardList.RemoveAt(i);
                }
                else
                {
                    break;
                }
            }
            //检测是否存在未知卡牌
            for (int i = userCardGroup.mainCardList.Count - 1; i >= 0; i--)
            {
                if (!gameManagerInstance.GetAllCardInfoList().ContainsKey(userCardGroup.mainCardList[i].cardNo))
                {
                    userCardGroup.mainCardList.RemoveAt(i);
                }
            }
            for (int i = userCardGroup.extraCardList.Count - 1; i >= 0; i--)
            {
                if (!gameManagerInstance.GetAllCardInfoList().ContainsKey(userCardGroup.extraCardList[i].cardNo))
                {
                    userCardGroup.extraCardList.RemoveAt(i);
                }
            }
            for (int i = userCardGroup.deputyCardList.Count - 1; i >= 0; i--)
            {
                if (!gameManagerInstance.GetAllCardInfoList().ContainsKey(userCardGroup.deputyCardList[i].cardNo))
                {
                    userCardGroup.deputyCardList.RemoveAt(i);
                }
            }
            //检测同名卡牌的数量
            foreach (var item in userCardGroup.mainCardList)
            {
                if (item.number > DuelRuleManager.GetSameCardNumberUpperLimit())
                {
                    item.number = DuelRuleManager.GetSameCardNumberUpperLimit();
                }
            }
            //检测禁卡的限制

            gameManagerInstance.SaveUserData();
        }
Пример #2
0
        /// <summary>
        /// 检测卡组是否合法
        /// </summary>
        /// <param name="cardGroupName"></param>
        /// <returns></returns>
        public static bool CheckCardGroupLegal(string cardGroupName)
        {
            UserCardGroup userCardGroup = gameManagerInstance.GetUserData().GetCardGroupByName(cardGroupName);

            //检测卡牌的数量
            if (userCardGroup.mainCardList.Count > DuelRuleManager.GetMainCardGroupNumberUpperLimit())
            {
                ShowMessage($"卡组:{cardGroupName}不合法。原因:卡牌的数量超过限制!");
                return(false);
            }
            //检测是否存在未知卡牌
            foreach (var item in userCardGroup.mainCardList)
            {
                if (!gameManagerInstance.GetAllCardInfoList().ContainsKey(item.cardNo))
                {
                    ShowMessage($"卡组:{cardGroupName}不合法。原因:主卡组存在未知卡牌{item.cardNo}!");
                    return(false);
                }
            }
            foreach (var item in userCardGroup.extraCardList)
            {
                if (!gameManagerInstance.GetAllCardInfoList().ContainsKey(item.cardNo))
                {
                    ShowMessage($"卡组:{cardGroupName}不合法。原因:额外卡组存在未知卡牌{item.cardNo}!");
                    return(false);
                }
            }
            foreach (var item in userCardGroup.deputyCardList)
            {
                if (!gameManagerInstance.GetAllCardInfoList().ContainsKey(item.cardNo))
                {
                    ShowMessage($"卡组:{cardGroupName}不合法。原因:副卡组存在未知卡牌{item.cardNo}!");
                    return(false);
                }
            }
            //检测同名卡牌的数量

            foreach (var item in userCardGroup.mainCardList)
            {
                if (item.number > DuelRuleManager.GetSameCardNumberUpperLimit())
                {
                    ShowMessage($"卡组:{cardGroupName}不合法。原因:同名卡牌{item.cardNo}超过上限!");
                    return(false);
                }
            }
            //检测禁卡的限制

            return(true);
        }