public void Delete() { if (!Configuration.CharacterDelete) { SendMessage(new CharacterValidationResult() { AlertMessageType = AlertMessageType.CharacterDelete, MenuResetType = MenuResetType.Characters }); return; } var validation = new CharacterValidation() { Player = Player }; CharacterValidationResult validationResult; validationResult = validation.ValidateCharacterIndex(characterIndex); if (!CanValidateNext(validationResult)) { return; } // Retorna AlertMessageType.None quando o slot está vazio. validationResult = validation.ValidateEmptyCharacterSelection(characterIndex); // Quando o slot de personagem está vazio, muda o AlertType para Connection. if (validationResult.AlertMessageType == AlertMessageType.None) { ; validationResult.AlertMessageType = AlertMessageType.Connection; validationResult.MenuResetType = MenuResetType.Login; validationResult.Disconnect = true; // Realiza a desconexão pois é impossível deletar um personagem que não existe. if (!CanValidateNext(validationResult)) { return; } } character = Player.CharacterSelection[characterIndex]; validationResult = validation.ValidateLevel(character.Level); if (!CanValidateNext(validationResult)) { return; } // Inicia o processo de requisição para exclusão. if (!character.PendingExclusion) { ProcessRequestDelete(); } }
public void Create(CharacterValidation validation) { if (db.Connected) { db.CreateCharacter( pData.AccountId, validation.CharacterIndex, validation.GenderType, validation.SpriteId, validation.CharacterName, validation.CharacterClass ); return; } }
public void Use(int characterIndex) { var validation = new CharacterValidation() { Player = Player }; CharacterValidationResult validationResult; validationResult = validation.ValidateCharacterIndex(characterIndex); if (!CanValidateNext(validationResult)) { return; } validationResult = validation.ValidateEmptyCharacterSelection(characterIndex); // Quando o slot de personagem está vazio, muda o AlertType para Connection. if (validationResult.AlertMessageType == AlertMessageType.None) { validationResult.AlertMessageType = AlertMessageType.Connection; validationResult.MenuResetType = MenuResetType.Login; validationResult.Disconnect = true; // Realiza a desconexão pois é impossível utilizar um personagem que não existe. if (!CanValidateNext(validationResult)) { return; } } var character = Player.CharacterSelection[characterIndex]; if (character.CharacterId > 0) { Player.CharacterId = character.CharacterId; // Quando um personagem pendente para exclusão é usado. A requisição é cancelada. var cancelRequest = false; if (Player.CharacterSelection[characterIndex].PendingExclusion) { Global.DeleteRequest.CancelDelete(character.CharacterId); cancelRequest = true; } var characters = new CharacterDatabase(Player); characters.LoadCharacter(cancelRequest); characters.Close(); Global.WriteLog(LogType.Player, $"Loaded characters from {Player.Username}", LogColor.Green); var game = new JoinGame() { Player = Player }; game.Join(); } }
public void Create() { var validation = new CharacterValidation() { Player = Player }; if (!Configuration.CharacterCreation) { SendMessage(new CharacterValidationResult() { AlertMessageType = AlertMessageType.CharacterCreation, MenuResetType = MenuResetType.Characters }); return; } CharacterValidationResult validationResult; validationResult = validation.ValidateName(name); if (!CanValidateNext(validationResult)) { return; } validationResult = validation.ValidateCharacterIndex(characterIndex); if (!CanValidateNext(validationResult)) { return; } validationResult = validation.ValidateEmptyCharacterSelection(characterIndex); if (!CanValidateNext(validationResult)) { return; } validationResult = validation.ValidateClass(classIndex); if (!CanValidateNext(validationResult)) { return; } validationResult = validation.ValidateGender(genderType); if (!CanValidateNext(validationResult)) { return; } validationResult = validation.ValidateSprite(spriteIndex); if (!CanValidateNext(validationResult)) { return; } var characters = new CharacterDatabase(Player); if (characters.Exist(validation.CharacterName)) { characters.Close(); SendMessage(new CharacterValidationResult() { AlertMessageType = AlertMessageType.NameTaken, MenuResetType = MenuResetType.Characters }); } else { characters.Create(validation); characters.SendCharactersAsync(); } Global.WriteLog(LogType.Player, $"Created Character {validation.CharacterName} AccountId {Player.AccountId}", LogColor.Green); }