public void RemoveAllNormal(DateTime currentTime) { var copy = FoodItemsGatheringInfo.ToList(); foreach (var x in copy) { if (x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled)) { FoodItemsGatheringInfo.Remove(x); } } }
public int TakeOneFromNormalGroup(DateTime currentTime) { var normalItem = FoodItemsGatheringInfo.FirstOrDefault(x => x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled)); if (normalItem != null) { normalItem.Item2--; if (normalItem.Item2 <= 0) { FoodItemsGatheringInfo.Remove(normalItem); } return(GetCountNormal(currentTime)); } return(-1); }
public int TakeOneFromSpoiledGroup(DateTime currentTime) { var spoiledItem = FoodItemsGatheringInfo.FirstOrDefault(x => x.Item1 <= currentTime.AddMinutes(-MinutesUntilSpoiled)); if (spoiledItem != null) { spoiledItem.Item2--; if (spoiledItem.Item2 <= 0) { FoodItemsGatheringInfo.Remove(spoiledItem); } return(GetCountSpoiled(currentTime)); } return(-1); }