public RouteMVVM(Route route) { this.Route = route; this.FillingDegree = this.Route.FillingDegree; this.Balance = this.Route.Balance; this.Distance = MathHelpers.GetDistance(this.Route.Destination1, this.Route.Destination2); if (route.Type == Route.RouteType.Passenger) { RouteAirlinerClass raClass = ((PassengerRoute)route).getRouteAirlinerClass(AirlinerClass.ClassType.Economy_Class); this.Total = route.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers")); this.Average = route.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers%")); } if (route.Type == Route.RouteType.Cargo) { this.Total = route.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo")); this.Average = route.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo%")); } if (this.Average < 0) { this.Average = 0; } }
public override double getFillingDegree() { if (this.HasStopovers) { double fillingDegree = 0; var legs = this.Stopovers.SelectMany(s => s.Legs); foreach (CargoRoute leg in legs) { fillingDegree += leg.getFillingDegree(); } return(fillingDegree / legs.Count()); } else { double cargo = Convert.ToDouble(this.Statistics.getTotalValue(StatisticsTypes.GetStatisticsType("Cargo"))); double cargoCapacity = Convert.ToDouble(this.Statistics.getTotalValue(StatisticsTypes.GetStatisticsType("Capacity"))); if (cargo > cargoCapacity) { return(1); } return(cargo / cargoCapacity); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Airport airport = (Airport)value; StatisticsType statType = StatisticsTypes.GetStatisticsType("Passengers"); return(airport.Statistics.getTotalValue(GameObject.GetInstance().GameTime.Year, statType)); }
public Statistics(double value, double valueIncreasePerLevel, StatisticsTypes type, bool isPercentageValue) { Value = value; PerLevelChange = valueIncreasePerLevel; Type = type; IsPercentage = isPercentageValue; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Route route = (Route)value; List <KeyValuePair <string, object> > stats = new List <KeyValuePair <string, object> >(); if (route.Type == Route.RouteType.Passenger) { RouteAirlinerClass raClass = ((PassengerRoute)route).getRouteAirlinerClass(AirlinerClass.ClassType.Economy_Class); double passengers = route.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers")); double avgPassengers = route.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers%")); stats.Add(new KeyValuePair <string, object>("Total Passengers", passengers)); stats.Add(new KeyValuePair <string, object>("Average Passengers", Math.Max(0, avgPassengers))); } if (route.Type == Route.RouteType.Cargo) { double cargo = route.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo")); double avgCargo = route.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo%")); stats.Add(new KeyValuePair <string, object>("Total Cargo", cargo)); stats.Add(new KeyValuePair <string, object>("Average Cargo", Math.Max(0, avgCargo))); } stats.Add(new KeyValuePair <string, object>("Filling Degree", string.Format("{0:0.##} %", route.FillingDegree * 100))); return(stats); }
//shows the stats private void showStats() { panelStats.Children.Clear(); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Arrivals"))); // panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Departures"))); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Passengers"))); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Passengers%"))); }
public RouteIncomePerPaxMVVM(Route route) { StatisticsType stat = StatisticsTypes.GetStatisticsType("Passengers"); this.Route = route; double pax = this.Route.Statistics.getStatisticsValue(stat); this.IncomePerPax = this.Route.Balance / pax; }
//returns dictionary of all airline average on-time % public static Dictionary <Airline, Double> GetTotalOnTime() { Dictionary <Airline, Double> totalOnTime = new Dictionary <Airline, Double>(); foreach (Airline airline in Airlines.GetAllAirlines()) { double otp = airline.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("On-Time%")); totalOnTime.Add(airline, otp); } return(totalOnTime); }
//calculates AI airline average on-time % public static Dictionary <Airline, Double> GetAIonTime() { Dictionary <Airline, Double> aiOnTime = new Dictionary <Airline, double>(); foreach (Airline airline in Airlines.GetAirlines(a => !a.IsHuman)) { double otp = airline.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("On-Time%")); aiOnTime.Add(airline, otp); } return(aiOnTime); }
//creates the stats panel private void createStats() { lbToUpdate = new List <ListBox>(); panelStats.Children.Clear(); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Departures"), false)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Passengers"), false)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Passengers%"), false)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("On-Time%"), true)); }
//gets the income per passenger private double getIncomePerPassenger() { double totalPassengers = Convert.ToDouble(getStatisticsValue(StatisticsTypes.GetStatisticsType("Passengers"))); if (totalPassengers == 0) { return(0); } else { return(getBalance() / totalPassengers); } }
public PageAirportsStatistics() { this.AllAirports = new List <Airport>(); StatisticsType statType = StatisticsTypes.GetStatisticsType("Passengers"); var airports = Airports.GetAllActiveAirports().OrderByDescending(a => a.Statistics.getTotalValue(GameObject.GetInstance().GameTime.Year, statType)); foreach (Airport airport in airports.Take(20)) { this.AllAirports.Add(airport); } InitializeComponent(); }
//sets the values private void setValues() { StatisticsType stat = StatisticsTypes.GetStatisticsType("Passengers"); foreach (Route route in this.Members.SelectMany(m => m.Member.Airline.Routes)) { this.AllianceRoutes.Add(new AllianceRouteMMVM(route.Airline, route)); } this.Routes = this.Members.Sum(m => m.Member.Airline.Routes.Count); this.Destinations = this.Members.SelectMany(m => m.Member.Airline.Airports).Distinct().Count(); this.ServingCountries = this.Members.SelectMany(m => m.Member.Airline.Airports.Select(a => a.Profile.Country)).Distinct().Count(); this.FleetSize = this.Members.Sum(m => m.Member.Airline.Fleet.Count); this.Passengers = this.Members.Sum(m => (int)m.Member.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, stat)); }
//shows the list of the largest airport private void showAirports() { StatisticsType statType = StatisticsTypes.GetStatisticsType("Passengers"); lbAirports.Items.Clear(); List <Airport> airports = Airports.GetAllActiveAirports(); airports.Sort(delegate(Airport a1, Airport a2) { return(a2.Statistics.getTotalValue(GameObject.GetInstance().GameTime.Year, statType).CompareTo(a1.Statistics.getTotalValue(GameObject.GetInstance().GameTime.Year, statType))); }); foreach (Airport airport in airports.GetRange(0, 20)) { lbAirports.Items.Add(new AirportTotalItem(airport, airport.Statistics.getTotalValue(GameObject.GetInstance().GameTime.Year, statType))); } }
public ItemTemplate AddBaseAttribute(StatisticsTypes type, double Value, double perLevelChange) { var statFactory = new StatisticsFactory(); if (BaseAttributes == null) { BaseAttributes = new List <Statistics>(); } if (!BaseAttributes.ContainsType(type)) { BaseAttributes.Add(statFactory.CreateStatFlat(Value, perLevelChange, type)); } return(this); }
//get the degree of filling private double getFillingDegree() { double avgPassengers = getStatisticsValue(StatisticsTypes.GetStatisticsType("Passengers")) / getStatisticsValue(StatisticsTypes.GetStatisticsType("Arrivals")); double totalPassengers = Convert.ToDouble(this.Airliner.Airliner.getTotalSeatCapacity()); double fillingDegree = avgPassengers / totalPassengers; if (totalPassengers == 0) { return(0); } else { return(avgPassengers / totalPassengers); } }
//creates the panel for the statistics for a leg private StackPanel createLegStatistics(Route leg) { StackPanel panelLegStatistics = new StackPanel(); panelLegStatistics.Margin = new Thickness(0, 5, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = string.Format("{0}-{1}", new AirportCodeConverter().Convert(leg.Destination1), new AirportCodeConverter().Convert(leg.Destination2)); panelLegStatistics.Children.Add(txtHeader); ListBox lbLegStatistics = new ListBox(); lbLegStatistics.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbLegStatistics.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelLegStatistics.Children.Add(lbLegStatistics); if (leg.Type == Route.RouteType.Mixed || leg.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Passenger) { RouteAirlinerClass raClass = ((PassengerRoute)leg).getRouteAirlinerClass(AirlinerClass.ClassType.Economy_Class); double passengers = leg.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers")); double avgPassengers = leg.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers%")); lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1009"), UICreator.CreateTextBlock(String.Format("{0:0,0}", passengers)))); lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1010"), UICreator.CreateTextBlock(string.Format("{0:0.##}", avgPassengers)))); } if (leg.Type == Route.RouteType.Mixed || leg.Type == Route.RouteType.Cargo) { double cargo = leg.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo")); double avgCargo = leg.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo%")); lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1013"), UICreator.CreateTextBlock(String.Format("{0:0,0}", cargo)))); lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1014"), UICreator.CreateTextBlock(string.Format("{0:0.##}", avgCargo)))); } lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1011"), UICreator.CreateTextBlock(string.Format("{0:0.##} %", leg.FillingDegree * 100)))); lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1012"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(leg.Balance).ToString()))); return(panelLegStatistics); }
public AirlinesMVVM(Airline airline) { this.Airline = airline; this.Profit = this.Airline.getProfit(); this.AvgFleetAge = this.Airline.getAverageFleetAge(); StatisticsType passengersType = StatisticsTypes.GetStatisticsType("Passengers"); StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%"); StatisticsType arrivalsType = StatisticsTypes.GetStatisticsType("Arrivals"); StatisticsType cargoType = StatisticsTypes.GetStatisticsType("Cargo"); StatisticsType cargoAvgType = StatisticsTypes.GetStatisticsType("Cargo%"); this.Passengers = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, passengersType); this.PassengersPerFlight = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, passengersAvgType); this.Flights = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, arrivalsType); this.Cargo = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, cargoType); this.CargoPerFlight = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, cargoAvgType); }
//creates the stats panel private void createStats() { lbToUpdate = new List <ListBox>(); panelStats.Children.Clear(); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Arrivals"), false)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Passengers"), false)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Passengers%"), false)); Boolean hasCargoAirline = Airlines.GetAirlines(a => a.AirlineRouteFocus == Model.AirlinerModel.RouteModel.Route.RouteType.Cargo).Count > 0; if (hasCargoAirline) { panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Cargo"), false)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Cargo%"), false)); } panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("On-Time%"), true)); panelStats.Children.Add(createStatisticsPanel(StatisticsTypes.GetStatisticsType("Cancellation%"), true)); }
//get the degree of filling public override double getFillingDegree() { if (this.HasStopovers) { double fillingDegree = 0; var legs = this.Stopovers.SelectMany(s => s.Legs); foreach (PassengerRoute leg in legs) { fillingDegree += leg.getFillingDegree(); } return(fillingDegree / legs.Count()); } else { double passengers = Convert.ToDouble(this.Statistics.getTotalValue(StatisticsTypes.GetStatisticsType("Passengers"))); double passengerCapacity = Convert.ToDouble(this.Statistics.getTotalValue(StatisticsTypes.GetStatisticsType("Capacity"))); return(passengers / passengerCapacity); } }
public StatisticsTypes GetStatisticsType(VariableVM variable) { StatisticsTypes statisticsType = StatisticsTypes.Unknown; if (variable.IsResponseTypeDateTime) { statisticsType = StatisticsTypes.DateTime; } else if (variable.IsResponseTypeFree) { statisticsType = StatisticsTypes.Free; } else if (variable.IsResponseTypeNumber) { statisticsType = StatisticsTypes.Number; } else if (variable.IsResponseTypeChoices) { QuestionVM question = FindQuestion(variable.QuestionId); if (question != null && question.VariableGenerationInfo != null) { VariableGenerationInfo generationInfo = question.VariableGenerationInfo; if (generationInfo.VariableGenerationType == VariableGenerationType.MultipleVariable) { statisticsType = StatisticsTypes.ChoicesMultipleAnswer; } else if (generationInfo.VariableGenerationType == VariableGenerationType.SingleVariable) { statisticsType = StatisticsTypes.ChoicesSingleAnswer; } } else { statisticsType = StatisticsTypes.ChoicesSingleAnswer; } } return(statisticsType); }
public ItemTemplate AddBaseStat(StatisticsTypes type, double Value, double perLevelChange, bool isPercentage) { var statFactory = new StatisticsFactory(); if (BaseStats == null) { BaseStats = new List <Statistics>(); } if (!BaseStats.ContainsType(type)) { if (isPercentage) { BaseStats.Add(statFactory.CreateStatPercent(Value, perLevelChange, type)); } else { BaseStats.Add(statFactory.CreateStatFlat(Value, perLevelChange, type)); } } return(this); }
public static List <CodebookVariable> CreateCodebookVariables(StudyUnitVM studyUnit) { List <CodebookVariable> codebookVariables = new List <CodebookVariable>(); ObservableCollection <QuestionVM> questions = studyUnit.AllQuestions; foreach (VariableVM variable in studyUnit.Variables) { QuestionVM question = EDOUtils.Find <QuestionVM>(questions, variable.QuestionId); StatisticsInfo statisticsInfo = studyUnit.FindStatisticsInfoModel(variable); StatisticsTypes statisticsType = StatisticsTypes.Unknown; if (statisticsInfo == null) { statisticsType = studyUnit.GetStatisticsType(variable); } else { statisticsType = statisticsInfo.StatisticsType; statisticsInfo.ApplyScale(); } CodebookVariable codebookVariable = null; if (question != null && StatisticsInfo.IsTypeChoicesMultipleAnswerOf(statisticsType)) { codebookVariable = CodebookVariable.FindByQuestionId(codebookVariables, question.Id); } if (codebookVariable == null) { codebookVariable = new CodebookVariable(); codebookVariables.Add(codebookVariable); } codebookVariable.Variables.Add(variable); codebookVariable.Question = question; codebookVariable.StatisticsInfo = statisticsInfo; codebookVariable.StatisticsType = statisticsType; } return(codebookVariables); }
public AirlinesMVVM(Airline airline) { this.Airline = airline; this.Profit = this.Airline.getProfit(); this.AvgFleetAge = this.Airline.getAverageFleetAge(); StatisticsType passengersType = StatisticsTypes.GetStatisticsType("Passengers"); StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%"); StatisticsType arrivalsType = StatisticsTypes.GetStatisticsType("Arrivals"); StatisticsType cargoType = StatisticsTypes.GetStatisticsType("Cargo"); StatisticsType cargoAvgType = StatisticsTypes.GetStatisticsType("Cargo%"); this.Passengers = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, passengersType); this.PassengersPerFlight = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, passengersAvgType); this.Flights = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, arrivalsType); this.Cargo = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, cargoType); this.CargoPerFlight = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, cargoAvgType); this.Stocks = this.Airline.Shares.Count; this.StocksForSale = this.Airline.Shares.Count(s => s.Airline == null); this.StockPrice = AirlineHelpers.GetPricePerAirlineShare(this.Airline); setOwnershipValues(); }
public double GetStatValue(StatisticsTypes type) { return(BaseItem.GetStatScaledValue(type, Level)); }
//shows the stats private void showStats() { lbStats.Items.Clear(); lbStats.Items.Add(new KeyValuePair <Airline, StatisticsType>(this.Airline, StatisticsTypes.GetStatisticsType("Passengers"))); lbStats.Items.Add(new KeyValuePair <Airline, StatisticsType>(this.Airline, StatisticsTypes.GetStatisticsType("Passengers%"))); lbStats.Items.Add(new KeyValuePair <Airline, StatisticsType>(this.Airline, StatisticsTypes.GetStatisticsType("Arrivals"))); }
//gets the income per passenger private double getIncomePerPassenger() { double totalPassengers = Convert.ToDouble(this.Statistics.getTotalValue(StatisticsTypes.GetStatisticsType("Passengers"))); return(base.Balance / totalPassengers); }
//shows the stats private void showStats() { lbStats.Items.Clear(); lbStats.Items.Add(new KeyValuePair <FleetAirliner, StatisticsType>(this.Airliner, StatisticsTypes.GetStatisticsType("Arrivals"))); if (this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger || this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Mixed) { lbStats.Items.Add(new KeyValuePair <FleetAirliner, StatisticsType>(this.Airliner, StatisticsTypes.GetStatisticsType("Passengers"))); lbStats.Items.Add(new KeyValuePair <FleetAirliner, StatisticsType>(this.Airliner, StatisticsTypes.GetStatisticsType("Passengers%"))); //lbStats.Items.Add(new KeyValuePair<FleetAirliner, StatisticsType>(this.Airliner, StatisticsTypes.GetStatisticsType("Departures"))); } if (this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Mixed || this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Cargo) { lbStats.Items.Add(new KeyValuePair <FleetAirliner, StatisticsType>(this.Airliner, StatisticsTypes.GetStatisticsType("Cargo"))); lbStats.Items.Add(new KeyValuePair <FleetAirliner, StatisticsType>(this.Airliner, StatisticsTypes.GetStatisticsType("Cargo%"))); } }
//gets the balance private double getBalance() { return(getStatisticsValue(StatisticsTypes.GetStatisticsType("Airliner_Income"))); }
//calculates human airline average on-time % for given year public static double GetHumanOnTimeYear(int year) { return(GameObject.GetInstance().HumanAirline.Statistics.getStatisticsValue(year, StatisticsTypes.GetStatisticsType("On-Time%"))); }