Exemplo n.º 1
0
        public void RemoveAllNormal(DateTime currentTime)
        {
            var copy = FoodItemsGatheringInfo.ToList();

            foreach (var x in copy)
            {
                if (x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled))
                {
                    FoodItemsGatheringInfo.Remove(x);
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public void AddGatheringInfo(DateTime time, int count)
 {
     FoodItemsGatheringInfo.Add(new Tuple <DateTime, int>(time, count));
 }
Exemplo n.º 5
0
 public int GetCountNormal(DateTime currentTime)
 {
     return(FoodItemsGatheringInfo.Where(x => x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled)).Sum(x => x.Item2));
 }