コード例 #1
0
        /// <summary>
        /// This function creates a new Board for a User.
        /// </summary>
        /// <param name="u">User</param>
        public Board CreateNewGameBoard(User player, int maxPlayers, int maxRounds)
        {
            var board = new Board();

            board.Status         = "New";
            board.MaximumPlayers = maxPlayers;
            board.MaximumRounds  = maxRounds;
            board.Host           = player;

            var boardUser = new BoardUser();

            boardUser.Money    = 1500;
            boardUser.Position = 1;
            boardUser.Board    = board;
            boardUser.BoardId  = board.Id;
            boardUser.User     = player;
            boardUser.Rounds   = 0;
            boardUser.Turn     = -1;
            BoardUsers.Add(boardUser);
            board.BoardUsers.Add(boardUser);
            board.ActiveBoardPlayer = player;

            Boards.Add(board);

            SaveChanges();

            return(board);
        }
コード例 #2
0
        public void AddPlayerToBoard(User player, Board board)
        {
            var boardUser = new BoardUser();

            boardUser.Money    = 1500;
            boardUser.Position = 1;
            boardUser.Board    = board;
            boardUser.User     = player;
            boardUser.Rounds   = 0;
            boardUser.Turn     = -1;
            board.BoardUsers.Add(boardUser);

            SaveChanges();
        }