Пример #1
0
        public void GiveReward(Character character)
        {
            // Wrong gender
            if (character.Gender != Gender && Gender != GenderType.Neutral)
                return;

            if (character.FactionGroup == FactionGroup.Alliance && AllianceTitle != 0)
            {
                character.SetTitle(AllianceTitle,false);
            }
            else if (character.FactionGroup == FactionGroup.Horde && HordeTitle != 0)
            {
                character.SetTitle(HordeTitle, false);
            }

            if (Item != 0)
            {
				var mailMessage = new MailMessage(Subjects.Localize(character.Locale), Bodies.Localize(character.Locale))
            	                  	{
            	                  		ReceiverId = character.EntityId.Low,
            	                  		DeliveryTime = DateTime.Now,
            	                  		SendTime = DateTime.Now,
            	                  		ExpireTime = DateTime.Now.AddMonths(1),
            	                  		MessageStationary = MailStationary.Normal
            	                  	};
            	mailMessage.AddItem(Item);
            	MailMgr.SendMail(mailMessage);
            }
        }
Пример #2
0
		public void SendMail(string subject, uint money, ItemRecord item, string body)
		{
			var msg = new MailMessage(subject, body)
				{
					SenderId = (uint)HouseFaction,
					ReceiverId = OwnerLowId,
					MessageStationary = MailStationary.Auction,
					MessageType = MailType.Auction,
					IncludedMoney = money,
                    LastModifiedOn = null,
                    SendTime = DateTime.Now,
                    DeliveryTime = DateTime.Now
				};

            if(item != null)
			    msg.AddItem(item);

			msg.Send();
		}
Пример #3
0
		private void DeleteOrReturn(MailMessage letter)
		{
			AllMail.Remove((uint)letter.Guid);

			if (!letter.IsDeleted && (letter.IncludedItemCount > 0 || letter.IncludedMoney > 0))
			{
				letter.ReturnToSender();
			}
			else
			{
				letter.DeletedTime = DateTime.Now;
				RealmServer.IOQueue.AddMessage(new Message(letter.Destroy));
			}
		}
Пример #4
0
		/// <summary>
		/// Creates and sends a new Mail with the given parameters
		/// </summary>
		public MailError SendMail(CharacterRecord recipient,
			string subject,
			string body,
			MailStationary stationary,
			ICollection<Item> items,
			uint money,
			uint cod)
		{
			if (subject.Length > MailMgr.MaxMailSubjectLength ||
				body.Length > MailMgr.MaxMailBodyLength)
			{
				// Player cannot send mails this long through the mail dialog
				return MailError.INTERNAL_ERROR;
			}

			// Can't send mail to yourself.
			if (recipient.EntityLowId == m_chr.EntityId.Low)
			{
				MailHandler.SendResult(m_chr.Client, 0, MailResult.MailSent, MailError.CANNOT_SEND_TO_SELF);
				return MailError.CANNOT_SEND_TO_SELF;
			}

		    var requiredCash = money;

			// Check that sender is good for the money.
			if (MailMgr.ChargePostage)
			{
                if (!m_chr.GodMode)
                {
                    requiredCash += MailMgr.PostagePrice;

                    var count = (items == null) ? 0u : (uint) items.Count;
                    if (count > 0)
                    {
                        requiredCash += ((count - 1)*MailMgr.PostagePrice);
                    }
                }
			}

            if (requiredCash > m_chr.Money)
            {
                MailHandler.SendResult(m_chr.Client, 0u, MailResult.MailSent, MailError.NOT_ENOUGH_MONEY);
                return MailError.NOT_ENOUGH_MONEY;
            }

            // Charge for the letter (already checked, Character has enough)
            m_chr.Money -= requiredCash;

			// All good, send an ok message
			MailHandler.SendResult(m_chr.Client, 0u, MailResult.MailSent, MailError.OK);
            m_chr.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GoldSpentForMail, requiredCash);

			var deliveryDelay = 0u;
			if (!m_chr.GodMode)
			{
				if ((money > 0 || (items != null && items.Count > 0)) && (m_chr.Account.AccountId != recipient.AccountId))
				{
					deliveryDelay = MailMgr.MaxPacketDeliveryDelay;
				}
			}

			// Create a new letter object
			var letter = new MailMessage(subject, body)
			{
				LastModifiedOn = null,
				SenderId = m_chr.EntityId.Low,
				ReceiverId = recipient.EntityLowId,
				MessageStationary = stationary,
				MessageType = MailType.Normal,
				CashOnDelivery = cod,
				IncludedMoney = money,
				SendTime = DateTime.Now,
				DeliveryTime = DateTime.Now.AddSeconds(deliveryDelay)
			};

			// Attach items to the new letter
			if (items != null && items.Count > 0)
			{
				// remove the item from the sender's inventory and add them to the list
				letter.SetItems(items);
			}

			MailMgr.SendMail(letter);
			return MailError.OK;
		}