Ejemplo n.º 1
0
        /// <summary>
        /// 会员积分变动记录
        /// </summary>
        /// <param name="CustomerId"></param>
        /// <param name="signEnum"></param>
        /// <returns></returns>
        public bool ChangeCustomerSign(int CustomerId, SignEnum signEnum)
        {
            Customer customer = _db.Queryable <Customer>().First(a => a.State & a.Id == CustomerId);

            customer.Integral += (int)signEnum;
            if (_db.Updateable(customer).ExecuteCommand() > 0)
            {
                CustomerSign sign = NewMethod1();
                sign.CustomerID = CustomerId;
                sign.Integral   = (int)signEnum;
                sign.Mode       = signEnum.ToString();
                if (_db.Insertable(sign).ExecuteCommand() > 0)
                {
                    //提交事务
                    return(true);
                }
                else
                {
                    throw new Exception("添加积分记录异常!");
                }
            }
            else
            {
                throw new Exception("会员签到异常!");
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <BaseTermin> GetBeforeSignBySign(SignEnum sign)
        {
            var sequense = Parent.Bind(c => c.Sequence.ToList());
            var res      = sequense.Bind(c => c.Select(x => x.MaybeAs <Sign>().GetOrDefault(null))).GetOrDefault(null);
            var resSign  = res.Where(c => c.CurrentSign == sign);

            return(resSign.Select(c => c.GetBeforeSign()));
        }
Ejemplo n.º 3
0
        public static bool CheckDiagonal(GameMap map, SignEnum player)
        {
            var sum = 0;

            for (var i = 0; i < map.Size; i++)
            {
                if (map.Tiles[i][i].Sign == player)
                {
                    sum++;
                }
            }
            return(CheckWin(sum, map));
        }
Ejemplo n.º 4
0
        public static bool CheckDiagonalReverse(GameMap map, SignEnum player)
        {
            var sum      = 0;
            var widthPos = map.Size - 1;

            for (var i = 0; i < map.Size; i++)
            {
                if (map.Tiles[i][widthPos].Sign == player)
                {
                    sum++;
                }
                widthPos--;
            }
            return(CheckWin(sum, map));
        }
Ejemplo n.º 5
0
 public static bool CheckColumns(GameMap map, SignEnum player)
 {
     for (var i = 0; i < map.Size; i++)
     {
         var sum = 0;
         for (var x = 0; x < map.Size; x++)
         {
             if (map.Tiles[x][i].Sign == player)
             {
                 sum++;
             }
         }
         if (CheckWin(sum, map))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 6
0
        public static bool CheckWin(GameMap map, SignEnum player)
        {
            if (CheckRows(map, player))
            {
                return(true);
            }

            if (CheckColumns(map, player))
            {
                return(true);
            }

            if (CheckDiagonal(map, player))
            {
                return(true);
            }

            if (CheckDiagonalReverse(map, player))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        public void CheckWin_ShouldReturnTrue_WhenSignsAreEqualToMapSize(SignEnum sign, bool expected)
        {
            var actual = GameLogic.CheckWin(Map, sign);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 8
0
        public void CheckColumn_ShouldReturnTrue_WhenColumnIsSameSign(SignEnum sign, bool expected)
        {
            var actual = GameLogic.CheckDiagonalReverse(Map, sign);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 9
0
        public void CheckRows_ShouldReturnTrue_WhenRowIsSameSign(SignEnum sign, bool expected)
        {
            var actual = GameLogic.CheckRows(Map, sign);

            Assert.Equal(expected, actual);
        }