Exemple #1
0
        public void Buy(uint uid, uint quantity, uint price)
        {
            BidShopItemRecord item = this.GetItem(uid);

            if (item != null)
            {
                if (item.Price == price)
                {
                    if (this.Character.RemoveKamas((int)price))
                    {
                        this.Character.Inventory.AddItem(item.ToCharacterItemRecord(this.Character.Id));
                        item.RemoveElement();
                        this.ShowList(item.GId);

                        if (this.Items.Count(x => x.GId == item.GId) == 0)
                        {
                            this.RemoveGId(item.GId);
                        }

                        this.AddGain(item);
                    }
                }
            }
            else
            {
                this.Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 64);
                this.ShowList(this.GIdWatched);
                this.ShowTypes(this.GIdWatched);
            }
        }
Exemple #2
0
        private BidExchangerObjectInfo[] SortedItems(List <BidShopItemRecord> items)
        {
            List <BidExchangerObjectInfo> result = new List <BidExchangerObjectInfo>();

            foreach (var itemsData in ItemCollection <BidShopItemRecord> .SortByEffects(items).Keys)
            {
                BidShopItemRecord sample = null;

                int[] prices = new int[3];

                for (int i = 0; i < this.BidShop.Quantities.Count; i++)
                {
                    int quantityPrice = 0;

                    List <BidShopItemRecord> sortedItems = itemsData.FindAll(x => x.Quantity == this.BidShop.Quantities[i]).OrderBy(x => x.Price).ToList();

                    if (sortedItems.Count > 0)
                    {
                        quantityPrice = (int)sortedItems[0].Price;
                        sample        = sortedItems[0];
                    }
                    prices[i] = quantityPrice;
                }

                result.Add(sample.GetBidExchangerObjectInfo(prices.ToArray()));
            }
            return(result.ToArray());
        }
        public void MoveItem(uint uid, int quantity)
        {
            var item     = CharacterBidItems.Find(x => x.objectUID == uid);
            var realItem = BidShopItemRecord.GetBidShopItem(uid);

            SaveTask.RemoveElement(realItem);
            Client.Character.Inventory.Add(new CharacterItemRecord(realItem.UID, 63, realItem.GID, Client.Character.Id, realItem.Quantity, realItem.GetEffects()));
            OpenSellPanel();
        }
 public void RemoveItem(BidShopItemRecord item)
 {
     item.RemoveElement();
     ShowItemList(item.GID, true);
     if (!ItemGIDExistInBid(item.GID))
     {
         DeleteGIDFromBidShop(item.GID);
     }
 }
        public void ModifyItemPriced(uint uid, int quantity, uint price)
        {
            BidShopItemRecord item = this.GetSelledItem(uid);

            if (item != null)
            {
                item.Price    = price;
                item.Quantity = (uint)quantity;
                item.UpdateElement();
                this.Open();
            }
        }
        public void MoveItemPriced(uint uid, int quantity, uint price)
        {
            CharacterItemRecord item = this.Character.Inventory.GetItem(uid);

            if (item != null && item.Quantity >= quantity && item.CanBeExchanged())
            {
                BidShopItemRecord selledItem = item.ToBidShopItemRecord(this.BidShop.Id, this.Character.Client.Account.Id, price);
                selledItem.Quantity = (uint)quantity;
                this.Character.Inventory.RemoveItem(item.UId, (uint)quantity);
                this.AddSelledItem(selledItem);
            }
        }
        public override void MoveItem(uint uid, int quantity)
        {
            if (quantity < 0)
            {
                BidShopItemRecord item = this.GetSelledItem(uid);

                if (item != null && item.Quantity >= Math.Abs(quantity))
                {
                    item.RemoveElement();
                    this.SelledItems.Remove(item);
                    this.Character.Inventory.AddItem(item.ToCharacterItemRecord(this.Character.Id));
                    this.Character.Client.Send(new ExchangeBidHouseItemRemoveOkMessage((int)uid));
                }
            }
        }
