Exemplo n.º 1
0
        /// <summary>
        /// What to do after an item is added.  For consignment merchants this is called after price is set
        /// </summary>
        /// <param name="player"></param>
        /// <param name="clientSlot"></param>
        /// <param name="price"></param>
        /// <returns></returns>
        public virtual bool SetSellPrice(GamePlayer player, ushort clientSlot, uint price)
        {
            GameConsignmentMerchant conMerchant = player.ActiveInventoryObject as GameConsignmentMerchant;

            if (conMerchant == null)
            {
                return(false);
            }
            House house = HouseMgr.GetHouse(conMerchant.HouseNumber);

            if (house == null)
            {
                return(false);
            }

            if (house.HasOwnerPermissions(player) == false)
            {
                return(false);
            }

            InventoryItem item = player.TempProperties.getProperty <InventoryItem>(GameInventoryObjectExtensions.ITEM_BEING_ADDED, null);

            if (item != null)
            {
                if (item.IsTradable)
                {
                    item.SellPrice = (int)price;
                }
                else
                {
                    // Unique DOL feature
                    item.SellPrice = 0;
                    player.Out.SendCustomDialog("This item is not tradable. You can store it here but cannot sell it.", null);
                }

                item.OwnerLot = conMerchant.HouseNumber;
                item.OwnerID  = conMerchant.GetOwner(player);
                GameServer.Database.SaveObject(item);
                ChatUtil.SendDebugMessage(player, item.Name + " SellPrice=" + price + ", OwnerLot=" + item.OwnerLot + ", OwnerID=" + item.OwnerID);
                player.Out.SendMessage("Price set!", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: {0}:{1} set sell price of '{2}' to {3} for consignment merchant on lot {4}.", player.Name, player.Client.Account.Name, item.Name, item.SellPrice, HouseNumber);
                }

                NotifyObservers(player, null);
            }


            return(true);
        }
Exemplo n.º 2
0
        public virtual void BuyItem(InventoryItem item, GamePlayer player)
        {
            GameConsignmentMerchant cm = HouseMgr.GetConsignmentByHouseNumber((int)item.OwnerLot);

            if (cm == null)
            {
                player.Out.SendMessage("I can't find the consigmnent merchant for this item!", eChatType.CT_Merchant, eChatLoc.CL_ChatWindow);
                log.ErrorFormat("ME: Error finding consignment merchant for lot {0}; {1}:{2} trying to buy {3}", item.OwnerLot, player.Name, player.Client.Account.Name, item.Name);
                return;
            }

            if (player.ActiveInventoryObject != null)
            {
                player.ActiveInventoryObject.RemoveObserver(player);
            }

            player.ActiveInventoryObject = cm;             // activate the target con merchant
            player.Out.SendInventoryItemsUpdate(cm.GetClientInventory(player), eInventoryWindowType.ConsignmentViewer);
            cm.AddObserver(player);
        }