Esempio n. 1
0
 public DateTime?GetStartTime()
 {
     return(Drones.SelectMany(
                drone => drone.GetValidInstructions()
                ).OrderBy(
                i => i.EndAt
                ).Select(
                i => i.EndAt
                ).FirstOrDefault());
 }
Esempio n. 2
0
 private IEnumerable <Unload> GetAllUnloadInstruction()
 {
     return(Drones.SelectMany(
                drone => drone.GetValidInstructions()
                .Where(
                    i => i.GetType() == typeof(Unload)
                    ).Select(
                    i => (i as Unload)
                    )
                ).OrderBy(
                u => u.EndAt
                ));
 }
Esempio n. 3
0
 public IEnumerable <ResourceQuantity> GetStoredResourcesAt(DateTime time)
 {
     return(Drones.SelectMany(
                drone => drone.GetValidInstructions()
                .Where(
                    i => i.IsFinishedAt(time) && i.GetType() == typeof(Unload)
                    ).Select(
                    i => (i as Unload).Resource
                    )
                ).GroupBy(
                rq => rq.Resource
                ).Select(
                rqGroup => new ResourceQuantity()
     {
         Resource = rqGroup.Key,
         Quantity = rqGroup.Sum(
             rq => rq.Quantity
             )
     }
                ));
 }
Esempio n. 4
0
        private void CheckAvailableShields(IGameLogger logger, int accountId, VaultView vault, Ship ship)
        {
            if (Shields == null)
            {
                Shields = new List <int>();
            }

            var tempShieldsGroup = Shields.Union(Drones.SelectMany(x => x.ShieldItems)).GroupBy(x => x).ToList();

            foreach (var grouping in tempShieldsGroup)
            {
                if (!vault.Shields.ContainsKey(grouping.Key))
                {
                    logger.LogWarning($"Check for player {accountId} on hangar with ship {ship.ID} resulted with equipped shields id:{grouping.Key} which are not owned!");
                    Shields.RemoveAll(x => x == grouping.Key);
                }
                else if (grouping.Count() > vault.Shields[grouping.Key])
                {
                    int diff = grouping.Count() - vault.Shields[grouping.Key];

                    Shields.RemoveAll(x => x == grouping.Key && diff-- > 0);
                    foreach (var drone in Drones)
                    {
                        if (diff <= 0)
                        {
                            break;
                        }

                        drone.ShieldItems.RemoveAll(x => x == grouping.Key && diff-- > 0);
                    }

                    if (diff != 0)
                    {
                        logger.LogWarning($"Check for player {accountId} on hangar with ship {ship.ID} resulted with a problematic difference of {diff} (shield check)");
                    }
                }
            }
        }