Beispiel #1
0
        private uint?InternalCreate(Client client, RequestCreateCharacterInSlotPacket packet, ICharUnitOfWork unitOfWork)
        {
            var changeFamilyName = false;

            if (!string.IsNullOrWhiteSpace(client.AccountEntry.FamilyName) && packet.FamilyName != client.AccountEntry.FamilyName)
            {
                if (!client.AccountEntry.Characters.Any())
                {
                    changeFamilyName = true;
                }
                else
                {
                    SendCharacterCreateFailed(client, CreateCharacterResult.InvalidCharacterName);
                    return(null);
                }
            }

            if ((string.IsNullOrWhiteSpace(client.AccountEntry.FamilyName) || packet.FamilyName != client.AccountEntry.FamilyName))
            {
                if (!unitOfWork.GameAccounts.CanChangeFamilyName(client.AccountEntry.Id, packet.FamilyName))
                {
                    SendCharacterCreateFailed(client, CreateCharacterResult.FamilyNameReserved);
                    return(null);
                }
            }

            var characterEntry = unitOfWork.Characters.Create(client.AccountEntry, packet.SlotNum,
                                                              packet.CharacterName,
                                                              (byte)packet.RaceId,
                                                              packet.Scale,
                                                              packet.Gender);

            if (characterEntry == null)
            {
                SendCharacterCreateFailed(client, CreateCharacterResult.TechnicalDifficulty);
                return(null);
            }

            var appearances = CreateCharacterAppearanceEntries(packet);

            unitOfWork.CharacterAppearances.Add(characterEntry, appearances);

            if (string.IsNullOrWhiteSpace(client.AccountEntry.FamilyName) || changeFamilyName)
            {
                unitOfWork.GameAccounts.UpdateFamilyName(client.AccountEntry.Id, packet.FamilyName);
            }

            return(characterEntry.Id);
        }
Beispiel #2
0
 private void LoadGameAccountEntry(ICharUnitOfWork unitOfWork, uint id)
 {
     AccountEntry = unitOfWork.GameAccounts.Get(id);
 }
 public DelegatingCharUnitOfWork(ICharUnitOfWork parent, IServiceScope scope)
     : base(parent, scope)
 {
     _parent = parent;
 }