Fixed 2 bugs relating to duplicate ItemRarity block items and spaces at the end of ItemRarity block items

This commit is contained in:
Ben Wallis
2016-08-30 18:39:08 +01:00
parent ce4366d3fd
commit 6eb17555c0
3 changed files with 102 additions and 95 deletions

View File

@@ -56,7 +56,7 @@ namespace Filtration.Parser.Services
}
var adjustedLine = line.Replace("#", " # ");
var trimmedLine = adjustedLine.TrimStart(' ');
var trimmedLine = adjustedLine.TrimStart(' ').TrimEnd(' ');
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
@@ -104,6 +104,8 @@ namespace Filtration.Parser.Services
}
case "Rarity":
{
RemoveExistingBlockItemsOfType<RarityBlockItem>(block);
var blockItemValue = new RarityBlockItem();
var result = Regex.Match(trimmedLine, @"^\w+\s+([><!=]{0,2})\s*(\w+)$");
if (result.Groups.Count == 3)
@@ -113,6 +115,7 @@ namespace Filtration.Parser.Services
blockItemValue.FilterPredicate.PredicateOperand =
(int)EnumHelper.GetEnumValueFromDescription<ItemRarity>(result.Groups[2].Value);
}
block.BlockItems.Add(blockItemValue);
break;
}