Exemplo n.º 1
0
        public static List <ItemInfo> GetItemsByLocations(D2DataReader dataReader, List <BodyLocation> locations)
        {
            List <ItemInfo> Items = new List <ItemInfo>();

            dataReader.ItemSlotAction(locations, (item, player, unitReader, stringReader, inventoryReader) => {
                Items.Add(new ItemInfo(item, player, unitReader, stringReader, inventoryReader));
            });
            return(Items);
        }
        public static List <ItemInfo> GetItemsByLocations(D2DataReader dataReader, List <BodyLocation> locations)
        {
            List <ItemInfo> Items = new List <ItemInfo>();

            dataReader.ItemSlotAction(locations, (itemReader, item) => {
                Items.Add(new ItemInfo(itemReader, item));
            });
            return(Items);
        }
Exemplo n.º 3
0
        void HandleClientConnection(NamedPipeServerStream pipe)
        {
            var reader  = new JsonStreamReader(pipe, Encoding.UTF8);
            var request = reader.ReadJson <QueryRequest>();

            QueryResponse response           = new QueryResponse();
            var           equipmentLocations = GetItemLocations(request);

            dataReader.ItemSlotAction(equipmentLocations, (itemReader, item) => {
                ItemResponse data = new ItemResponse();
                data.ItemName     = itemReader.GetFullItemName(item);
                data.Properties   = itemReader.GetMagicalStrings(item);
                response.Items.Add(data);
            });

            response.IsValid = equipmentLocations.Count > 0;
            response.Success = response.Items.Count > 0;
            var writer = new JsonStreamWriter(pipe, Encoding.UTF8);

            writer.WriteJson(response);
            writer.Flush();
        }
Exemplo n.º 4
0
        void HandleClientConnection(Object pipeObject)
        {
            try
            {
                NamedPipeServerStream pipe = (NamedPipeServerStream)pipeObject;
                var reader  = new JsonStreamReader(pipe, Encoding.UTF8);
                var request = reader.ReadJson <QueryRequest>();

                QueryResponse response           = new QueryResponse();
                var           equipmentLocations = GetItemLocations(request);

                dataReader.ItemSlotAction(equipmentLocations, (itemReader, item) =>
                {
                    ItemQuality quality = itemReader.GetItemQuality(item);
                    string color        = null;
                    switch (quality)
                    {
                    case ItemQuality.Low:
                    case ItemQuality.Normal:
                    case ItemQuality.Superior:
                        color = "WHITE";
                        break;

                    case ItemQuality.Magic:
                        color = "BLUE";
                        break;

                    case ItemQuality.Rare:
                        color = "YELLOW";
                        break;

                    case ItemQuality.Crafted:
                    case ItemQuality.Tempered:
                        color = "ORANGE";
                        break;

                    case ItemQuality.Unique:
                        color = "GOLD";
                        break;

                    case ItemQuality.Set:
                        color = "GREEN";
                        break;
                    }

                    ItemResponse data = new ItemResponse();
                    data.ItemName     = itemReader.GetFullItemName(item);
                    data.BaseItem     = itemReader.GetGrammaticalName(itemReader.GetItemName(item), out string grammerCase);
                    data.Quality      = color;
                    data.Properties   = itemReader.GetMagicalStrings(item);
                    data.Location     = itemReader.GetItemData(item)?.BodyLoc ?? BodyLocation.None;
                    response.Items.Add(data);
                });

                response.IsValid = equipmentLocations.Count > 0;
                response.Success = response.Items.Count > 0;
                var writer = new JsonStreamWriter(pipe, Encoding.UTF8);
                writer.WriteJson(response);
                writer.Flush();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Logger.Instance.WriteLine("exception caught in HandleClientConnection:");
                Logger.Instance.WriteLine(e.Message);
                return;
            }
        }