Ejemplo n.º 1
0
        public void CreateMjGame(CreateMjGameInput input)
        {
            //when creating new game
            //1.create game
            var newGame = _mjGameAppService.CreateMjGame(input);

            //2.create initial game session
            var currentUser = _userRepository.Get(AbpSession.GetUserId());

            var dSesssion = new CreateMjGameSessionInput
            {
                MjGameId = newGame.Id,
                GameNo   = 1,
                Wind     = MjGameWind.East,
            };

            dSesssion.UsersId.Add(AbpSession.GetUserId());

            var newSession = _mjGameAppService.CreateMjGameSession(dSesssion);

            newGame.ActiveSessionId = newSession.Id;

            _mjGameAppService.UpdateMjGame(newGame);

            //3.if everything worked out, add game creator to this session
            Groups.Add(Context.ConnectionId, newSession.Id.ToString());
        }
Ejemplo n.º 2
0
        public MjGameSession CreateMjGameSession(CreateMjGameSessionInput input)
        {
            List <User> users = new List <User>();

            foreach (var userId in input.UsersId)
            {
                users.Add(_userRepository.Get(userId));
            }

            var session = new MjGameSession()
            {
                GameNo   = input.GameNo,
                MjGameId = input.MjGameId,
                Wind     = input.Wind,
                Users    = users,
            };
            var newSession = _mjGameSessionRepository.Insert(session);

            return(newSession);
        }