/// <summary> /// Applies the requested animal assignment data, cooking animals /// for food in the process /// </summary> /// <param name="player"></param> /// <param name="data"></param> public static void AssignAnimals(AgricolaPlayer player, AnimalCacheActionData data, List <GameActionNotice> resultingNotices) { player.AssignAnimals(data.Assignments); var cooking = false; foreach (var count in data.Cook.Values) { if (count > 0) { cooking = true; break; } } var freedAnimalsPredicates = new List <INoticePredicate>(); foreach (var animal in data.Free.Keys) { if (data.Free[animal] > 0) { freedAnimalsPredicates.Add(new ResourceCache((Resource)animal, data.Free[animal])); } } if (freedAnimalsPredicates.Count > 0) { resultingNotices.Add(new GameActionNotice(player.Name, NoticeVerb.FreeAnimals.ToString(), freedAnimalsPredicates)); } if (cooking) { var conversions = Curator.GetHarvestFoodValues(player); var cookedAnimalPredicates = new List <INoticePredicate>(); foreach (var animal in data.Cook.Keys) { if (data.Cook[animal] > 0) { var definition = conversions.Where(x => x.InType.ToString() == animal.ToString()).OrderByDescending(x => x.OutAmount).First(); var inputCache = new ResourceCache((Resource)animal, data.Cook[animal]); var outputCache = new ResourceCache(Resource.Food, definition.OutAmount * data.Cook[animal]); player.AddResource(outputCache); cookedAnimalPredicates.Add(new ConversionPredicate(inputCache, outputCache)); } } if (cookedAnimalPredicates.Count > 0) { resultingNotices.Add(new GameActionNotice(player.Name, NoticeVerb.Converted.ToString(), cookedAnimalPredicates)); } } }