Esempio n. 1
0
        /// <summary>
        /// 检查游戏中的牌信息,确定游戏中有哪些丢失的或者重复的牌
        /// </summary>
        /// <param name="aGame">游戏对象</param>
        /// <returns>XML报告</returns>
        public string CardsChecker(SGS.ServerCore.Contest.Global.GameBase aGame)
        {
            List <Card> lst = new List <Card>(CardsHeap);

            lst.AddRange(CardsHeap2);
            ChiefBase s = aGame.GamePlayers[-1].Chief;

            if (s != null)
            {
                ChiefBase t = s;
                do
                {
                    lst.AddRange(aGame.GamePlayers[t].Hands);
                    if (aGame.GamePlayers[t].Armor != null)
                    {
                        lst.Add(aGame.GamePlayers[t].Armor);
                    }
                    if (aGame.GamePlayers[t].Weapon != null)
                    {
                        lst.Add(aGame.GamePlayers[t].Weapon);
                    }
                    if (aGame.GamePlayers[t].Jia1Ma != null)
                    {
                        lst.Add(aGame.GamePlayers[t].Jia1Ma);
                    }
                    if (aGame.GamePlayers[t].Jian1Ma != null)
                    {
                        lst.Add(aGame.GamePlayers[t].Jian1Ma);
                    }
                    lst.AddRange(aGame.GamePlayers[t].Debuff);
                    t = t.Next;
                } while (t != s);
            }
            int[] Buff = new int[TotalCards + 1];
            foreach (Card c in lst)
            {
                Buff[c.ID]++;
            }
            Beaver lost   = new Beaver();
            Beaver excess = new Beaver();
            bool   normal = true;

            for (int i = 1; i <= TotalCards; i++)
            {
                if (Buff[i] > 1)
                {
                    excess.Add(string.Empty, new Beaver(string.Empty, i, Buff[i] - 1));
                    normal = false;
                }
                //new XElement("card",
                //    new XElement("id", i),
                //    new XElement("excess_count", Buff[i] - 1)
                //));
                else if (Buff[i] == 0)
                {
                    lost.Add(string.Empty, i);
                    normal = false;
                }
                //new XElement("card" ,
                //    new XElement("id" , i)
                //    )
                //);
            }
            if (!normal)
            {
                return(new Beaver("cardschecker.wrong_total", lost, excess).ToString());
            }
            return(new Beaver("cardschecker").ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// 构造牌堆
 /// </summary>
 public CardHeap(SGS.ServerCore.Contest.Global.GameBase aGame)
 {
     //_random = new RNGCryptoServiceProvider();
     _game = aGame;
 }