Exemple #1
0
    public void EditAllCardLimitDict(int cardID, int changeValue) // 更改某卡牌上限数量
    {
        if (changeValue > 0)
        {
            if (!CardUnlockInfos[cardID])
            {
                CardUnlockInfos[cardID] = true;
            }
        }

        foreach (KeyValuePair <int, BuildInfo> kv in PlayerBuildInfos)
        {
            SortedDictionary <int, BuildCards.CardSelectInfo> csis = kv.Value.M_BuildCards.CardSelectInfos;
            int remainChange = changeValue;
            if (csis[cardID].CardSelectUpperLimit + changeValue >= 0)
            {
                csis[cardID].CardSelectUpperLimit += changeValue;

                if (csis[cardID].CardSelectUpperLimit < csis[cardID].CardSelectCount)
                {
                    csis[cardID].CardSelectCount = csis[cardID].CardSelectUpperLimit;
                }
            }
            else // 如果本身的上限不够扣,则扣掉该系列卡牌的其他牌的上限
            {
                remainChange += csis[cardID].CardSelectUpperLimit;
                csis[cardID].CardSelectUpperLimit = 0;
                List <int> series = AllCards.GetCardSeries(cardID);
                foreach (int i in series)
                {
                    if (csis[i].CardSelectUpperLimit + remainChange >= 0)
                    {
                        csis[i].CardSelectUpperLimit += remainChange;
                        if (csis[i].CardSelectUpperLimit < csis[i].CardSelectCount)
                        {
                            csis[i].CardSelectCount = csis[i].CardSelectUpperLimit;
                        }

                        break;
                    }
                    else
                    {
                        remainChange += csis[i].CardSelectUpperLimit;
                        csis[i].CardSelectUpperLimit = 0;
                        csis[i].CardSelectCount      = 0;
                    }
                }
            }
        }

        int baseCardID = AllCards.GetCardBaseCardID(cardID);

        Base_CardLimitDict[baseCardID] += changeValue;

        InfoRefresh?.Invoke();
    }
Exemple #2
0
    public SortedDictionary <int, int> GetBaseCardLimitDict()
    {
        SortedDictionary <int, int> res = new SortedDictionary <int, int>();

        foreach (KeyValuePair <int, CardSelectInfo> kv in CardSelectInfos)
        {
            int baseCardID = AllCards.GetCardBaseCardID(kv.Key);
            if (!res.ContainsKey(baseCardID))
            {
                res.Add(baseCardID, kv.Value.CardSelectUpperLimit);
            }
            else
            {
                res[baseCardID] += kv.Value.CardSelectUpperLimit;
            }
        }

        return(res);
    }