Esempio n. 1
0
        public static void LoadDataFromAukPageRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position += 15;
            AucionCategoties category = (AucionCategoties)packet.ReadInt16();

            ++packet.Position;
            short option1 = packet.ReadInt16();
            byte  option2 = packet.ReadByte();
            byte  option3 = packet.ReadByte();
            byte  curPage = packet.ReadByte();

            try
            {
                AuctionLevelCriterion    requiredLevelCriterion;
                Asda2ItemAuctionCategory index = Asda2AuctionHandler.CalcCategory(category, option1, option2, option3,
                                                                                  out requiredLevelCriterion);
                SortedSet <Asda2ItemRecord> source = Asda2AuctionMgr.CategorizedItemsById[index][requiredLevelCriterion];
                Asda2AuctionHandler.SendItemsOnAukInfoResponse(client,
                                                               source.Skip <Asda2ItemRecord>((int)curPage * 7).Take <Asda2ItemRecord>(7),
                                                               (byte)((source.Count - 1) / 7), curPage);
            }
            catch
            {
                client.ActiveCharacter.YouAreFuckingCheater("Sends wrong auction show items request.", 1);
            }
        }
Esempio n. 2
0
 public static void ShowMyAukItemsRequest(IRealmClient client, RealmPacketIn packet)
 {
     packet.Position += 15;
     if (packet.ReadByte() == (byte)1)
     {
         Asda2AuctionHandler.SendMyAukItemsInfoResponse(client,
                                                        Asda2AuctionMgr.GetCharacterRegularItems((uint)client.ActiveCharacter.Record.Guid));
     }
     else
     {
         Asda2AuctionHandler.SendMyAukItemsInfoResponse(client,
                                                        Asda2AuctionMgr.GetCharacterShopItems((uint)client.ActiveCharacter.Record.Guid));
     }
 }
Esempio n. 3
0
        public static void TryRemoveItems(Character activeCharacter, List <int> itemIds)
        {
            uint entityLowId = activeCharacter.Record.EntityLowId;

            if (!Asda2AuctionMgr.ItemsByOwner.ContainsKey(entityLowId))
            {
                activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded.");
            }
            else
            {
                bool?nullable1 = new bool?();
                List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>();
                foreach (int itemId in itemIds)
                {
                    if (!Asda2AuctionMgr.ItemsByOwner[entityLowId].ContainsKey(itemId))
                    {
                        asda2ItemRecordList.Clear();
                        activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded.");
                        return;
                    }

                    Asda2ItemRecord asda2ItemRecord = Asda2AuctionMgr.ItemsByOwner[entityLowId][itemId];
                    if (!nullable1.HasValue)
                    {
                        nullable1 = new bool?(asda2ItemRecord.Template.IsShopInventoryItem);
                    }
                    bool?nullable2         = nullable1;
                    bool shopInventoryItem = asda2ItemRecord.Template.IsShopInventoryItem;
                    if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0)
                    {
                        activeCharacter.YouAreFuckingCheater(
                            "Trying to remove shop\not shop item in one auction buy request.", 1);
                        activeCharacter.SendAuctionMsg(
                            "Removing from auction failed cause founded shop\not shop items in one request.");
                    }

                    asda2ItemRecordList.Add(asda2ItemRecord);
                }

                if (nullable1.Value)
                {
                    if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count)
                    {
                        activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                        return;
                    }
                }
                else if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count)
                {
                    activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                    return;
                }

                List <Asda2ItemTradeRef> asda2Items = new List <Asda2ItemTradeRef>();
                foreach (Asda2ItemRecord record in asda2ItemRecordList)
                {
                    Asda2AuctionMgr.UnRegisterItem(record);
                    int       amount          = record.Amount;
                    int       auctionId       = record.AuctionId;
                    Asda2Item asda2Item       = (Asda2Item)null;
                    Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null);
                    int       num             = (int)activeCharacter.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true,
                                                                                           ref asda2Item, new Asda2InventoryType?(), itemToCopyStats);
                    record.DeleteLater();
                    asda2Items.Add(new Asda2ItemTradeRef()
                    {
                        Amount = amount,
                        Item   = asda2Item,
                        Price  = auctionId
                    });
                    Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId)
                    .AddAttribute("source", 0.0, "removed_from_auction").AddItemAttributes(asda2Item, "").Write();
                }

                Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, asda2Items);
            }
        }
