示例#1
0
        public bool StartGame(int userId, int roomId)
        {
            var room = _gameService.GetGameById(roomId);

            if (room != null)
            {
                return(ActionSuccedded(_gameService.DoAction(userId, CommunicationMessage.ActionType.StartGame, 0, roomId)));
            }
            return(false);
        }
示例#2
0
        public bool DeleteUser(int id)
        {
            var user = _userService.GetUserById(id);

            if (user != null)
            {
                var playerGames = _gameService.GetActiveGamesByUserName(user.MemberName());
                if (playerGames != null)
                {
                    playerGames.ForEach(g => _gameService.DoAction(id,
                                                                   CommunicationMessage.ActionType.Leave, 0, g.Id));
                }
                return(_userService.DeleteUser(user.MemberName(), user.Password()));
            }
            return(false);
        }
示例#3
0
        public ResponeCommMessage HandleEvent(ActionCommMessage msg)
        {
            if (_sessionIdHandler != null)
            {
                ResponeCommMessage             response = null;
                IEnumerator <ActionResultInfo> iter;
                switch (msg.MoveType)
                {
                case CommunicationMessage.ActionType.Bet:
                case CommunicationMessage.ActionType.Fold:
                case CommunicationMessage.ActionType.HandCard:
                case CommunicationMessage.ActionType.Leave:
                case CommunicationMessage.ActionType.StartGame:
                case CommunicationMessage.ActionType.SpectatorLeave:
                    iter     = _gameService.DoAction(msg.UserId, msg.MoveType, msg.Amount, msg.RoomId);
                    response = SendMessages(msg.UserId, iter, msg);
                    break;

                case CommunicationMessage.ActionType.Join:
                    iter = _gameService.DoAction(msg.UserId, msg.MoveType, msg.Amount, msg.RoomId);

                    response = SendMessagesJoin(msg.UserId, iter, msg);
                    break;

                case CommunicationMessage.ActionType.Spectate:
                    iter     = _gameService.AddSpectatorToRoom(msg.UserId, msg.RoomId);
                    response = SendMessagesJoin(msg.UserId, iter, msg);
                    break;
                }
                if (response != null)
                {
                    return(response);
                }
            }
            return(new ResponeCommMessage(msg.UserId, msg.SessionId, false, msg));
        }