private int GetStackSize() { if (!RawInfo.Contains("Stack Size:")) { return(1); } int res = Convert.ToInt32(Regex.Match(RawInfo, @"Stack Size: [0-9.]+/([0-9.]+)").Groups[1].Value); return(res); }
private Price GetPrice() { Price price = new Price(); if (!RawInfo.Contains("Note: ~price") && !RawInfo.Contains("Note: ~b/o")) { return(new Price()); } if (Regex.IsMatch(RawInfo, "~b/o [0-9.]+/[0-9.]+")) { price.Cost = Convert.ToDouble(Regex.Replace(RawInfo, @"([\w\s\W\n]+Note: ~b/o )|(/+[\w\s\W]*)|([^0-9.])", "")); price.ForNumberItems = Convert.ToInt32(Regex.Replace(RawInfo, @"([\w\s\W]+/)|([^0-9.])", "")); price.CurrencyType = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", "")); } else if (Regex.IsMatch(RawInfo, @"~b/o +[0-9.]+\s\D*")) { price.Cost = Convert.ToDouble(Regex.Replace(RawInfo, @"[\w\W]*~b/o |[^0-9.]*", "").Replace('.', ',')); price.ForNumberItems = GetStackSize(); price.CurrencyType = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", "")); } else if (Regex.IsMatch(RawInfo, "~price [0-9.]+/[0-9.]+")) { price.Cost = Convert.ToDouble(Regex.Replace(RawInfo, @"([\w\s\W\n]+Note: ~price )|(/+[\w\s\W]*)|([^0-9.])", "")); price.ForNumberItems = Convert.ToInt32(Regex.Replace(RawInfo, @"([\w\s\W]+/)|([^0-9.])", "")); price.CurrencyType = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", "")); } else if (Regex.IsMatch(RawInfo, @"~price +[0-9.]+\s\D*")) { price.Cost = Convert.ToDouble(Regex.Replace(RawInfo, @"[\w\W]*~price |[^0-9.]*", "").Replace('.', ',')); price.ForNumberItems = GetStackSize(); price.CurrencyType = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", "")); } if (!price.IsSet) { return(new Price()); } else { return(price); } }
private string GetNameItem() { if (RawInfo.Contains("Rarity: Currency")) { var lines = RawInfo.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); return(lines[2]); } if (RawInfo.Contains("Map Tier:")) { if (RawInfo.Contains("Rarity: Rare")) { var match = Regex.Match(RawInfo, @"Rarity: Rare\s([\w ']*)\s([\w ']*)"); if (!string.IsNullOrEmpty(match.Groups[2].Value)) { return(match.Groups[2].Value.Replace(" Map", "")); } else { return(match.Groups[1].Value.Replace(" Map", "")); } } if (RawInfo.Contains("Rarity: Normal")) { return(Regex.Match(RawInfo, @"Rarity: Normal\s([\w ']*)").Groups[1].Value.Replace(" Map", "")); } if (RawInfo.Contains("Rarity: Unique")) { var match = Regex.Match(RawInfo, @"Rarity: Unique\s([\w ']*)\s([\w ']*)"); if (!string.IsNullOrEmpty(match.Groups[2].Value)) { return($"{match.Groups[1].Value} {match.Groups[2].Value}".Replace(" Map", "")); } else { return("Undefined item"); } } } if (RawInfo.Contains("Rarity: Divination Card")) { return(Regex.Match(RawInfo, @"Rarity: Divination Card\s([\w ']*)").Groups[1].Value); } //I think that it for predicate fragments if (!RawInfo.Contains("Requirements:")) { if (RawInfo.Contains("Rarity: Normal")) { return(Regex.Match(RawInfo, @"Rarity: Normal\s([\w ']*)").Groups[1].Value); } } // Get Generic Name string[] infoParts = RawInfo.Split(new[] { "\n", "\r", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string itemName = string.Empty; foreach (string line in infoParts) { if (line.Contains(":")) { continue; } if (line.Contains("--------")) { break; } itemName = $"{itemName} {line}"; } return(itemName.Trim()); }