Esempio n. 4
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();
            }
        }
Esempio n. 5
0
        public static void TryRemoveItems(Character activeCharacter, List <int> itemIds)
        {
            var chrId = activeCharacter.Record.EntityLowId;

            if (!ItemsByOwner.ContainsKey(chrId))
            {
                activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded.");
                return;
            }
            bool?isShopItems = null;
            var  items       = new List <Asda2ItemRecord>();

            foreach (var itemId in itemIds)
            {
                if (!ItemsByOwner[chrId].ContainsKey(itemId))
                {
                    items.Clear();
                    activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded.");
                    return;
                }
                var item = ItemsByOwner[chrId][itemId];
                if (isShopItems == null)
                {
                    isShopItems = item.Template.IsShopInventoryItem;
                }
                if (isShopItems != item.Template.IsShopInventoryItem)
                {
                    activeCharacter.YouAreFuckingCheater("Trying to remove shop\not shop item in one auction buy request.");
                    activeCharacter.SendAuctionMsg("Removing from auction failed cause founded shop\not shop items in one request.");
                }
                items.Add(item);
            }
            if ((bool)isShopItems)
            {
                if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < items.Count)
                {
                    activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                    return;
                }
            }
            else
            {
                if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < items.Count)
                {
                    activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                    return;
                }
            }
            var r = new List <Asda2ItemTradeRef>();

            foreach (var rec in items)
            {
                UnRegisterItem(rec);
                var       amount  = rec.Amount;
                var       aucId   = rec.AuctionId;
                Asda2Item item    = null;
                var       aucItem = Asda2Item.CreateItem(rec, (Character)null);
                activeCharacter.Asda2Inventory.TryAdd(rec.ItemId, rec.Amount, true, ref item, null, aucItem);
                rec.DeleteLater();
                r.Add(new Asda2ItemTradeRef {
                    Amount = amount, Item = item, Price = aucId
                });
                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId)
                .AddAttribute("source", 0, "removed_from_auction")
                .AddItemAttributes(item)
                .Write();
            }
            Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, r);
        }
Esempio n. 6
0
        public static void TryBuy(List <int> aucIds, Character chr)
        {
            if (aucIds.Count == 0)
            {
                return;
            }
            var  itemsToBuy  = new List <Asda2ItemRecord>();
            var  totalPrice  = 0u;
            bool?isShopItems = null;

            foreach (var aucId in aucIds)
            {
                if (!AllAuctionItems.ContainsKey(aucId))
                {
                    chr.SendAuctionMsg("Can't found item you want to buy, may be some one already buy it.");
                    return;
                }
                var item = AllAuctionItems[aucId];
                if (isShopItems == null)
                {
                    isShopItems = item.Template.IsShopInventoryItem;
                }
                if (isShopItems != item.Template.IsShopInventoryItem)
                {
                    chr.YouAreFuckingCheater("Trying to buy shop\not shop item in one auction buy request.");
                    chr.SendAuctionMsg("Buying from auction failed cause founded shop\not shop items in one request.");
                }
                itemsToBuy.Add(item);
                totalPrice += (uint)item.AuctionPrice;
            }
            if (chr.Money <= totalPrice)
            {
                chr.SendAuctionMsg("Failed to buy items. Not enoght money.");
                return;
            }
            if (isShopItems != null && isShopItems.Value)
            {
                if (chr.Asda2Inventory.FreeShopSlotsCount < itemsToBuy.Count)
                {
                    chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                    return;
                }
            }
            else
            {
                if (chr.Asda2Inventory.FreeRegularSlotsCount < itemsToBuy.Count)
                {
                    chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                    return;
                }
            }
            chr.SubtractMoney(totalPrice);
            var r = new List <Asda2ItemTradeRef>();

            foreach (var itemRec in itemsToBuy)
            {
                SendMoneyToSeller(itemRec);
                UnRegisterItem(itemRec);
                var       amount    = itemRec.Amount;
                var       auctionId = itemRec.AuctionId;
                Asda2Item addedItem = null;
                var       item      = Asda2Item.CreateItem(itemRec, (Character)null);
                chr.Asda2Inventory.TryAdd(itemRec.ItemId, itemRec.Amount, true, ref addedItem, null, item);
                r.Add(new Asda2ItemTradeRef {
                    Amount = amount, Item = addedItem, Price = auctionId
                });
                itemRec.DeleteLater();
            }
            Asda2AuctionHandler.SendItemsBuyedFromAukResponse(chr.Client, r);
            chr.SendMoneyUpdate();
        }
