/// <summary> /// Returns a summarized set of Faces /// </summary> /// <param name="firstSet"></param> /// <returns></returns> public FaceMap Merge(FaceMap firstSet) { Dictionary <Face, byte> merged = new Dictionary <Face, byte>(); var keys = firstSet.faces.Keys.Union(faces.Keys); foreach (Face key in keys) { if (firstSet.faces.ContainsKey(key)) { if (faces.ContainsKey(key)) { merged.Add(key, (byte)(firstSet.faces[key] + faces[key])); } else { merged.Add(key, firstSet.faces[key]); } } else { merged.Add(key, faces[key]); } } return(new FaceMap(merged)); }
/// <summary> /// /// </summary> /// <param name="pool"></param> /// <returns></returns> public static FaceMap CountPool(List <Die> pool) { //escape for new lists if (pool.Count == 0) { return(new FaceMap(new Dictionary <Face, byte>())); } FaceMap nextPool = new FaceMap(new Dictionary <Face, byte>()); foreach (Die dieFaces in pool) { foreach (FaceMap face in dieFaces.faceMaps) { nextPool = face.Merge(nextPool); } } return(nextPool); }