Ejemplo n.º 1
0
        public override void Execute(PclPacket getGiftPacket, ClientSession clientSession)
        {
            var isCopy = getGiftPacket.Type == 2;
            var mail   = _mailHttpClient.GetGift(getGiftPacket.GiftId, clientSession.Character.VisualId, isCopy);

            if (mail == null)
            {
                return;
            }

            if ((getGiftPacket.Type == 4) && (mail.ItemInstance != null))
            {
                var itemInstance = _itemInstanceDao.FirstOrDefault(s => s.Id == mail.ItemInstance.Id);
                var item         = _itemProvider.Convert(itemInstance);
                item.Id = Guid.NewGuid();
                var newInv = clientSession.Character.InventoryService
                             .AddItemToPocket(InventoryItemInstance.Create(item, clientSession.Character.CharacterId))
                             .FirstOrDefault();
                if (newInv != null)
                {
                    clientSession.SendPacket(clientSession.Character.GenerateSay(
                                                 string.Format(
                                                     Language.Instance.GetMessageFromKey(LanguageKey.ITEM_RECEIVED,
                                                                                         clientSession.Account.Language),
                                                     newInv.ItemInstance.Item.Name, newInv.ItemInstance.Amount), SayColorType.Green));
                    clientSession.SendPacket(
                        new ParcelPacket {
                        Type = 2, Unknown = 1, Id = (short)getGiftPacket.GiftId
                    });
                    _mailHttpClient.DeleteGift(getGiftPacket.GiftId, clientSession.Character.VisualId, isCopy);
                }
                else
                {
                    clientSession.SendPacket(new ParcelPacket {
                        Type = 5, Unknown = 1, Id = 0
                    });
                    clientSession.SendPacket(new MsgPacket
                    {
                        Message = Language.Instance.GetMessageFromKey(LanguageKey.NOT_ENOUGH_PLACE,
                                                                      clientSession.Account.Language),
                        Type = 0
                    });
                }
            }
            else if (getGiftPacket.Type == 5)
            {
                clientSession.SendPacket(new ParcelPacket {
                    Type = 7, Unknown = 1, Id = (short)getGiftPacket.GiftId
                });
                _mailHttpClient.DeleteGift(getGiftPacket.GiftId, clientSession.Character.VisualId, isCopy);
            }
        }
Ejemplo n.º 2
0
        public override void Execute(PstClientPacket pstClientPacket, ClientSession clientSession)
        {
            var isCopy = pstClientPacket.Type == 2;
            var mail   = _mailHttpClient.GetGift(pstClientPacket.Id, clientSession.Character.VisualId, isCopy);

            switch (pstClientPacket.ActionType)
            {
            case 3:
                if (mail == null)
                {
                    return;
                }

                var patch = new JsonPatchDocument <MailDto>();
                patch.Replace(link => link.IsOpened, true);
                _mailHttpClient.ViewGift(mail.MailDto.MailId, patch);
                clientSession.SendPacket(mail.GeneratePostMessage(pstClientPacket.Type));
                break;

            case 2:
                if (mail == null)
                {
                    return;
                }

                _mailHttpClient.DeleteGift(pstClientPacket.Id, clientSession.Character.VisualId, isCopy);
                clientSession.SendPacket(
                    clientSession.Character.GenerateSay(
                        Language.Instance.GetMessageFromKey(LanguageKey.MAIL_DELETED,
                                                            clientSession.Account.Language),
                        SayColorType.Purple));
                break;

            case 1:
                if (string.IsNullOrEmpty(pstClientPacket.Text) || string.IsNullOrEmpty(pstClientPacket.Title))
                {
                    return;
                }

                var dest = _characterDao.FirstOrDefault(s => s.Name == pstClientPacket.ReceiverName);
                if (dest != null)
                {
                    _mailHttpClient.SendMessage(clientSession.Character, dest.CharacterId, pstClientPacket.Title,
                                                pstClientPacket.Text);
                    clientSession.SendPacket(clientSession.Character.GenerateSay(
                                                 Language.Instance.GetMessageFromKey(
                                                     LanguageKey.MAILED,
                                                     clientSession.Account.Language), SayColorType.Yellow));
                }
                else
                {
                    clientSession.SendPacket(
                        clientSession.Character.GenerateSay(
                            Language.Instance.GetMessageFromKey(LanguageKey.USER_NOT_FOUND,
                                                                clientSession.Account.Language),
                            SayColorType.Yellow));
                }

                break;

            default:
                return;
            }
        }