Esempio n. 7
0
        public static void RegisterItemToAukRequest(IRealmClient client, RealmPacketIn packet)
        {
            Character            activeCharacter = client.ActiveCharacter;
            Asda2PlayerInventory asda2Inventory  = activeCharacter.Asda2Inventory;

            packet.Position += 15;
            int num1 = 0;
            List <Asda2ItemTradeRef> items = new List <Asda2ItemTradeRef>();

            for (int index = 0; index < 5 && packet.RemainingLength >= 50; ++index)
            {
                packet.Position += 4;
                byte  num2 = packet.ReadByte();
                short num3 = packet.ReadInt16();
                packet.Position += 12;
                int num4 = packet.ReadInt32();
                packet.Position += 34;
                int num5 = packet.ReadInt32();
                packet.Position += 41;
                if (num5 < 0 || num5 > 100000000)
                {
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tried to use wrong price while registering auk items : " + (object)num3, 1);
                    Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                  (List <Asda2ItemTradeRef>)null);
                    return;
                }

                if (num3 < (short)0 || num3 > (short)70)
                {
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tried to use wrong cell while registering auk items : " + (object)num3, 1);
                    Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                  (List <Asda2ItemTradeRef>)null);
                    return;
                }

                Asda2Item asda2Item;
                switch (num2)
                {
                case 1:
                    asda2Item = asda2Inventory.ShopItems[(int)num3];
                    break;

                case 2:
                    asda2Item = asda2Inventory.RegularItems[(int)num3];
                    break;

                default:
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tried to use wrong inventory while registering auk items : " + (object)num2, 1);
                    Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                  (List <Asda2ItemTradeRef>)null);
                    return;
                }

                items.Add(new Asda2ItemTradeRef()
                {
                    Item   = asda2Item,
                    Amount = num4,
                    Price  = num5
                });
                num1 += num5;
            }

            if ((double)client.ActiveCharacter.Money <=
                (double)num1 * (double)CharacterFormulas.AuctionPushComission)
            {
                client.ActiveCharacter.SendAuctionMsg("Not enought money to register items.");
                Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client, (List <Asda2ItemTradeRef>)null);
            }
            else
            {
                Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client, items);
                foreach (Asda2ItemTradeRef itemRef in items)
                {
                    if (itemRef.Item == null)
                    {
                        activeCharacter.SendAuctionMsg("Failed to register item cause not founded.");
                        Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                      (List <Asda2ItemTradeRef>)null);
                        return;
                    }

                    if (itemRef.Amount < 0 || itemRef.Amount > itemRef.Item.Amount)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater(
                            "Tried to use wrong item amount while registering auk items : " + (object)itemRef.Amount,
                            1);
                        Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                      (List <Asda2ItemTradeRef>)null);
                        return;
                    }

                    if (itemRef.Item.IsSoulbound)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater(
                            "Tried to use soulbounded item while registering auk items : " + (object)itemRef.Amount,
                            1);
                        Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                      (List <Asda2ItemTradeRef>)null);
                        return;
                    }

                    asda2Inventory.AuctionItem(itemRef);
                }

                AchievementProgressRecord progressRecord =
                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(10U);
                switch (++progressRecord.Counter)
                {
                case 100:
                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Merchant48);
                    break;

                case 200:
                    client.ActiveCharacter.GetTitle(Asda2TitleId.Merchant48);
                    break;
                }

                progressRecord.SaveAndFlush();
                activeCharacter.SendAuctionMsg("You have success with registering auction items.");
                activeCharacter.SendMoneyUpdate();
            }
        }