private void CheckShip(IGameLogger logger, int accountId, VaultView vault, Ship ship) { // check ship if (!vault.Ships.Contains(ship.ID)) { throw logger.LogError(new Exception($"Check for player {accountId} on hangar with ship {ship.ID} resulted in a assigned ship which is not even owned!")); } // check amount of items packed into the ship if (Weapons.Count > ship.WeaponSlots) { Weapons = Weapons.Take(ship.WeaponSlots).ToList(); } if (Generators.Count + Shields.Count > ship.GeneratorSlots) { int diff = Math.Abs((Generators.Count + Shields.Count) - ship.GeneratorSlots); int generatorsToRemove = Math.Min(diff, Generators.Count); int shieldsToRemove = Math.Min(diff - generatorsToRemove, Shields.Count); Generators = Generators.Take(Generators.Count - generatorsToRemove).ToList(); Shields = Shields.Take(Shields.Count - shieldsToRemove).ToList(); if (diff != 0) { logger.LogWarning($"Check for player {accountId} on hangar with ship {ship.ID} resulted with a problematic difference of {diff}"); } } }