Exemple #1
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)");
                    }
                }
            }
        }