示例#1
0
 //adds a subsidiary airline to the airline
 //removes a code share agreement from the airline
 public void RemoveCodeshareAgreement(CodeshareAgreement share)
 {
     Codeshares.Remove(share);
 }
        private void hlCodeSharing_Click(object sender, RoutedEventArgs e)
        {
            var o = PopUpCodeshareAgreement.ShowPopUp(Airline.Airline);

            if (o != null)
            {
                var type = (CodeshareAgreement.CodeshareType) o;
                var accepted = AirlineHelpers.AcceptCodesharing(
                    Airline.Airline,
                    GameObject.GetInstance().HumanAirline,
                    type);

                if (accepted)
                {
                    HasCodesharing = true;
                    ShowActionMenu = !Airline.Airline.IsHuman
                                     && (CanHaveAlliance || !HasCodesharing);

                    var agreement = new CodeshareAgreement(
                        Airline.Airline,
                        GameObject.GetInstance().HumanAirline,
                        type);

                    Airline.addCodeshareAgreement(agreement);
                    GameObject.GetInstance().HumanAirline.AddCodeshareAgreement(agreement);
                }
                else
                {
                    WPFMessageBox.Show(
                        Translator.GetInstance().GetString("MessageBox", "2408"),
                        string.Format(
                            Translator.GetInstance().GetString("MessageBox", "2408", "message"),
                            Airline.Airline.Profile.Name),
                        WPFMessageBoxButtons.Ok);
                }
            }
        }
示例#3
0
 public void AddCodeshareAgreement(CodeshareAgreement share)
 {
     Codeshares.Add(share);
 }
        public void addCodeshareAgreement(CodeshareAgreement share)
        {
            Codeshares.Add(share.Airline1 == Airline ? share.Airline2 : share.Airline1);
            Airline.AddCodeshareAgreement(share);

            HasAlliance = Alliance != null || Codeshares.Count > 0;
        }
        //returns if an airline wants to have code sharing with another airline
        public static bool AcceptCodesharing(Airline airline, Airline asker, CodeshareAgreement.CodeshareType type)
        {
            double coeff = type == CodeshareAgreement.CodeshareType.OneWay ? 0.25 : 0.40;

            IEnumerable<Country> sameCountries = asker.Airports.Select(a => a.Profile.Country).Distinct().Intersect(airline.Airports.Select(a => a.Profile.Country).Distinct());
            IEnumerable<Airport> sameDestinations = asker.Airports.Distinct().Intersect(airline.Airports);
            IEnumerable<Country> sameCodesharingCountries =
                airline.GetCodesharingAirlines().SelectMany(a => a.Airports).Select(a => a.Profile.Country).Distinct().Intersect(airline.Airports.Select(a => a.Profile.Country).Distinct());

            double airlineDestinations = airline.Airports.Count;
            double airlineRoutes = airline.Routes.Count;
            double airlineCountries = airline.Airports.Select(a => a.Profile.Country).Distinct().Count();
            double airlineCodesharings = airline.Codeshares.Count;
            double airlineAlliances = airline.Alliances.Count;

            //declines if asker is much smaller than the invited airline
            if (airlineRoutes > 3*asker.Routes.Count)
                return false;

            //declines if there is a match for x% of the airlines
            if (sameDestinations.Count() >= airlineDestinations*coeff)
                return false;

            //declines if there is a match for 75% of the airlines
            if (sameCountries.Count() >= airlineCountries*0.75)
                return false;

            //declines if the airline already has a code sharing or alliance in that area
            if (sameCodesharingCountries.Count() >= airlineCountries*coeff)
                return false;

            return true;
        }
 //returns the pay for a codesharing agreement - one wayed
 public static double GetCodesharingPrice(CodeshareAgreement agreement)
 {
     return GetCodesharingPrice(agreement.Airline1, agreement.Airline2);
 }
 public CodeshareAgreementMVVM(CodeshareAgreement agreement)
 {
     Agreement = agreement;
 }