Exemplo n.º 1
0
        public GameBoard GetBoard()
        {
            var board = new GameBoard { AllNumsAsString = Board };
            board.InitFromString();

            return board;
        }
        public static GameBoard Random()
        {
            var gameboard = new GameBoard();

            for (int i = 0; i < 5; i++)
            {
                switch (i)
                {
                    case 0:
                        gameboard.BCol = CreateNRandomNumbers(5, 1, 15);
                        break;
                    case 1:
                        gameboard.ICol = CreateNRandomNumbers(5, 16, 30);
                        break;
                    case 2:
                        gameboard.NCol = CreateNRandomNumbers(5, 31, 45);
                        break;
                    case 3:
                        gameboard.GCol = CreateNRandomNumbers(5, 46, 60);
                        break;
                    case 4:
                        gameboard.OCol = CreateNRandomNumbers(5, 61, 75);
                        break;
                }
            }

            //Add the free col
            gameboard.NCol[2] = 0;

            return gameboard;
        }
        public static string CreateSerializedString(GameBoard gameBoard)
        {
            var nums = new List<int>();
            nums.AddRange(gameBoard.BCol);
            nums.AddRange(gameBoard.ICol);
            nums.AddRange(gameBoard.NCol);
            nums.AddRange(gameBoard.GCol);
            nums.AddRange(gameBoard.OCol);

            return string.Join(",", nums);
        }
        public static GameViewModel Create(string userid, GameBoard gameBoard)
        {
            var viewModel = new GameViewModel()
                                {
                                    GameBoard = gameBoard ?? Models.GameBoard.Random(),
                                    ServerTime = DateTime.Now.AddSeconds(5),
                                    UserId = userid
                                };

            return viewModel;
        }