Changeset - a93007642265
[Not reviewed]
default
0 1 0
Jason Maltzen - 3 years ago 2021-09-09 23:59:27
jason@hiddenachievement.com
Add a utility on a paint recipe to find the list of missing reaction pairs for that recipe
1 file changed with 36 insertions and 0 deletions:
0 comments (0 inline, 0 general)
Models/PaintRecipe.cs
Show inline comments
...
 
@@ -361,4 +361,40 @@ namespace DesertPaintCodex.Models
 
            return false;
 
        }
 

	
 
        public List<(string, string)> MissingReactionPairs()
 
        {
 
            ReactionSet? reactions = ProfileManager.CurrentProfile?.Reactions;
 
            Debug.Assert(reactions != null);
 

	
 
            HashSet<string> reagentSet = new();
 
            List<Reagent> prevReagents = new();
 

	
 
            List<(string, string)> missingReactionPairs = new List<(string, string)>(16);
 

	
 
            foreach (ReagentQuantity ingredient in _recipe)
 
            {
 
                if (reagentSet.Count > 4) return missingReactionPairs; // no more reactions
 

	
 
                string reagentName = ingredient.Name;
 
                if (string.IsNullOrEmpty(reagentName)) continue;
 
                if (reagentSet.Contains(reagentName)) continue;
 
                reagentSet.Add(reagentName);
 

	
 
                Reagent reagent = ReagentService.GetReagent(reagentName);
 

	
 
                // Find reactions.
 
                foreach (Reagent prevReagent in prevReagents)
 
                {
 
                    Reaction? reaction = reactions.Find(prevReagent, reagent);
 
                    if (reaction == null)
 
                    {
 
                        missingReactionPairs.Add((prevReagent.Name, reagentName));
 
    }
 
}
 
                prevReagents.Add(reagent);
 
            }
 

	
 
            return missingReactionPairs;
 
        }
 
    }
 
}
0 comments (0 inline, 0 general)