Example #1
0
        public void CreateGame(List <string> players, string gameId, string pass)
        {
            if (GetAllGameIds().Contains(gameId))
            {
                throw new Exception();
            }
            Log.Debug("Create game" + gameId);
            repository.AddGuid(gameId, Guid.NewGuid());
            SetTimeForGame(gameId, _clock.Now);
            repository.SetPassword(gameId, pass);
            var game = new MainGameModel();

            SetPlayersForGameId(players, gameId);
            game.Users = _userService.GetPLayersByGameId(gameId);
            var t = Enumerable.Range(0, 25).Select(p => new Cell()
            {
                Id = p
            }).ToList();
            var word = _wordService.GetRandomWord(5);

            t[10].Letter = word[0].ToString();
            t[11].Letter = word[1].ToString();
            t[12].Letter = word[2].ToString();
            t[13].Letter = word[3].ToString();
            t[14].Letter = word[4].ToString();
            game.Cells   = t;
            _userService.SetCurrentUser(players[0], gameId);
            SetMainModel(game, gameId);
        }