internal void LoadAircraft(AircraftConfig ac) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); aircraftName.AddStat(new StringStat(ac.DisplayName)); nFlights.AddStat(new IntStat(Game.current.flightScheduler.Today.Count(x => ac.DisplayName.Equals(x.flightSchema.aircraftConfig.DisplayName)))); isMod.AddStat(new BoolStat(ac.isDefault)); paxCapacity.AddStat(new IntStat(ac.Capacity)); nFlightAttendants.AddStat(new IntStat(ac.nFlightAttendants)); nPilots.AddStat(new IntStat(ac.nPilots)); crewChangeModifier.AddStat(new PercentageStat(ac.CrewChangeChanceModifier)); fuelCapacity.AddStat(new IntStat(ac.FuelCapacity / 1000)); minRunwaySize.AddStat(new IntStat(ac.MinRunwaySize)); minGateSize.AddStat(new StringStat(ac.MinGateSize.ToString())); string airlineString = string.Empty; foreach (Airline airline in Game.current.airlines) { if (airline.AircraftInFleet.Contains(ac.isDefault ? ac.DisplayName : ac.ReferenceID)) { airlineString += airline.name + "<br/>"; } } airlinesUsing.AddStat(new StringStat(airlineString)); shortName.AddStat(new StringStat(ac.DisplayShortName)); }
private string[,] LoadArray(AircraftConfig ac) { string[,] arr = new string[arrayRows, 2]; for (int i = 0; i < arrayRows; i++) { arr[i, 0] = i18n.Get($"TBFlash.AirportStats.AircraftStats.stats{i}"); } arr[0, 1] = ac.DisplayName; arr[1, 1] = Game.current.flightScheduler.Today.Count(x => ac.DisplayName.Equals(x.flightSchema.aircraftConfig.DisplayName)).ToString("#"); arr[2, 1] = ac.isDefault ? i18n.Get("TBFlash.AirportStats.utils.no") : i18n.Get("TBFlash.AirportStats.utils.yes"); arr[3, 1] = ac.Capacity.ToString("#"); arr[4, 1] = ac.nFlightAttendants.ToString("#"); arr[5, 1] = ac.nPilots.ToString("#"); arr[6, 1] = ac.CrewChangeChanceModifier.ToString("P0"); arr[7, 1] = (ac.FuelCapacity / 1000).ToString("#,###"); arr[8, 1] = ac.MinRunwaySize.ToString("#,###"); arr[9, 1] = ac.MinGateSize.ToString(); string airlineString = string.Empty; foreach (Airline airline in Game.current.airlines) { if (airline.AircraftInFleet.Contains(ac.isDefault ? ac.DisplayName : ac.ReferenceID)) { airlineString += airline.name + "<br/>"; } } arr[10, 1] = airlineString; arr[11, 1] = ac.DisplayShortName; return(arr); }
static internal string GetAircraftStats(AircraftConfig aircraftConfig) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); string str = string.Empty; StatLoader.UpdateAircraftStats(aircraftConfig); str += $"<div class=\"modal\"><h1>{aircraftConfig.DisplayName}</h1><table>\n"; str += StatLoader.aircraftData.ForTable(); str += "</table></div>"; return(str); }
public void EditConfig(object sender, EventArgs e) { var reg = SelectedRegistration; if (reg != null) { currentConfig = profiles.AcConfigs.Find(reg); ShowPropertyGroupBox(); FillProperties(currentConfig.Config); } }
internal string GetAircraftStats(AircraftConfig aircraftConfig) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); string[,] arr = LoadArray(aircraftConfig); string htmlCode = $"<div class=\"modal\"><h1>{arr[0, 1]}</h1><table>"; for (int i = 1; i < arrayRows; i++) { htmlCode += "<tr>"; for (int j = 0; j < 2; j++) { htmlCode += $"<td>{arr[i, j]}</td>"; } htmlCode += "</tr>"; } htmlCode += "</table></div>"; return(htmlCode); }
public void CreateConfig(object sender, EventArgs e) { ShowPropertyGroupBox(); ShowDefaultConfig(); currentConfig = null; }
static private void LoadAirlineData(int start, int end) { AirportStatUtils.AirportStatsLogger(Log.FromPool($"start: {start}; end: {end}").WithCodepoint()); airportData.RemoveAirlineDataStats(start, end); Dictionary <AircraftGate.GateSize, int> gateSizes = new Dictionary <AircraftGate.GateSize, int> { { AircraftGate.GateSize.Small, 0 }, { AircraftGate.GateSize.Large, 0 }, { AircraftGate.GateSize.Extra_Large, 0 } }; foreach (Airline airline in AirlineManager.AllAirlines()) { AirlineDailyData thisAirline = airlineData.GetAirlineDailyData(airline.name); thisAirline.RemoveStats(start, end); for (int i = end; i >= start; i--) { IEnumerable <FlightRecord> flightRecords = Game.current.flightRecords.GetForDay(i).Where(x => x.airline == airline.name); if (flightRecords?.Any() != true) { continue; } // Load Flight Stats int nSchedFlights = flightRecords.Count(); int ontimeDepart = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) && !AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedDeparture)); int delDep = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedDeparture)); int canx = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Canceled)); thisAirline.flightStats.nSchedFlights.AddStat(i, new IntStat(nSchedFlights)); thisAirline.flightStats.nDelayedArrival.AddStat(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedArrival)))); thisAirline.flightStats.nRequiresCrew.AddStat(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.RequiresCrew)))); thisAirline.flightStats.nOntimeDeparture.AddStat(i, new IntStat(ontimeDepart)); thisAirline.flightStats.nDelayedDeparture.AddStat(i, new IntStat(delDep, delDep > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); thisAirline.flightStats.nCancelled.AddStat(i, new IntStat(canx, canx > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); thisAirline.flightStats.nAirportInvalid.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.AirportInvalid))); thisAirline.flightStats.nWeather.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Weather))); thisAirline.flightStats.nRunway.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Runway))); thisAirline.flightStats.nGate.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Gate))); thisAirline.flightStats.nExpired.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Expired))); thisAirline.flightStats.nReneged.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Reneged))); thisAirline.flightStats.ontimeDeparturePer.AddStat(i, new AverageStat(ontimeDepart, ontimeDepart + delDep + canx, typeof(PercentageStat))); airportData.flightStats.nSchedFlights.AddToValue(i, new IntStat(nSchedFlights)); airportData.flightStats.nDelayedArrival.AddToValue(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedArrival)))); airportData.flightStats.nRequiresCrew.AddToValue(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.RequiresCrew)))); airportData.flightStats.nOntimeDeparture.AddToValue(i, new IntStat(ontimeDepart)); airportData.flightStats.nDelayedDeparture.AddToValue(i, new IntStat(delDep, delDep > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); airportData.flightStats.nCancelled.AddToValue(i, new IntStat(canx, canx > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); airportData.flightStats.nAirportInvalid.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.AirportInvalid))); airportData.flightStats.nWeather.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Weather))); airportData.flightStats.nRunway.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Runway))); airportData.flightStats.nGate.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Gate))); airportData.flightStats.nExpired.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Expired))); airportData.flightStats.nReneged.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Reneged))); airportData.flightStats.ontimeDeparturePer.AddToValue(i, new AverageStat(ontimeDepart, ontimeDepart + delDep + canx, typeof(PercentageStat))); //Load Passenger Stats int arrivingPax = flightRecords.Sum(x => x.nArriving); int boardedPax = flightRecords.Sum(x => x.nBoarded); int schedDepartingPax = flightRecords.Sum(x => x.nDeparting); int missed = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) || AirportStatUtils.HasStatus(x.status, Flight.Status.Canceled) ? x.nDeparting - x.nBoarded : 0); double timeBoarding = flightRecords.Sum(x => x.nBoarded > 0 ? x.time_boarding : 0) * 60f; thisAirline.passengerStats.nArriving.AddStat(i, new IntStat(arrivingPax)); thisAirline.passengerStats.nBoarded.AddStat(i, new IntStat(boardedPax)); thisAirline.passengerStats.nCheckedIn.AddStat(i, new IntStat(flightRecords.Sum(x => x.nCheckedIn))); thisAirline.passengerStats.nSchedDep.AddStat(i, new IntStat(schedDepartingPax)); thisAirline.passengerStats.nMissed.AddStat(i, new IntStat(missed > 0 ? missed : 0, missed > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); thisAirline.passengerStats.timeBoarding.AddStat(i, new TimeStat(timeBoarding)); thisAirline.passengerStats.timeDeplaning.AddStat(i, new TimeStat(flightRecords.Sum(x => x.time_deplaning) * 60f)); thisAirline.passengerStats.arrPaxPerFlt.AddStat(i, new AverageStat(arrivingPax, nSchedFlights, typeof(IntStat))); thisAirline.passengerStats.departPaxPerFlt.AddStat(i, new AverageStat(schedDepartingPax, nSchedFlights, typeof(IntStat))); thisAirline.passengerStats.avgBoardTime.AddStat(i, new AverageStat(timeBoarding, ontimeDepart + delDep + canx, typeof(TimeStat))); thisAirline.passengerStats.boardedPerFlt.AddStat(i, new AverageStat(boardedPax, boardedPax + missed, typeof(PercentageStat))); airportData.passengerStats.nArriving.AddToValue(i, new IntStat(arrivingPax)); airportData.passengerStats.nBoarded.AddToValue(i, new IntStat(boardedPax)); airportData.passengerStats.nCheckedIn.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nCheckedIn))); airportData.passengerStats.nSchedDep.AddToValue(i, new IntStat(schedDepartingPax)); airportData.passengerStats.nMissed.AddToValue(i, new IntStat(missed > 0 ? missed : 0, missed > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); airportData.passengerStats.timeBoarding.AddToValue(i, new TimeStat(timeBoarding)); airportData.passengerStats.timeDeplaning.AddToValue(i, new TimeStat(flightRecords.Sum(x => x.time_deplaning) * 60f)); airportData.passengerStats.arrPaxPerFlt.AddToValue(i, new AverageStat(arrivingPax, nSchedFlights, typeof(IntStat))); airportData.passengerStats.departPaxPerFlt.AddToValue(i, new AverageStat(schedDepartingPax, nSchedFlights, typeof(IntStat))); airportData.passengerStats.avgBoardTime.AddToValue(i, new AverageStat(timeBoarding, ontimeDepart + delDep + canx, typeof(TimeStat))); airportData.passengerStats.boardedPerFlt.AddToValue(i, new AverageStat(boardedPax, boardedPax + missed, typeof(PercentageStat))); //Load Fuel Stats int fuelDel = Convert.ToInt32(flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) ? x.nFuelRefueled : 0) / 1000); int fuelReq = Convert.ToInt32(flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) ? x.nFuelRequested : 0) / 1000); int fuelFailures = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) && x.nFuelRequested > 0 && x.nFuelRefueled == 0); thisAirline.fuelStats.fuelDelivered.AddStat(i, new IntStat(fuelDel, fuelDel < fuelReq ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); thisAirline.fuelStats.fuelRequested.AddStat(i, new IntStat(fuelReq)); thisAirline.fuelStats.fuelingFailures.AddStat(i, new IntStat(fuelFailures, fuelFailures > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); thisAirline.fuelStats.planesRefueled.AddStat(i, new IntStat(flightRecords.Count(x => x.nFuelRefueled > 0))); airportData.fuelStats.fuelDelivered.AddToValue(i, new IntStat(fuelDel, fuelDel < fuelReq ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); airportData.fuelStats.fuelRequested.AddToValue(i, new IntStat(fuelReq)); airportData.fuelStats.fuelingFailures.AddToValue(i, new IntStat(fuelFailures, fuelFailures > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); airportData.fuelStats.planesRefueled.AddToValue(i, new IntStat(flightRecords.Count(x => x.nFuelRefueled > 0))); // Load Luggage Stats int lostBaggage = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) ? x.nDepartingBags - x.nBagsLoaded : 0); thisAirline.luggageStats.arrivingBags.AddStat(i, new IntStat(flightRecords.Sum(x => x.nArrivalBags))); thisAirline.luggageStats.bagsLoaded.AddStat(i, new IntStat(flightRecords.Sum(x => x.nBagsLoaded))); thisAirline.luggageStats.bagsUnloaded.AddStat(i, new IntStat(flightRecords.Sum(x => x.nBagsUnloaded))); thisAirline.luggageStats.departingBags.AddStat(i, new IntStat(flightRecords.Sum(x => x.nDepartingBags))); thisAirline.luggageStats.lostBags.AddStat(i, new IntStat(lostBaggage, lostBaggage > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); thisAirline.luggageStats.timeLoadingBags.AddStat(i, new TimeStat(flightRecords.Sum(x => x.nBagsLoaded > 0 ? x.time_bag_load : 0) * 60f)); airportData.luggageStats.arrivingBags.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nArrivalBags))); airportData.luggageStats.bagsLoaded.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nBagsLoaded))); airportData.luggageStats.bagsUnloaded.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nBagsUnloaded))); airportData.luggageStats.departingBags.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nDepartingBags))); airportData.luggageStats.lostBags.AddToValue(i, new IntStat(lostBaggage, lostBaggage > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); airportData.luggageStats.timeLoadingBags.AddToValue(i, new TimeStat(flightRecords.Sum(x => x.nBagsLoaded > 0 ? x.time_bag_load : 0) * 60f)); //Load Gate Stats (into FlightStats) gateSizes[AircraftGate.GateSize.Small] = 0; gateSizes[AircraftGate.GateSize.Large] = 0; gateSizes[AircraftGate.GateSize.Extra_Large] = 0; foreach (FlightRecord fr in flightRecords) { AircraftConfig ac = AircraftConfigManager.FindByAnyName(fr.aircraft, false); if (ac != null) { gateSizes[ac.MinGateSize]++; } } foreach (KeyValuePair <AircraftGate.GateSize, int> kvp in gateSizes) { switch (kvp.Key) { case AircraftGate.GateSize.Small: thisAirline.flightStats.nSmallGates.AddStat(i, new IntStat(kvp.Value)); airportData.flightStats.nSmallGates.AddToValue(i, new IntStat(kvp.Value)); break; case AircraftGate.GateSize.Large: thisAirline.flightStats.nLargeGates.AddStat(i, new IntStat(kvp.Value)); airportData.flightStats.nLargeGates.AddToValue(i, new IntStat(kvp.Value)); break; case AircraftGate.GateSize.Extra_Large: thisAirline.flightStats.nXLGates.AddStat(i, new IntStat(kvp.Value)); airportData.flightStats.nXLGates.AddToValue(i, new IntStat(kvp.Value)); break; } } } } for (int i = end; i >= start; i--) { Game.current.GameReports.TryGetValue(i, out GamedayReportingData gamedayData); if (gamedayData == null) { continue; } airportData.passengerStats.nConnecting.AddStat(i, new IntStat(gamedayData.NumConnectPax)); airportData.fuelStats.avgFuelPrice.AddStat(i, new MoneyStat(GetAverageFuelCost(i), 2)); GamedayReportingData.MoneyCategory category; float val; foreach (string name in Enum.GetNames(typeof(GamedayReportingData.MoneyCategory))) { category = (GamedayReportingData.MoneyCategory)Enum.Parse(typeof(GamedayReportingData.MoneyCategory), name); if ((val = GetDailyMoneyTotal(gamedayData, category, true)) != 0) { airportData.revAndExpStats.revenueStats.AddStat(name, i, new MoneyStat(val)); } if ((val = GetDailyMoneyTotal(gamedayData, category, false)) != 0) { airportData.revAndExpStats.expenseStats.AddStat(name, i, new MoneyStat(val)); } } if ((val = GetDailyMoneyTotal(gamedayData, true)) != 0) { airportData.revAndExpStats.revenueStats.AddStat("total", i, new MoneyStat(val)); int boarded = ((IntStat)airportData.passengerStats.nBoarded.GetStat(i))?.GetValue() ?? 0; int missed = ((IntStat)airportData.passengerStats.nMissed.GetStat(i))?.GetValue() ?? 0; airportData.revAndExpStats.revenueStats.RevPerPax.AddStat(i, new AverageStat(val, boarded + missed, typeof(MoneyStat))); } if ((val = GetDailyMoneyTotal(gamedayData, false)) != 0) { airportData.revAndExpStats.expenseStats.AddStat("total", i, new MoneyStat(val)); } //set profits AirportStatUtils.AirportStatsLogger(Log.FromPool("Loading Profits").WithCodepoint()); val = ((MoneyStat)airportData.revAndExpStats.revenueStats.StatGroups["total"].GetStat(i))?.GetFloatValue() ?? 0; float netCost = -((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups["total"].GetStat(i))?.GetFloatValue() ?? 0; float operatingCost = netCost + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Taxes)].GetStat(i))?.GetFloatValue() ?? 0 - ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Bank)].GetStat(i))?.GetFloatValue() ?? 0; float grossCost = -(((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Fuel)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Infrastructure)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Land_Purchase)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Materials)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Retail)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Staff)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Maintenance)].GetStat(i))?.GetFloatValue() ?? 0); AirportStatUtils.AirportStatsLogger(Log.FromPool($"Revenue: {val}; NetCost: {netCost}; Operating: {operatingCost}; Gross: {grossCost}").WithCodepoint()); airportData.profitStats.GrossProfit.AddStat(i, new MoneyStat(val - grossCost)); airportData.profitStats.OperatingProfit.AddStat(i, new MoneyStat(val - operatingCost)); airportData.profitStats.NetProfit.AddStat(i, new MoneyStat(val - netCost)); if (val != 0) { if (val > grossCost) { airportData.profitStats.GrossMargin.AddStat(i, new PercentageStat((val - grossCost) / val)); } if (val > operatingCost) { airportData.profitStats.OperatingMargin.AddStat(i, new PercentageStat((val - operatingCost) / val)); } if (val > netCost) { airportData.profitStats.NetMargin.AddStat(i, new PercentageStat((val - netCost) / val)); } } AirportStatUtils.AirportStatsLogger(Log.FromPool("Completed Loading Profits").WithCodepoint()); } }
static internal void UpdateAircraftStats(AircraftConfig ac) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); aircraftData.LoadAircraft(ac); }