Skip to content

Commit

Permalink
#26 Find duplicate names for items and locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjöblom Tommy IT-enheten committed Dec 1, 2020
1 parent 589a665 commit 29bda88
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,35 @@ private static bool ValidateConfig(out string errorMessage)
var ret = true;
var sb = new StringBuilder();

List<string> dupNames;

// Items

dupNames = gameDefinition.items.GroupBy(t => t.name).Where(g => g.Count() > 1).Select(y => y.Key).ToList();
if (dupNames.Any())
{
sb.AppendLine("Duplicate found in item names:");
dupNames.ForEach(d => sb.AppendLine($" {d}"));
ret = false;
}

// Items

dupNames = gameDefinition.locations.GroupBy(t => t.name).Where(g => g.Count() > 1).Select(y => y.Key).ToList();
if (dupNames.Any())
{
sb.AppendLine("Duplicate found in location names:");
dupNames.ForEach(d => sb.AppendLine($" {d}"));
ret = false;
}


// Trigger actions

var dupNames = gameDefinition.triggerActions.GroupBy(t => t.name).Where(g => g.Count() > 1).Select(y => y.Key).ToList();
dupNames = gameDefinition.triggerActions.GroupBy(t => t.name).Where(g => g.Count() > 1).Select(y => y.Key).ToList();
if (dupNames.Any())
{
sb.AppendLine("Duplicate found i trigger action names:");
sb.AppendLine("Duplicate found i triggerAction names:");
dupNames.ForEach(d => sb.AppendLine($" {d}"));
ret = false;
}
Expand Down

0 comments on commit 29bda88

Please sign in to comment.