Beispiel #1
0
        public Error Login(LoginHandlerMode loginMode, string playerName, string playerLoginKey, out LoginResponseData loginData)
        {
            loginData = null;

            uint playerId;

            if (!uint.TryParse(playerName, out playerId))
            {
                return(Error.PlayerNotFound);
            }

            loginData = new LoginResponseData
            {
                Player = new LoginResponseData.PlayerData
                {
                    Banned = false,
                    Id     = playerId,
                    Name   = "Player " + playerId,
                    Rights = PlayerRights.Basic
                },
                Achievements   = new List <Achievement>(),
                ThemePurchases = themeManager.Themes.Where(theme => theme.Id != Theme.DEFAULT_THEME_ID)
                                 .Select(theme => new ThemePurchase {
                    ThemeId = theme.Id
                })
                                 .ToList()
            };

            return(Error.Ok);
        }
Beispiel #2
0
        public Error Login(LoginHandlerMode loginMode, string playerName, string playerLoginKey, out LoginResponseData loginData)
        {
            loginData = null;
            ApiResponse <LoginResponseData> response;

            try
            {
                response = loginMode == 0
                                   ? ApiCaller.CheckLoginKey(playerName, playerLoginKey)
                                   : ApiCaller.CheckLogin(playerName, playerLoginKey);
            }
            catch (Exception e)
            {
                logger.Error("Error loading player", e);
                return(Error.Unexpected);
            }

            if (!response.Success)
            {
                return(Error.InvalidLogin);
            }

            loginData = response.Data;
            return(Error.Ok);
        }