Esempio n. 1
0
        public void TestsFailedToCalculateWhenStartingPinsNumberIsZero()
        {
            //-- Arrange
            Calculate      _calculate         = new Calculate();
            int            startingPinsNumber = 0;
            CommonGameData data = new CommonGameData(10, 10);

            try
            {
                _calculate.CalculateScore(data.Frames, startingPinsNumber);
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("The number of starting pins 0 is out of range.", ex.Message);
                return;
            }
            Assert.Fail("Call did NOT throw the Argument Exception");
        }
Esempio n. 2
0
        public void TestsFailedWhenStartingPinsNumberIsZero()
        {
            //-- Arrange
            TenPinsGame    game      = new TenPinsGame();
            string         gameInput = "X|7/|9-|x|-8|8/|-6|x|X|X||81";
            CommonGameData data;

            try
            {
                data = new CommonGameData(10, 0);
                game.ShowScore(gameInput);
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("MaxFrameNumber and StartingPinsNumber has to be higher than 0.", ex.Message);
                return;
            }
            Assert.Fail("Call did NOT throw the Argument Exception");
        }
 public FivePinsGame()
 {
     _data      = new CommonGameData(MaxFramesNumber, StartingPinsNumber);
     _calculate = new Calculate();
 }
Esempio n. 4
0
        private static void TexasGameLog(string startTime, string endTime)
        {
            //查询开始时间



            GameRecordView grv = new GameRecordView {
                Gametype = 1, Data = 0, UserID = 0, SearchExt = "Analyse_Texas", StartDate = startTime.ToString(), ExpirationDate = endTime.ToString(), Page = 1, SeachType = (seachType)0
            };



            IEnumerable <TexasGameRecord> data = GameDataBLL.GetListForTexas(grv);



            List <CommonGameData> resdata = new List <CommonGameData>();



            foreach (TexasGameRecord m in data)
            {
                var userList = m.UserData.Split('_').ToList();
                userList.RemoveAt(userList.Count - 1);
                var j = userList.Count;
                for (int i = 0; i < j; i++)
                {
                    CommonGameData com      = new CommonGameData();
                    var            userData = userList[i].Split(',').ToList();
                    int            tem      = 0;

                    DateTime t = m.CreateTime;
                    com.CountDate = new DateTime(t.Year, t.Month, t.Day);
                    //int 房间ID = m.RoomID;
                    //decimal 牌局号 = m.Round;
                    string 盲注 = m.BaseScore;

                    string[] s = m.BaseScore.Split('/');
                    int      v = int.Parse(s[0]);
                    tem = v;
                    //int 服务费 = m.Service;


                    var wj = userData[2];
                    com.UserID = int.Parse(wj);

                    decimal d = Convert.ToDecimal(userData[4]);
                    if (tem <= 100)
                    {
                        com.Initial = d; com.InitialCount = 1;
                    }
                    else if (tem >= 5000)
                    {
                        com.HighRank = d; com.HighRankCount = 1;
                    }
                    else
                    {
                        com.Secondary = d; com.SecondaryCount = 1;
                    }

                    com.Key = com.UserID + com.CountDate.ToString();
                    resdata.Add(com);
                }
            }
            IEnumerable <IGrouping <string, CommonGameData> > query = resdata.GroupBy(m => m.Key);
            List <CommonGameData> sumData = new List <CommonGameData>();

            foreach (IGrouping <string, CommonGameData> info in query)
            {
                List <CommonGameData> sl = info.ToList <CommonGameData>();//分组后的集合
                CommonGameData        co = new CommonGameData();
                co.UserID         = sl[0].UserID;
                co.CountDate      = sl[0].CountDate;
                co.InitialL       = sl.Where(m => m.Initial < 0).Sum(m => m.Initial);
                co.InitialW       = sl.Where(m => m.Initial > 0).Sum(m => m.Initial);
                co.InitialCount   = sl.Sum(m => m.InitialCount);
                co.HighRankL      = sl.Where(m => m.HighRank < 0).Sum(m => m.HighRank);
                co.HighRankW      = sl.Where(m => m.HighRank > 0).Sum(m => m.HighRank);
                co.HighRankCount  = sl.Sum(m => m.HighRankCount);
                co.SecondaryL     = sl.Where(m => m.Secondary < 0).Sum(m => m.Secondary);
                co.SecondaryW     = sl.Where(m => m.Secondary > 0).Sum(m => m.Secondary);
                co.SecondaryCount = sl.Sum(m => m.SecondaryCount);
                sumData.Add(co);
            }

            foreach (CommonGameData comdata in sumData)
            {
                string sql = @"
replace into Clearing_Game(UserID ,CountDate ,Texas_LCount ,Texas_LAward_L ,Texas_LAward_W ,Texas_MCount ,Texas_MAward_L ,Texas_MAward_W ,Texas_HCount ,Texas_HAward_L ,Texas_HAward_W)
select " + comdata.UserID + " ,'" + comdata.CountDate + "' ,ifnull(b.Texas_LCount,0) + " + comdata.InitialCount + " ,ifnull(b.Texas_LAward_L,0) + " + comdata.InitialL + " ,ifnull(b.Texas_LAward_W,0) + " + comdata.InitialW + @" 
,ifnull(b.Texas_MCount,0) + " + comdata.SecondaryCount + @" ,ifnull(b.Texas_MAward_L,0) + " + comdata.SecondaryL + @" ,ifnull(b.Texas_MAward_W,0) + " + comdata.SecondaryW + @" 
,ifnull(b.Texas_HCount,0) + " + comdata.HighRankCount + @" ,ifnull(b.Texas_HAward_L,0) + " + comdata.HighRankL + @" ,ifnull(b.Texas_HAward_W,0) + " + comdata.HighRankW + @"
from (select " + comdata.UserID + @" userid ) a left join (
select * from Clearing_Game where UserID = " + comdata.UserID + @" and CountDate = '" + comdata.CountDate + @"') b on 1 = 1;
";


                GameDataBLL.Add(sql);
            }

            GameDataBLL.UpdateBeginTimeForGame(grv);
            //修改时间
        }
Esempio n. 5
0
 // Start is called before the first frame update
 void Start()
 {
     CommonGameData.ResetValues();
 }