Exemple #8
0
        public void AddGain(BidShopItemRecord item)
        {
            var client = WorldServer.Instance.GetOnlineClient(item.AccountId);

            string notification = "Banque : + " + item.Price + " Kamas (vente de " + item.Quantity + " <b>[" + item.Template.Name + "]</b>) hors ligne.";

            if (client != null)
            {
                AccountInformationsRecord.AddBankKamas(item.AccountId, item.Price);
                client.Character.OnItemSelled(item.GId, item.Quantity, item.Price);
            }
            else
            {
                AccountInformationsRecord.AddBankKamas(item.AccountId, item.Price);
                NotificationRecord.Add(item.AccountId, notification);
            }
        }
        List <BidExchangerObjectInfo> SortedItems(List <BidShopItemRecord> items)
        {
            List <BidExchangerObjectInfo> result = new List <BidExchangerObjectInfo>();

            uint[] bidShopQuantites = Descriptor.quantities.ToArray();
            foreach (var itemsData in GetItemSortedByEffects(items))
            {
                var firstQuantityItemsDatas  = itemsData.Key.FindAll(x => x.Quantity == bidShopQuantites[0]);
                var secondQuantityItemsDatas = itemsData.Key.FindAll(x => x.Quantity == bidShopQuantites[1]);
                var thirdQuantityItemsDatas  = itemsData.Key.FindAll(x => x.Quantity == bidShopQuantites[2]);

                firstQuantityItemsDatas  = firstQuantityItemsDatas.OrderBy(x => x.Price).ToList();
                secondQuantityItemsDatas = secondQuantityItemsDatas.OrderBy(x => x.Price).ToList();
                thirdQuantityItemsDatas  = thirdQuantityItemsDatas.OrderBy(x => x.Price).ToList();

                BidShopItemRecord sample = null;
                int firstQuantityPrice   = 0;
                int secondQuantityPrice  = 0;
                int thirdQuantiyPrice    = 0;
                if (firstQuantityItemsDatas.Count() > 0)
                {
                    firstQuantityPrice = (int)firstQuantityItemsDatas[0].Price;
                    sample             = firstQuantityItemsDatas[0];
                }
                if (secondQuantityItemsDatas.Count() > 0)
                {
                    secondQuantityPrice = (int)secondQuantityItemsDatas[0].Price;
                    sample = secondQuantityItemsDatas[0];
                }
                if (thirdQuantityItemsDatas.Count() > 0)
                {
                    thirdQuantiyPrice = (int)thirdQuantityItemsDatas[0].Price;
                    sample            = thirdQuantityItemsDatas[0];
                }
                if (sample != null)
                {
                    var prices = new int[3] {
                        firstQuantityPrice, secondQuantityPrice, thirdQuantiyPrice
                    };
                    result.Add(new BidExchangerObjectInfo(sample.UID, sample.GetEffects(), prices));
                }
            }
            return(result);
        }
Exemple #10
0
 public static uint PopNextUID()
 {
     Locker.EnterReadLock();
     try
     {
         List <uint> uids = CharactersItems.ConvertAll <uint>(x => x.UID);
         uids.AddRange(BidShopItemRecord.GetAllItemsUIDs());
         uids.AddRange(BankItemRecord.GetAllItemsUIDs());
         uids.Sort();
         if (uids.Count == 0)
         {
             return(1);
         }
         return(uids.Last() + 1);
     }
     finally
     {
         Locker.ExitReadLock();
     }
 }
        public static void HandleCharacterDeletion(CharacterDeletionRequestMessage message, WorldClient client) // finish this
        {
            CharacterRecord deletedCharacter = CharacterRecord.GetCharacterRecordById(message.characterId);

            if (deletedCharacter == null)
            {
                return;
            }
            StatsRecord.GetStatsRecord(message.characterId).RemoveElement();
            CharacterRecord.Characters.Remove(deletedCharacter);
            client.Characters.Remove(deletedCharacter);
            deletedCharacter.RemoveElement();
            CharacterItemRecord.RemoveAll(message.characterId);
            GeneralShortcutRecord.RemoveAll(message.characterId);
            CharacterSpellRecord.RemoveAll(message.characterId);
            CharacterJobRecord.RemoveAll(message.characterId);
            BidShopGainRecord.RemoveAll(message.characterId);
            CharacterGuildRecord.RemoveAll(message.characterId); // Si il est meneur de guilde?
            BidShopItemRecord.RemoveAll(message.characterId);
            Logger.Log("Character " + deletedCharacter.Name + " deleted");

            client.Send(new CharactersListMessage(client.Characters.ConvertAll <CharacterBaseInformations>(x => x.GetBaseInformation()), false));
        }
 public void AddSelledItem(BidShopItemRecord item)
 {
     item.AddElement();
     this.SelledItems.Add(item);
     this.Character.Client.Send(new ExchangeBidHouseItemAddOkMessage(item.GetObjectItemToSellInBid()));
 }
 public override void Open()
 {
     this.SelledItems = BidShopItemRecord.GetSellerItems(this.BidShop.Id, this.Character.Client.Account.Id);
     this.Character.Client.Send(new ExchangeStartedBidSellerMessage(this.BidShop.GetBuyerDescriptor((int)this.Npc.Id),
                                                                    this.SelledItems.ConvertAll <ObjectItemToSellInBid>(x => x.GetObjectItemToSellInBid()).ToArray()));
 }
Exemple #14
0
        public void Add(BidShopItemRecord item)
        {
            var newItem = new CharacterItemRecord(item.UID, 63, item.GID, Character.Id, item.Quantity, item.GetEffects());

            Add(newItem);
        }