Exemplo n.º 1
0
        private void ParseHeader(ref ParsedItem item, ref string input)
        {
            var dataItem = itemDataService.ParseItem(input);

            item.Name     = dataItem.Name;
            item.TypeLine = dataItem.Type;
            item.Rarity   = dataItem.Rarity;

            if (item.Rarity == Rarity.Unknown)
            {
                var lines = NewlinePattern.Split(input);
                item.Rarity = GetRarity(lines[0]);
            }

            if (string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.TypeLine))
            {
                throw new NotSupportedException("Item not found.");
            }

            if (item.Rarity != Rarity.DivinationCard)
            {
                item.ItemLevel  = GetInt(patterns.ItemLevel, input);
                item.Identified = !patterns.Unidentified.IsMatch(input);
                item.Corrupted  = patterns.Corrupted.IsMatch(input);
            }
        }
Exemplo n.º 2
0
        public async Task <ParsedItem> ParseItem(string itemText)
        {
            await languageProvider.FindAndSetLanguage(itemText);

            try
            {
                itemText = new ItemNameTokenizer().CleanString(itemText);
                var item = new ParsedItem
                {
                    ItemText = itemText
                };

                ParseHeader(ref item, ref itemText);
                ParseProperties(ref item, ref itemText);
                ParseSockets(ref item, ref itemText);
                ParseInfluences(ref item, ref itemText);
                ParseMods(ref item, ref itemText);

                return(item);
            }
            catch (Exception e)
            {
                logger.Error(e, "Could not parse item.");
                return(null);
            }
        }
Exemplo n.º 3
0
        private void ParseProperties(ref ParsedItem item, ref string input)
        {
            var blocks = SeparatorPattern.Split(input);

            item.Armor                    = GetInt(patterns.Armor, blocks[1]);
            item.EnergyShield             = GetInt(patterns.EnergyShield, blocks[1]);
            item.Evasion                  = GetInt(patterns.Evasion, blocks[1]);
            item.ChanceToBlock            = GetInt(patterns.ChanceToBlock, blocks[1]);
            item.Quality                  = GetInt(patterns.Quality, blocks[1]);
            item.MapTier                  = GetInt(patterns.MapTier, blocks[1]);
            item.ItemQuantity             = GetInt(patterns.ItemQuantity, blocks[1]);
            item.ItemRarity               = GetInt(patterns.ItemRarity, blocks[1]);
            item.MonsterPackSize          = GetInt(patterns.MonsterPackSize, blocks[1]);
            item.AttacksPerSecond         = GetDouble(patterns.AttacksPerSecond, blocks[1]);
            item.CriticalStrikeChance     = GetDouble(patterns.CriticalStrikeChance, blocks[1]);
            item.Extended.ElementalDps    = GetDps(patterns.ElementalDamage, blocks[1], item.AttacksPerSecond);
            item.Extended.PhysicalDps     = GetDps(patterns.PhysicalDamage, blocks[1], item.AttacksPerSecond);
            item.Extended.DamagePerSecond = item.Extended.ElementalDps + item.Extended.PhysicalDps;
            item.Blighted                 = patterns.Blighted.IsMatch(blocks[0]);

            if (item.Rarity == Rarity.Gem)
            {
                item.GemLevel = GetInt(patterns.Level, blocks[1]);
            }
        }
Exemplo n.º 4
0
        private void ParseInfluences(ref ParsedItem item, ref string input)
        {
            var blocks        = SeparatorPattern.Split(input);
            var strippedInput = string.Concat(blocks.Skip(1).ToList());

            item.Influences.Crusader = patterns.Crusader.IsMatch(strippedInput);
            item.Influences.Elder    = patterns.Elder.IsMatch(strippedInput);
            item.Influences.Hunter   = patterns.Hunter.IsMatch(strippedInput);
            item.Influences.Redeemer = patterns.Redeemer.IsMatch(strippedInput);
            item.Influences.Shaper   = patterns.Shaper.IsMatch(strippedInput);
            item.Influences.Warlord  = patterns.Warlord.IsMatch(strippedInput);
        }
Exemplo n.º 5
0
        private void ParseSockets(ref ParsedItem item, ref string input)
        {
            var result = patterns.Socket.Match(input);

            if (result.Success)
            {
                var groups = result.Groups
                             .Where(x => !string.IsNullOrEmpty(x.Value))
                             .Select(x => x.Value)
                             .ToList();
                for (var index = 1; index < groups.Count; index++)
                {
                    var groupValue = groups[index].Replace("-", "").Trim();
                    while (groupValue.Length > 0)
                    {
                        switch (groupValue[0])
                        {
                        case 'B': item.Sockets.Add(new Socket()
                            {
                                Group = index - 1, Color = SocketColor.Blue
                            }); break;

                        case 'G': item.Sockets.Add(new Socket()
                            {
                                Group = index - 1, Color = SocketColor.Green
                            }); break;

                        case 'R': item.Sockets.Add(new Socket()
                            {
                                Group = index - 1, Color = SocketColor.Red
                            }); break;

                        case 'W': item.Sockets.Add(new Socket()
                            {
                                Group = index - 1, Color = SocketColor.White
                            }); break;

                        case 'A': item.Sockets.Add(new Socket()
                            {
                                Group = index - 1, Color = SocketColor.Abyss
                            }); break;
                        }
                        groupValue = groupValue.Substring(1);
                    }
                }
            }
        }
Exemplo n.º 6
0
 private void ParseMods(ref ParsedItem item, ref string input)
 {
     item.Extended.Mods = statsDataService.ParseMods(input);
 }