Beispiel #1
0
        private static void SendMoneyToSeller(Asda2ItemRecord item)
        {
            Character character = World.GetCharacter(item.OwnerId);

            if (character != null)
            {
                Asda2AuctionMgr.SendMoneyToSeller(item.Template.Name, item.AuctionPrice, item.Amount, character);
            }
            else
            {
                new AuctionSelledRecord(item.OwnerId, item.AuctionPrice, item.Amount, item.ItemId).Create();
            }
        }
Beispiel #2
0
        public static void OnLogin(Character chr)
        {
            uint guid = (uint)chr.Record.Guid;

            if (!Asda2AuctionMgr.SelledRecords.ContainsKey(guid))
            {
                return;
            }
            List <AuctionSelledRecord> selledRecord = Asda2AuctionMgr.SelledRecords[guid];

            foreach (AuctionSelledRecord record in selledRecord)
            {
                Asda2AuctionMgr.SendMoneyToSeller(Asda2ItemMgr.GetTemplate(record.ItemId).Name, record.GoldAmount,
                                                  record.ItemAmount, chr);
                record.DeleteLater();
            }

            selledRecord.Clear();
            Asda2AuctionMgr.SelledRecords.Remove(guid);
        }
Beispiel #3
0
        public static void TryBuy(List <int> aucIds, Character chr)
        {
            if (aucIds.Count == 0)
            {
                return;
            }
            List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>();
            uint amount1   = 0;
            bool?nullable1 = new bool?();

            foreach (int aucId in aucIds)
            {
                if (!Asda2AuctionMgr.AllAuctionItems.ContainsKey(aucId))
                {
                    chr.SendAuctionMsg("Can't found item you want to buy, may be some one already buy it.");
                    return;
                }

                Asda2ItemRecord allAuctionItem = Asda2AuctionMgr.AllAuctionItems[aucId];
                if (!nullable1.HasValue)
                {
                    nullable1 = new bool?(allAuctionItem.Template.IsShopInventoryItem);
                }
                bool?nullable2         = nullable1;
                bool shopInventoryItem = allAuctionItem.Template.IsShopInventoryItem;
                if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0)
                {
                    chr.YouAreFuckingCheater("Trying to buy shop\not shop item in one auction buy request.", 1);
                    chr.SendAuctionMsg("Buying from auction failed cause founded shop\not shop items in one request.");
                }

                asda2ItemRecordList.Add(allAuctionItem);
                amount1 += (uint)allAuctionItem.AuctionPrice;
            }

            if (chr.Money <= amount1)
            {
                chr.SendAuctionMsg("Failed to buy items. Not enoght money.");
            }
            else
            {
                if (nullable1.HasValue && nullable1.Value)
                {
                    if (chr.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count)
                    {
                        chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                        return;
                    }
                }
                else if (chr.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count)
                {
                    chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                    return;
                }

                chr.SubtractMoney(amount1);
                List <Asda2ItemTradeRef> items = new List <Asda2ItemTradeRef>();
                foreach (Asda2ItemRecord record in asda2ItemRecordList)
                {
                    Asda2AuctionMgr.SendMoneyToSeller(record);
                    Asda2AuctionMgr.UnRegisterItem(record);
                    int       amount2         = record.Amount;
                    int       auctionId       = record.AuctionId;
                    Asda2Item asda2Item       = (Asda2Item)null;
                    Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null);
                    int       num             = (int)chr.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true, ref asda2Item,
                                                                               new Asda2InventoryType?(), itemToCopyStats);
                    items.Add(new Asda2ItemTradeRef()
                    {
                        Amount = amount2,
                        Item   = asda2Item,
                        Price  = auctionId
                    });
                    record.DeleteLater();
                }

                Asda2AuctionHandler.SendItemsBuyedFromAukResponse(chr.Client, items);
                chr.SendMoneyUpdate();
            }
        }