Esempio n. 1
0
        //hires the pilots for a specific airliner
        public static void HireAirlinerPilots(FleetAirliner airliner)
        {
            if (Pilots.GetNumberOfUnassignedPilots() < 10)
                GeneralHelpers.CreatePilots(50);

            while (airliner.Airliner.Type.CockpitCrew > airliner.NumberOfPilots)
            {
                var pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country == airliner.Airliner.Airline.Profile.Country && p.Aircrafts.Contains(airliner.Airliner.Type.AirlinerFamily));

                if (pilots.Count == 0)
                    pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country.Region == airliner.Airliner.Airline.Profile.Country.Region && p.Aircrafts.Contains(airliner.Airliner.Type.AirlinerFamily));

                if (pilots.Count == 0)
                    pilots = Pilots.GetUnassignedPilots(p=>p.Aircrafts.Contains(airliner.Airliner.Type.AirlinerFamily));

                if (pilots.Count == 0)
                {
                    GeneralHelpers.CreatePilots(4, airliner.Airliner.Type.AirlinerFamily);
                    HireAirlinerPilots(airliner);
                }

                Pilot pilot = pilots.OrderByDescending(p => p.Rating.CostIndex).FirstOrDefault();

                if (pilot != null)
                {
                    airliner.Airliner.Airline.addPilot(pilot);

                    pilot.Airliner = airliner;
                    airliner.addPilot(pilot);
                }
                else
                    GeneralHelpers.CreatePilots(50);
            }



        }
Esempio n. 2
0
        //hires the pilots for a specific airliner
        public static void HireAirlinerPilots(FleetAirliner airliner)
        {
            if (Pilots.GetNumberOfUnassignedPilots() < 10)
                GeneralHelpers.CreatePilots(50);

            while (airliner.Airliner.Type.CockpitCrew > airliner.NumberOfPilots)
            {
                var pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country == airliner.Airliner.Airline.Profile.Country);

                if (pilots.Count == 0)
                    pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country.Region == airliner.Airliner.Airline.Profile.Country.Region);

                if (pilots.Count == 0)
                    pilots = Pilots.GetUnassignedPilots();

                Pilot pilot = pilots.OrderByDescending(p => p.Rating).First();

                if (pilot != null)
                {
                    airliner.Airliner.Airline.addPilot(pilot);

                    pilot.Airliner = airliner;
                    airliner.addPilot(pilot);
                }
                else
                    GeneralHelpers.CreatePilots(50);
            }



        }