Exemple #1
0
        public void Initialize()
        {
            Item = InventoryItemTable.Load(ItemID);

            if (Item == null)
            {
                BidHouseTable.Delete(ItemID);
                return;
            }

            BH.addObject(this);
            BH = null;
        }
Exemple #2
0
        public Boolean BuyObject(int LineID, int Count, long Price, Player Character)
        {
            Boolean possible = true;

            try
            {
                if (Character.Kamas < Price)
                {
                    return(false);
                }
                var Line        = getLine(LineID);
                var ObjectToBuy = Line.Have(Count, Price);
                Character.InventoryCache.SubstractKamas(Price);
                if (ObjectToBuy.Owner != -1)
                {
                    var OwnerClient = Network.WorldServer.Clients.Find(x => x.Account != null && x.Account.ID == ObjectToBuy.Owner);
                    if (OwnerClient != null)
                    {
                        OwnerClient.Account.Data.BankKamas += ObjectToBuy.Price;
                        OwnerClient.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 65, new String[] { Price.ToString(), ObjectToBuy.Item.TemplateID.ToString(), 1 + "" }));
                    }
                    else
                    {
                        AccountDataTable.UpdateKamas(ObjectToBuy.Price, ObjectToBuy.Owner);
                        //TODO Cache vous IM MSG
                    }
                }
                Character.Send(new AccountStatsMessage(Character));
                var OldItem = ObjectToBuy.Item;
                Character.InventoryCache.Add(OldItem);

                OldItem.Template.newSold(ObjectToBuy.getQuantity(true), Price);
                DestroyObject(ObjectToBuy);
                BidHouseTable.Delete(ObjectToBuy.Item.ID);
                if (ObjectToBuy.Owner == -1)
                {
                    InventoryItemTable.Add(OldItem);
                }
                ObjectToBuy = null;
            }
            catch (Exception e)
            {
                possible = false;
            }
            return(possible);
        }
Exemple #3
0
 public override bool MoveItem(WorldClient Client, Database.Models.InventoryItemModel Item, ushort Quantity, bool Add = false)
 {
     if (Add)
     {
         long Taxe = (long)(Price * (Market.SellTaxe / 100));
         if (myClient.Account.Data.canTaxBidHouseItem(Market.HdvID) >= Market.countItem)
         {
             myClient.Send(new TextInformationMessage(Libs.Enumerations.TextInformationTypeEnum.INFO, 58));
             return(false);
         }
         if (myClient.Character.Kamas < Taxe)
         {
             myClient.Send(new TextInformationMessage(Libs.Enumerations.TextInformationTypeEnum.ERREUR, 76));
             return(false);
         }
         myClient.Character.InventoryCache.SubstractKamas(Taxe);
         int cantReal  = (int)(Math.Pow(10, Quantity) / 10);
         int nuevaCant = Item.Quantity - cantReal;
         if (nuevaCant <= 0)
         {
             myClient.Character.InventoryCache.RemoveItem(Item);
             myClient.Character.Send(new ObjectRemoveMessage(Item.ID));
         }
         else
         {
             Item.Quantity -= cantReal;
             myClient.Send(new ObjectQuantityMessage(Item.ID, Item.Quantity));
             Item = InventoryItemTable.TryCreateItem(Item.TemplateID, quantity: cantReal, Stats: Item.GetStats().ToItemStats());
         }
         var MarketItem = new BidHouseItem()
         {
             Price    = Price,
             Quantity = Quantity,
             Owner    = myClient.Account.ID,
             Item     = Item,
         };
         Market.addObject(MarketItem);
         BidHouseTable.Add(MarketItem);
         myClient.Send(new ExchangeMoveDistantObject('+', "", MarketItem.SerializeAsDisplayEquipmentOnMarket()));
         Client.Send(new AccountStatsMessage(myClient.Character));
     }
     else
     {
         var          MarketID = Market.HdvID;
         BidHouseItem BHI      = null;
         try
         {
             foreach (var BH in myClient.Account.Data.BHI[MarketID])
             {
                 if (BH.LineID == ItemID)
                 {
                     BHI = BH;
                     break;
                 }
             }
         }
         catch (Exception e)
         {
             return(false);
         }
         if (BHI == null)
         {
             return(false);
         }
         myClient.Account.Data.BHI[MarketID].Remove(BHI);
         var Object = BHI.Item;
         myClient.Character.InventoryCache.Add(Object);
         Market.DestroyObject(BHI);
         BidHouseTable.Delete(BHI.ItemID);
         myClient.Send(new ExchangeMoveDistantObject('-', "", ItemID + ""));
     }
     return(true);
 }