示例#1
0
        public void SaveMSEs(string file, Card[] cards, bool isUpdate)
        {
            if (cards == null)
            {
                return;
            }

            string pack_db = MyPath.GetRealPath(MyConfig.ReadString("pack_db"));
            bool   rarity  = MyConfig.ReadBoolean("mse_auto_rarity", false);

#if DEBUG
            MessageBox.Show("db = " + pack_db + ",auto rarity=" + rarity);
#endif
            int c = cards.Length;
            //不分开,或者卡片数小于单个存档的最大值
            if (this.mseHelper.MaxNum == 0 || c < this.mseHelper.MaxNum)
            {
                this.SaveMSE(1, file, cards, pack_db, rarity, isUpdate);
            }
            else
            {
                int nums = c / this.mseHelper.MaxNum;
                if (nums * this.mseHelper.MaxNum < c)//计算需要分多少个存档
                {
                    nums++;
                }

                List <Card> clist = new List <Card>();
                for (int i = 0; i < nums; i++)//分别生成存档
                {
                    clist.Clear();
                    for (int j = 0; j < this.mseHelper.MaxNum; j++)
                    {
                        int index = i * this.mseHelper.MaxNum + j;
                        if (index < c)
                        {
                            clist.Add(cards[index]);
                        }
                    }
                    int    t     = file.LastIndexOf(".mse-set");
                    string fname = (t > 0) ? file.Substring(0, t) : file;
                    fname += string.Format("_{0}.mse-set", i + 1);
                    this.SaveMSE(i + 1, fname, clist.ToArray(), pack_db, rarity, isUpdate);
                }
            }
        }