コード例 #1
0
ファイル: MailboxHandler.cs プロジェクト: tech-bear/Rhisis
        public static void OnQueryGetMailGold(WorldClient client, INetPacketStream packet)
        {
            var onQueryGetMailGold    = new QueryGetMailGoldPacket(packet);
            var queryGetMailGoldEvent = new QueryGetMailGoldEventArgs(onQueryGetMailGold.MailId);

            client.Player.NotifySystem <MailboxSystem>(queryGetMailGoldEvent);
        }
コード例 #2
0
ファイル: MailboxSystem.cs プロジェクト: tech-bear/Rhisis
        private void GetMailGold(IPlayerEntity player, QueryGetMailGoldEventArgs e)
        {
            var database = DependencyContainer.Instance.Resolve <IDatabase>();
            var mail     = database.Mails.Get(x => x.Id == e.MailId && x.ReceiverId == player.PlayerData.Id);

            if (mail is null)
            {
                return;
            }

            if (mail.HasReceivedGold)
            {
                return;
            }

            checked
            {
                try
                {
                    player.PlayerData.Gold += (int)mail.Gold;
                    mail.HasReceivedGold    = true;
                }
                catch (OverflowException)
                {
                    Logger.LogError($"{player.Object.Name} caused an OverflowException by taking {mail.Gold} out of mail {mail.Id}.");
                    return;
                }
            }
            database.Complete();
            WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.GOLD, player.PlayerData.Gold);
            WorldPacketFactory.SendRemoveMail(player, mail, RemovedFromMail.Gold);
        }