void TrySetMatch(GrowthMatch match, BuildingStruct growth) { if (matList == null) { matList = new Dictionary <BuildingStruct, GrowthMatch>(); } if (matList.ContainsKey(growth)) { if (matList[growth].difference < match.difference) //overwrite existing exact matches { return; //the comparitor can be changed to <= if that behavior is not desired. } } matList[growth] = match; }
void Setwords(string plant, string growth, string color, GrowthMatch match) { if (plant == "*") { match.difference |= 1; foreach (var item in PlantTokenList.GrowthIDs.Values) { Setwords(growth, color, item, match); } } else { if (PlantTokenList.GrowthIDs.ContainsKey(plant)) { Setwords(growth, color, PlantTokenList.GrowthIDs[plant], match); } } }
void Setwords(string word, Dictionary <string, BuildingStruct> wordList, GrowthMatch match) { if (word == "*") { match.difference |= 4; foreach (BuildingStruct item in wordList.Values) { TrySetMatch(match, item); } } else { if (wordList.ContainsKey(word)) { TrySetMatch(match, wordList[word]); } } }
void Setwords(string word, string suffix, Dictionary <string, Dictionary <string, BuildingStruct> > wordList, GrowthMatch match) { if (word == "*") { match.difference |= 2; foreach (var item in wordList.Values) { Setwords(suffix, item, match); } } else { if (wordList.ContainsKey(word)) { Setwords(suffix, wordList[word], match); } } }