public async Task LoginToAccount(ILoginParameters loginParameters) { if (!_loginActions.LoginParametersAreValid(loginParameters)) { return; } var loginToServerOperation = _networkOperationFactory.CreateSafeBlockingOperation( async() => await _loginActions.LoginToServer(loginParameters), SetInitialStateAndShowError, SetInitialStateAndShowError); if (!await loginToServerOperation.Invoke()) { return; } var reply = loginToServerOperation.Result; if (reply == LoginReply.Ok) { _gameStateActions.ChangeToState(GameStates.LoggedIn); } else { _errorDisplayAction.ShowLoginError(reply); } }
public async Task CreateAccount(ICreateAccountParameters createAccountParameters) { var paramsValidationResult = _accountActions.CheckAccountCreateParameters(createAccountParameters); if (paramsValidationResult.FaultingParameter != WhichParameter.None) { _accountDialogDisplayActions.ShowCreateParameterValidationError(paramsValidationResult); return; } var checkNameOperation = _networkOperationFactory.CreateSafeBlockingOperation( async() => await _accountActions.CheckAccountNameWithServer(createAccountParameters.AccountName), SetInitialStateAndShowError, SetInitialStateAndShowError); if (!await checkNameOperation.Invoke()) { return; } var nameResult = checkNameOperation.Result; if (nameResult != AccountReply.Continue) { _accountDialogDisplayActions.ShowCreateAccountServerError(nameResult); return; } var result = await _accountDialogDisplayActions.ShowCreatePendingDialog(); if (result == XNADialogResult.Cancel) { return; } var createAccountOperation = _networkOperationFactory.CreateSafeBlockingOperation( async() => await _accountActions.CreateAccount(createAccountParameters), SetInitialStateAndShowError, SetInitialStateAndShowError); if (!await createAccountOperation.Invoke()) { return; } var accountResult = createAccountOperation.Result; if (accountResult != AccountReply.Created) { _accountDialogDisplayActions.ShowCreateAccountServerError(accountResult); return; } _gameStateActions.ChangeToState(GameStates.Initial); _accountDialogDisplayActions.ShowSuccessMessage(); }
public void GoToInitialState() { _gameStateActions.ChangeToState(GameStates.Initial); }
private void SetInitialStateAndShowError(NoDataSentException ex) { _gameStateActions.ChangeToState(GameStates.Initial); _errorDisplayAction.ShowException(ex); }
private void SetInitialStateAndShowError() { _gameStateActions.ChangeToState(GameStates.Initial); _errorDialogDisplayAction.ShowError(ConnectResult.SocketError); }