예제 #1
0
        //calculates employee happiness as a function of wages, discounts, and free pilots (relative to workload)
        public static double GetEmployeeHappiness(Airline airline)
        {
            Dictionary <Airline, Double>  wages            = StatisticsHelpers.GetEmployeeWages();
            Dictionary <Airline, Double>  discounts        = StatisticsHelpers.GetEmployeeDiscounts();
            Dictionary <Airline, Double>  unassignedPilots = StatisticsHelpers.GetUnassignedPilots();
            IDictionary <Airline, Double> scaleWages       = StatisticsHelpers.GetRatingScale(wages);
            IDictionary <Airline, Double> scaleDiscounts   = StatisticsHelpers.GetRatingScale(discounts);
            IDictionary <Airline, Double> scaleUPilots     = StatisticsHelpers.GetRatingScale(unassignedPilots);

            double airlineWages            = scaleWages[airline];
            double airlineDiscounts        = scaleDiscounts[airline];
            double airlineUnassignedPilots = scaleUPilots[airline];

            return((airlineWages * 0.7) + (airlineUnassignedPilots * 0.2) + (airlineDiscounts * 0.1));
        }
예제 #2
0
        //calculates customer happiness as a function of average ticket price, crowding on flights, and on-time % - for an airline
        public static double GetCustomerHappiness(Airline airline)
        {
            int negInt = -1;
            Dictionary <Airline, Double>  fillAverages  = StatisticsHelpers.GetFillAverages();
            Dictionary <Airline, Double>  onTimePercent = StatisticsHelpers.GetTotalOnTime();
            Dictionary <Airline, Double>  ticketPPD     = StatisticsHelpers.GetTotalPPD();
            IDictionary <Airline, Double> scaleAvgFill  = StatisticsHelpers.GetRatingScale(fillAverages);
            IDictionary <Airline, Double> scaleOnTimeP  = StatisticsHelpers.GetRatingScale(onTimePercent);
            IDictionary <Airline, Double> scalePPD      = StatisticsHelpers.GetRatingScale(ticketPPD);
            IDictionary <Airline, Double> scaleLuxury   = StatisticsHelpers.GetRatingScale(GetAirlinesLuxuryLevels());

            double airlineAvgFill = scaleAvgFill[airline];
            double airlineOTP     = scaleOnTimeP[airline];
            double airlinePPD     = scalePPD[airline];
            double airlineLuxury  = scaleLuxury[airline];

            return(((airlinePPD * negInt + 100) * 0.4) + (airlineAvgFill * 0.2) + (airlineOTP * 0.2) + (airlineLuxury * 0.2));
        }
예제 #3
0
        //creates the panel for the human statistics
        private StackPanel createHumanStatisticsPanel()
        {
            StackPanel panelHumanStatistics = new StackPanel();

            panelHumanStatistics.Margin = new Thickness(0, 10, 0, 0);

            TextBlock txtHeader = new TextBlock();

            txtHeader.Uid    = "1005";
            txtHeader.Margin = new Thickness(0, 0, 0, 0);
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = Translator.GetInstance().GetString("PageAirlineStatistics", txtHeader.Uid);

            panelHumanStatistics.Children.Add(txtHeader);

            ListBox lbHumanStats = new ListBox();

            lbHumanStats.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbHumanStats.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            panelHumanStatistics.Children.Add(lbHumanStats);

            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1006"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", StatisticsHelpers.GetHumanOnTime()))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1007"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", StatisticsHelpers.GetHumanFillAverage() * 100))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1008"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", Ratings.GetCustomerHappiness(GameObject.GetInstance().HumanAirline)))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1009"), UICreator.CreateTextBlock(string.Format("{0:0.00}", StatisticsHelpers.GetHumanAvgTicketPPD()))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1012"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", Ratings.GetEmployeeHappiness(GameObject.GetInstance().HumanAirline)))));
            return(panelHumanStatistics);
        }
