コード例 #1
0
 private void ProcessItemsList(NetworkClient networkClient, GameClient client,
     string groupId, int groupPage, string subGroupId, string subGroupName, 
     string subGroupType, string subGroupLevel, Packet itemsList)
 {
     //Get all nodes of items
     XmlNodeList items = itemsList.GetNodes("O");
     if (items != null)
     {
         //For each node of items
         foreach (XmlNode item in items)
         {
             if (!ProcessItem(networkClient, client, groupId, groupPage, subGroupId,
                              subGroupName, subGroupType, subGroupLevel, item))
             {
                 return;
             }
         }
     }
 }
コード例 #2
0
        private void ProcessSubGroupsList(NetworkClient networkClient, GameClient client,
            string groupId, int groupPage, bool isAuction, Packet groups, 
            List<string> subGroupsOrderList)
        {
            //Get all subgroups nodes
            XmlNodeList itemsAndSubGroups = groups.GetNodes("O");
            if (itemsAndSubGroups != null)
            {
                //For each subgroup node
                foreach (XmlNode itemOrSubGroup in itemsAndSubGroups)
                {
                    //If it`s valid node
                    if (itemOrSubGroup.Attributes != null)
                    {
                        XmlAttribute name;
                        switch (groupId)
                        {
                            case GameItemsGroupID.PLANT_PACKS:
                                name = itemOrSubGroup.Attributes["namef"];
                                break;
                            case GameItemsGroupID.DOCUMENTS:
                                name = itemOrSubGroup.Attributes["namef"] ??
                                       itemOrSubGroup.Attributes["name"];
                                break;
                            default:
                                name = itemOrSubGroup.Attributes["name"];
                                break;
                        }

                        XmlAttribute type = itemOrSubGroup.Attributes["type"];

                        //If the node doesn`t have own name, ignore this node
                        if (name == null || type == null)
                        {
                            continue;
                        }

                        string subGroupId = name.InnerText;
                        string subGroupType = type.InnerText.Replace(".", "");

                        //Store subgroup->group relation
                        _gameItemsGroups.StoreSubGroupIDToGroupRelation(groupId, subGroupId, subGroupType);

                        //If we in the full processing mode (subGroupsOrderList != null),
                        //groupId should be stored in the appropriate list
                        if (subGroupsOrderList != null)
                        {
                            string ident = GameItemsSubGroup.GetSubGroupIdent(subGroupId, subGroupType);
                            subGroupsOrderList.Add(ident);
                        }

                        //Is this a subgroup of items?
                        XmlAttribute auc = itemOrSubGroup.Attributes["auc"];
                        if (auc != null)
                        {
                            //Check IgnoreForShopping flag
                            GameItemsSubGroup subGroup = _gameItemsGroups[groupId].GetSubGroup(subGroupId, subGroupType);
                            if (subGroup != null && (subGroup.IgnoreForShopping || subGroup.ItemsCount == 0))
                            {
                                continue;
                            }

                            //okay, now go inside the subgroup
                            XmlAttribute lvl = itemOrSubGroup.Attributes["lvl"];
                            XmlAttribute txt = itemOrSubGroup.Attributes["txt"];

                            //Verify parameters
                            if (txt != null)
                            {
                                string subGroupName = GameItem.GetPureItemText(txt.InnerText);
                                string subGroupLevel = lvl != null ? lvl.InnerText : "";

                                //There is one page available at least
                                int pagesCount = 1;

                                //For each page of items
                                for (int subGroupPage = 0; subGroupPage < pagesCount; subGroupPage++)
                                {
                                    //Make the filter string
                                    string filter = string.Format(@"name:{0},type:{1},lvl:{2}",
                                        subGroupId, subGroupType, subGroupLevel);

                                    //Get items list
                                    //Query params: 1: item group ID, 2: filter, 3: page number, 4: is auction?
                                    string getGroupsItemsListQuery = Packet.BuildPacket(FromClient.SHOP,
                                        Shop.ITEMS_GET_LIST, groupId, filter, subGroupPage,
                                        isAuction);
                                    networkClient.SendData(getGroupsItemsListQuery);

                                    //Get items list
                                    Packet groupItemsList = networkClient.InputQueue.Pop(FromServer.SHOP_DATA);

                                    if (groupItemsList != null)
                                    {
                                        //Calculate pages count or set according to ShopPagesLimit value
                                        if (subGroupPage == 0)
                                        {
                                            if (subGroup == null || subGroup.ShopPagesLimit == 0)
                                            {
                                                int itemsCount = int.Parse(groupItemsList["@m"]);
                                                pagesCount = itemsCount / 8 + (itemsCount % 8 > 0 ? 1 : 0);
                                            }
                                            else
                                            {
                                                pagesCount = subGroup.ShopPagesLimit;
                                            }
                                        }

                                        //Process items list
                                        ProcessItemsList(networkClient, client, groupId, groupPage, subGroupId,
                                            subGroupName, subGroupType, subGroupLevel, groupItemsList);
                                    }
                                }
                            }
                        }

                        //otherwise let`s process standalone item
                        else
                        {
                            //Check IgnoreForShopping flag
                            GameItemsSubGroup subGroup = _gameItemsGroups[groupId].GetSubGroup(subGroupId, subGroupType);
                            if (subGroup != null && (subGroup.IgnoreForShopping || subGroup.ItemsCount == 0))
                            {
                                continue;
                            }

                            XmlAttribute txt = itemOrSubGroup.Attributes["txt"];
                            XmlAttribute lvl = itemOrSubGroup.Attributes["lvl"];

                            //Verify parameters
                            if (txt != null)
                            {
                                string subGroupName = GameItem.GetPureItemText(txt.InnerText);
                                string subGroupLevel = lvl != null ? lvl.InnerText : "";

                                //Process item
                                ProcessItem(networkClient, client, groupId, 0, subGroupId, subGroupName,
                                            subGroupType, subGroupLevel, itemOrSubGroup);
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void ProcessMyAucItemsList(NetworkClient networkClient, GameClient client, 
                                           Packet itemsList)
        {
            //Get all nodes of items
            XmlNodeList items = itemsList.GetNodes("O");
            if (items != null)
            {
                //For each node of items
                foreach (XmlNode item in items)
                {
                    //Create new my shop item
                    ShopItem myItem = Helper.ParseShopItem(item, _gameItemsGroups);

                    //Validate the item
                    if (myItem != null && !string.IsNullOrEmpty(myItem.SubGroupID))
                    {
                        string groupId = _gameItemsGroups.SubGroupToGroupId(myItem.SubGroupID,
                                                                            myItem.SubGroupType);
                        if (!string.IsNullOrEmpty(groupId))
                        {
                            //Get subgroup
                            GameItemsSubGroup sg = _gameItemsGroups[groupId].GetSubGroup(
                                myItem.SubGroupID, myItem.SubGroupType);

                            //Cache items list from auction
                            CacheAuctionItems(networkClient, groupId, myItem.SubGroupID,
                                              sg.Type, sg.Level);

                            //Do dumping
                            DoDumping(networkClient, client, myItem, true);
                        }
                    }
                }
            }
        }