// extrawords // 1 - username // 2 - password public void Execute(List <string> extraWords, AttachedClient executingClient) { if (executingClient == null) { return; } if (extraWords.Count != 2) { var errorMsgDto = new DescriptiveTextDto("Wrong number of parameters."); executingClient?.SendDtoMessage(errorMsgDto); return; } if (AttachedClients.IsAccountLoggedIn(extraWords[0])) { var errorMsgDto = new DescriptiveTextDto("Account is already logged in."); executingClient?.SendDtoMessage(errorMsgDto); return; } var potentialAccount = GrainClusterClient.Accounts.GetAccount(extraWords[0]).Result; if (potentialAccount != null && potentialAccount.ValidatePassword(extraWords[1]).Result) { executingClient.AttachedAccount = potentialAccount; var successMsgDto = new DescriptiveTextDto("Login success."); executingClient?.SendDtoMessage(successMsgDto); } else { var errorMsgDto = new DescriptiveTextDto("Either the username or password were incorrect."); executingClient?.SendDtoMessage(errorMsgDto); } }
// extrawords // 1 - username // 2 - password public void Execute(List <string> extraWords, AttachedClient executingClient) { if (executingClient == null) { return; } if (extraWords.Count != 2) { var errorMsgDto = new DescriptiveTextDto("Wrong number of parameters."); executingClient?.SendDtoMessage(errorMsgDto); return; } var potentialAccount = GrainClusterClient.Accounts.CreateAccount(extraWords[0], extraWords[1]).Result; if (potentialAccount == null) { var errorMsgDto = new DescriptiveTextDto("Error creating account."); executingClient?.SendDtoMessage(errorMsgDto); return; } var successMsgDto = new DescriptiveTextDto("Account created."); executingClient?.SendDtoMessage(successMsgDto); }
public void Execute(List <string> extraWords, IAccountGrain executingAccount) { AttachedClient executingClient = AttachedClients.GetAccountFocusedClient(executingAccount); if (executingAccount == null || executingClient == null) { var errorMsgDto = new DescriptiveTextDto("The use player command is currently unavailable."); executingClient?.SendDtoMessage(errorMsgDto); return; } if (extraWords.Count != 1) { var errorMsgDto = new DescriptiveTextDto("Wrong number of parameters."); executingClient?.SendDtoMessage(errorMsgDto); return; } var character = executingAccount.GetCharacter(extraWords[0]).Result;; if (character == null) { var errorMsgDto = new DescriptiveTextDto("Unknown character."); executingClient?.SendDtoMessage(errorMsgDto); return; } // TODO: this instantly will switch active players in an account.. there needs to be a cooldown time here to logout then login AttachedClients.SetClientFocusedCharacter(executingClient.TrackingId, character.TrackingId); if (character.IsNew) { character.IsNew = false; var gameIntroMsgDto = new DescriptiveTextDto(GrainClusterClient.Universe.GetGameIntroductionText().Result); executingClient?.SendDtoMessage(gameIntroMsgDto); } else { var successMsgDto = new DescriptiveTextDto($"You have entered {character.GetLocation().LocationName}."); executingClient?.SendDtoMessage(successMsgDto); } var othersMsgDto = new DescriptiveTextDto($"{character.Name} has entered the area."); character.GetLocation().SendDescriptiveTextDtoMessage($"{character.Name} has entered the area.", character); }
public void Execute(List <string> extraWords, IAccountGrain executingAccount) { AttachedClient executingClient = AttachedClients.GetAccountFocusedClient(executingAccount); if (executingAccount == null || executingClient == null || !executingAccount.CanCreateNewPlayer().Result) { var errorMsgDto = new DescriptiveTextDto("The create new player command is currently unavailable."); executingClient?.SendDtoMessage(errorMsgDto); return; } if (extraWords.Count != 1) { var errorMsgDto = new DescriptiveTextDto("Wrong number of parameters."); executingClient?.SendDtoMessage(errorMsgDto); return; } if (GrainClusterClient.Universe.IsPlayerCharacterNameInUse(extraWords[0]).Result) { var errorMsgDto = new DescriptiveTextDto("This character name is already taken."); executingClient?.SendDtoMessage(errorMsgDto); return; } var newPlayerCharacter = EngineInternal.NewPlayerCreator(); newPlayerCharacter.Name = extraWords[0]; // Mark all player characters as needing focus to stay in the world newPlayerCharacter.NeedsFocus = true; executingAccount.AddCharacter(newPlayerCharacter.TrackingId).Wait(); var successMsgDto = new DescriptiveTextDto("New player created."); executingClient?.SendDtoMessage(successMsgDto); }