예제 #4
0
        public PageAirlineRatings(AirlineMVVM airline)
        {
            this.AirlineRatings    = new ObservableCollection <AirlineScoreMVVM>();
            this.AirlineScores     = new ObservableCollection <AirlineScoreMVVM>();
            this.AirlineStatistics = new ObservableCollection <AirlineStatisticsMVVM>();
            this.Airline           = airline;
            this.DataContext       = this.Airline;

            InitializeComponent();

            this.AirlineRatings.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1007"), this.Airline.Airline.Ratings.SecurityRating));
            this.AirlineRatings.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1008"), this.Airline.Airline.Ratings.SafetyRating));
            this.AirlineRatings.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1009"), this.Airline.Airline.Ratings.EmployeeHappinessRating));
            this.AirlineRatings.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1010"), this.Airline.Airline.Ratings.CustomerHappinessRating));
            this.AirlineRatings.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1011"), this.Airline.Airline.Ratings.MaintenanceRating));

            this.AirlineScores.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1012"), this.Airline.Airline.OverallScore));
            // this.AirlineScores.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1013"), this.Airline.Airline.Reputation));<
            this.AirlineScores.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1014"), (int)StatisticsHelpers.GetOnTimePercent(this.Airline.Airline)));
            this.AirlineScores.Add(new AirlineScoreMVVM(Translator.GetInstance().GetString("PageAirlineRatings", "1015"), (int)(StatisticsHelpers.GetAirlineFillAverage(this.Airline.Airline) * 100)));

            this.AirlineStatistics.Add(new AirlineStatisticsMVVM(this.Airline.Airline, StatisticsTypes.GetStatisticsType("Passengers")));
            this.AirlineStatistics.Add(new AirlineStatisticsMVVM(this.Airline.Airline, StatisticsTypes.GetStatisticsType("Passengers%")));
            this.AirlineStatistics.Add(new AirlineStatisticsMVVM(this.Airline.Airline, StatisticsTypes.GetStatisticsType("Arrivals")));
        }
