Beispiel #1
0
        /// <summary>
        /// Checks whether the given Item may be sold by the given
        /// Character and sends an Error reply if not
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool CanPlayerSellItem(Character chr, Item item, ref SellItemError error)
        {
            // Can't sell items that don't belong to you.
            if (chr != item.OwningCharacter)
            {
                error = SellItemError.PlayerDoesntOwnItem;
                return(false);
            }

            var template = item.Template;

            // Can't sell non-empty bags
            if (template.IsBag && !((Container)item).BaseInventory.IsEmpty)
            {
                error = SellItemError.OnlyEmptyBag;
                return(false);
            }

            // Item is in invalid state or simply not for sale
            if (!item.CanBeTraded || template.SellPrice == 0)
            {
                error = SellItemError.CantSellItem;
                return(false);
            }

            return(true);
        }
Beispiel #2
0
 /// <summary>Sends a sell-error packet to the client</summary>
 /// <param name="client">The IRealmClient to send the error to.</param>
 /// <param name="error">A SellItemError</param>
 public static void SendSellError(IPacketReceiver client, EntityId vendorId, EntityId itemId,
                                  SellItemError error)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_SELL_ITEM, 17))
     {
         packet.Write((ulong)vendorId);
         packet.Write((ulong)itemId);
         packet.Write((byte)error);
         client.Send(packet, false);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Checks whether the given Item may be sold by the given
        /// Character and sends an Error reply if not
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool CanPlayerSellItem(Character chr, Item item, ref SellItemError error)
        {
            if (chr != item.OwningCharacter)
            {
                error = SellItemError.PlayerDoesntOwnItem;
                return(false);
            }

            ItemTemplate template = item.Template;

            if (template.IsBag && !((Container)item).BaseInventory.IsEmpty)
            {
                error = SellItemError.OnlyEmptyBag;
                return(false);
            }

            if (item.CanBeTraded && template.SellPrice != 0U)
            {
                return(true);
            }
            error = SellItemError.CantSellItem;
            return(false);
        }
Beispiel #4
0
		/// <summary>
		/// Sends a sell-error packet to the client
		/// </summary>
		/// <param name="client">The IRealmClient to send the error to.</param>
		/// <param name="error">A SellItemError</param>
		public static void SendSellError(IPacketReceiver client, EntityId vendorId, EntityId itemId, SellItemError error)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SELL_ITEM, 8 + 8 + 1))
			{
				packet.Write(vendorId);
				packet.Write(itemId);
				packet.Write((byte)error);

				client.Send(packet);
			}
		}
Beispiel #5
0
        /// <summary>
        /// Sends a sell-error packet to the client
        /// </summary>
        /// <param name="client">The IRealmClient to send the error to.</param>
        /// <param name="error">A SellItemError</param>
        public static void SendSellError(IPacketReceiver client, EntityId vendorId, EntityId itemId, SellItemError error)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SELL_ITEM, 8 + 8 + 1))
            {
                packet.Write(vendorId);
                packet.Write(itemId);
                packet.Write((byte)error);

                client.Send(packet);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Checks whether the given Item may be sold by the given
        /// Character and sends an Error reply if not
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool CanPlayerSellItem(Character chr, Item item, ref SellItemError error)
        {
            // Can't sell items that don't belong to you.
            if (chr != item.OwningCharacter)
            {
                error = SellItemError.PlayerDoesntOwnItem;
                return false;
            }

            var template = item.Template;

            // Can't sell non-empty bags
            if (template.IsBag && !((Container)item).BaseInventory.IsEmpty)
            {
                error = SellItemError.OnlyEmptyBag;
                return false;
            }

            // Item is in invalid state or simply not for sale
            if (!item.CanBeTraded || template.SellPrice == 0)
            {
                error = SellItemError.CantSellItem;
                return false;
            }

            return true;
        }