Esempio n. 1
0
        internal AuthCharacterMain(ESIEve EasyEve) : base(EasyEve)
        {
            EasyObject = (ESIEve.Authenticated)EasyEve;

            Assets               = new CharacterAssets(EasyObject);
            Bookmarks            = new CharacterBookmarks(EasyObject);
            Calendar             = new CharacterCalendar(EasyObject);
            Clones               = new CharacterClones(EasyObject);
            Contacts             = new CharacterContacts(EasyObject);
            Contracts            = new CharacterContracts(EasyObject);
            FactionWarfare       = new CharacterFactionWarfare(EasyObject);
            Fittings             = new CharacterFittings(EasyObject);
            Fleet                = new CharacterFleet(EasyObject);
            Industry             = new CharacterIndustry(EasyObject);
            Killmails            = new CharacterKillMails(EasyObject);
            Location             = new CharacterLocation(EasyObject);
            Loyalty              = new CharacterLoyalty(EasyObject);
            Mail                 = new CharacterMail(EasyObject);
            Market               = new CharacterMarket(EasyObject);
            Opportunities        = new CharacterOpportunities(EasyObject);
            PlanetaryInteraction = new CharacterPlanetaryInteraction(EasyObject);
            Skills               = new CharacterSkills(EasyObject);
            Wallet               = new CharacterWallet(EasyObject);
        }
Esempio n. 2
0
        public static async Task SendHandler(MailSend packet, Player player)
        {
            await using var ctx = new UchuContext();

            var response = new SendResponse();

            var recipient = await ctx.Characters.FirstOrDefaultAsync(c => c.Name == packet.RecipientName);

            if (recipient == default)
            {
                response.Code = MailResponseCode.RecipientNotFound;
                goto sendResponse;
            }

            var author = player.GetComponent <CharacterComponent>();

            if (recipient.Id == author.CharacterId)
            {
                response.Code = MailResponseCode.CannotMailYourself;
                goto sendResponse;
            }

            if (author.Currency < (long)packet.Currency)
            {
                response.Code = MailResponseCode.NotEnoughCurrency;
                goto sendResponse;
            }

            Item item = default;

            if (packet.Attachment > 0)
            {
                if (!player.Zone.TryGetGameObject(packet.Attachment, out item))
                {
                    response.Code = MailResponseCode.InvalidAttachment;
                    goto sendResponse;
                }

                if (item.IsBound)
                {
                    response.Code = MailResponseCode.ItemCannotBeMailed;
                    goto sendResponse;
                }

                await player.GetComponent <InventoryManagerComponent>().RemoveItemAsync(item, packet.AttachmentCount);
            }

            var mail = new CharacterMail
            {
                AuthorId           = author.CharacterId,
                RecipientId        = recipient.Id,
                AttachmentCurrency = packet.Currency,
                AttachmentLot      = item?.Lot ?? -1,
                AttachmentCount    = packet.AttachmentCount,
                Subject            = packet.Subject,
                Body           = packet.Body,
                SentTime       = DateTime.Now,
                ExpirationTime = DateTime.Now.AddDays(7)
            };

            await ctx.Mails.AddAsync(mail);

            author.Currency -= 25; // Hard coded cost for filing a mail
            response.Code    = MailResponseCode.Success;

sendResponse:
            await ctx.SaveChangesAsync();

            player.Message(new ServerMailPacket
            {
                Id         = ServerMailPacketId.SendResponse,
                MailStruct = response
            });
        }