예제 #5
0
        public AirportMVVM(Airport airport)
        {
            this.Airport = airport;

            this.TerminalGatePrice = this.Airport.getTerminalGatePrice();
            this.TerminalPrice     = this.Airport.getTerminalPrice();

            this.Cooperations      = new ObservableCollection <Cooperation>();
            this.Terminals         = new ObservableCollection <AirportTerminalMVVM>();
            this.BuildingTerminals = new ObservableCollection <AirportTerminalMVVM>();

            foreach (Terminal terminal in this.Airport.Terminals.getTerminals())
            {
                Boolean isSellable = terminal.Airline != null && terminal.Airline == GameObject.GetInstance().HumanAirline;

                if (terminal.IsBuilt)
                {
                    this.Terminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
                else
                {
                    this.BuildingTerminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
            }
            this.Contracts = new ObservableCollection <ContractMVVM>();

            foreach (AirportContract contract in this.Airport.AirlineContracts)
            {
                this.Contracts.Add(new ContractMVVM(contract));
            }

            foreach (Cooperation cooperation in this.Airport.Cooperations)
            {
                this.Cooperations.Add(cooperation);
            }

            AirportHelpers.CreateAirportWeather(this.Airport);

            this.Weather = this.Airport.Weather.ToList();

            if (!GameObject.GetInstance().DayRoundEnabled)
            {
                this.CurrentWeather = this.Weather[0].Temperatures[GameObject.GetInstance().GameTime.Hour];
            }

            this.FreeGates = this.Airport.Terminals.NumberOfFreeGates;

            this.Demands = new List <DemandMVVM>();

            var demands = this.Airport.getDestinationDemands().Where(a => a != null && GeneralHelpers.IsAirportActive(a)).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class));

            var internationalDemand = demands.Where(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) != new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country));
            var domesticDemand      = demands.Where(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) == new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country));

            foreach (Airport destination in internationalDemand)
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.Profile.Pax, (int)this.Airport.getDestinationCargoRate(destination), DemandMVVM.DestinationType.International));
            }

            foreach (Airport destination in domesticDemand)
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.Profile.Pax, (int)this.Airport.getDestinationCargoRate(destination), DemandMVVM.DestinationType.Domestic));
            }

            this.AirportFacilities = this.Airport.getAirportFacilities().FindAll(f => f.Airline == null && f.Facility.TypeLevel != 0).Select(f => f.Facility).Distinct().ToList();

            this.AirlineFacilities         = new ObservableCollection <AirlineAirportFacilityMVVM>();
            this.BuildingAirlineFacilities = new ObservableCollection <AirlineAirportFacilityMVVM>();

            foreach (var facility in this.Airport.getAirportFacilities().FindAll(f => f.Airline != null))
            {
                if (facility.Facility.TypeLevel != 0)
                {
                    Alliance alliance = facility.Airline.Alliances.Count == 0 ? null : facility.Airline.Alliances[0];

                    AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(facility, alliance);

                    if (airlineFacility.IsDelivered)
                    {
                        if (facility == Airport.getAirlineAirportFacility(facility.Airline, facility.Facility.Type))
                        {
                            this.AirlineFacilities.Add(airlineFacility);
                        }
                    }
                    else
                    {
                        this.BuildingAirlineFacilities.Add(airlineFacility);
                    }
                }
            }

            this.AirlineStatistics = new List <AirportStatisticsMVMM>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                StatisticsType passengersType    = StatisticsTypes.GetStatisticsType("Passengers");
                StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%");
                StatisticsType arrivalsType      = StatisticsTypes.GetStatisticsType("Arrivals");

                double passengers    = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersType);
                double passengersAvg = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersAvgType);
                double arrivals      = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, arrivalsType);

                int routes = airline.Routes.Count(r => r.Destination1 == this.Airport || r.Destination2 == this.Airport);

                this.AirlineStatistics.Add(new AirportStatisticsMVMM(airline, passengers, passengersAvg, arrivals, routes));
            }

            this.Traffic = new List <AirportTrafficMVVM>();

            var passengerDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationPassengerStatistics(a) descending select a;

            var cargoDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationCargoStatistics(a) descending select a;

            foreach (Airport a in passengerDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, this.Airport.getDestinationPassengerStatistics(a), AirportTrafficMVVM.TrafficType.Passengers));
            }

            foreach (Airport a in cargoDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, Convert.ToInt64(this.Airport.getDestinationCargoStatistics(a)), AirportTrafficMVVM.TrafficType.Cargo));
            }

            this.Flights = new List <DestinationFlightsMVVM>();

            var airportRoutes = AirportHelpers.GetAirportRoutes(this.Airport).Where(r => r.getAirliners().Count > 0);

            foreach (Route airportRoute in airportRoutes)
            {
                double distance = MathHelpers.GetDistance(airportRoute.Destination1, airportRoute.Destination2);

                Airport destination = airportRoute.Destination1 == this.Airport ? airportRoute.Destination2 : airportRoute.Destination1;
                if (this.Flights.Exists(f => f.Airline == airportRoute.Airline && f.Airport == destination))
                {
                    DestinationFlightsMVVM flight = this.Flights.First(f => f.Airline == airportRoute.Airline && f.Airport == destination);

                    flight.Flights += airportRoute.TimeTable.getEntries(destination).Count;

                    foreach (AirlinerType aircraft in airportRoute.getAirliners().Select(a => a.Airliner.Type))
                    {
                        if (!flight.Aircrafts.Contains(aircraft))
                        {
                            flight.Aircrafts.Add(aircraft);
                        }
                    }
                }
                else
                {
                    this.Flights.Add(new DestinationFlightsMVVM(destination, airportRoute.Airline, distance, airportRoute.getAirliners().Select(a => a.Airliner.Type).ToList(), airportRoute.TimeTable.getEntries(destination).Count));
                }
            }

            /*
             * Dictionary<Airport, int> destinations = new Dictionary<Airport, int>();
             * foreach (Route route in AirportHelpers.GetAirportRoutes(this.Airport).FindAll(r => r.getAirliners().Count > 0))
             * {
             *  if (route.Destination1 != this.Airport)
             *  {
             *      if (!destinations.ContainsKey(route.Destination1))
             *          destinations.Add(route.Destination1, 0);
             *      destinations[route.Destination1] += route.TimeTable.getEntries(route.Destination1).Count;
             *
             *
             *  }
             *  if (route.Destination2 != this.Airport)
             *  {
             *      if (!destinations.ContainsKey(route.Destination2))
             *          destinations.Add(route.Destination2, 0);
             *      destinations[route.Destination2] += route.TimeTable.getEntries(route.Destination2).Count;
             *  }
             * }
             *
             * foreach (Airport a in destinations.Keys)
             *  this.Flights.Add(new DestinationFlightsMVVM(a, destinations[a]));
             */

            this.Hubs = new ObservableCollection <Hub>();

            foreach (Hub hub in this.Airport.getHubs())
            {
                this.Hubs.Add(hub);
            }

            this.CanBuildHub        = canBuildHub();
            this.CanMakeCooperation = GameObject.GetInstance().HumanAirline.Airports.Exists(a => a == this.Airport);

            this.LocalTime = MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, this.Airport.Profile.TimeZone);

            this.ShowLocalTime = !GameObject.GetInstance().DayRoundEnabled;

            this.AirlineReputations = new List <AirlineReputationMVVM>();

            IDictionary <Airline, double> airlineScores = new Dictionary <Airline, double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                airlineScores.Add(airline, this.Airport.getAirlineReputation(airline));
            }

            foreach (KeyValuePair <Airline, double> score in StatisticsHelpers.GetRatingScale(airlineScores))
            {
                this.AirlineReputations.Add(new AirlineReputationMVVM(score.Key, (int)score.Value));
            }
        }