//creates a dictionary of average employee discounts public static Dictionary <Airline, Double> GetEmployeeDiscounts() { Dictionary <Airline, Double> employeeDiscounts = new Dictionary <Airline, double>(); foreach (Airline airline in Airlines.GetAllAirlines()) { double eDiscount = airline.Fees.getValue(FeeTypes.GetType("Employee Discount")); employeeDiscounts.Add(airline, eDiscount); } return(employeeDiscounts); }
/*------------------------------------------------------------------------------------------------------------------------------------------- * ------------------------------------------------------------------------------------------------------------------------------------------- * ------------------------------------------END OF CUSTOMER HAPPINESS METHODS-------------------------------------------------------------*/ //creates dictionary of average employee wages public static Dictionary <Airline, Double> GetEmployeeWages() { Dictionary <Airline, Double> employeeWages = new Dictionary <Airline, Double>(); foreach (Airline airline in Airlines.GetAllAirlines()) { double sWage = airline.Fees.getValue(FeeTypes.GetType("Support Wage")); double mWage = airline.Fees.getValue(FeeTypes.GetType("Maintenance Wage")); double pWage = airline.Fees.getValue(FeeTypes.GetType("Pilot Base Salary")); // *airline.Pilots.Count(); double cWage = airline.Fees.getValue(FeeTypes.GetType("Cabin Wage")); double iWage = airline.Fees.getValue(FeeTypes.GetType("Instructor Base Salary")); // *PilotModel.FlightSchool.MaxNumberOfInstructors; int cabinCrew = airline.Routes.Where(r => r.Type == AirlinerModel.RouteModel.Route.RouteType.Passenger || r.Type == AirlinerModel.RouteModel.Route.RouteType.Mixed).Sum(r => ((PassengerRoute)r).getTotalCabinCrew()); int serviceCrew = airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(airline)).Where(a => a.EmployeeType == AirportModel.AirportFacility.EmployeeTypes.Support).Sum(a => a.NumberOfEmployees); int maintenanceCrew = airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(airline)).Where(a => a.EmployeeType == AirportModel.AirportFacility.EmployeeTypes.Maintenance).Sum(a => a.NumberOfEmployees); double averageWage = ((sWage * serviceCrew) + (mWage * maintenanceCrew) + pWage + iWage + (cWage * cabinCrew)) / 5; averageWage = (sWage + mWage + pWage + cWage + iWage) / 5; employeeWages.Add(airline, averageWage); } return(employeeWages); }
public PanelPilot(PagePilots parent, Pilot pilot) { this.ParentPage = parent; this.Pilot = pilot; InitializeComponent(); StackPanel panelPilot = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PanelPilot", txtHeader.Uid); panelPilot.Children.Add(txtHeader); ListBox lbPilotInformation = new ListBox(); lbPilotInformation.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); lbPilotInformation.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1002"), UICreator.CreateTextBlock(this.Pilot.Profile.Name))); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1003"), UICreator.CreateTextBlock(this.Pilot.Profile.Birthdate.ToShortDateString()))); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1004"), UICreator.CreateTownPanel(this.Pilot.Profile.Town))); ContentControl lblFlag = new ContentControl(); lblFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem"); lblFlag.Content = new CountryCurrentCountryConverter().Convert(this.Pilot.Profile.Town.Country); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1005"), lblFlag)); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1006"), UICreator.CreateTextBlock(this.Pilot.EducationTime.ToShortDateString()))); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1007"), UICreator.CreateTextBlock(this.Pilot.Rating.ToString()))); // lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1008"), UICreator.CreateTextBlock(string.Format("{0:C}", ((int)this.Pilot.Rating) * 1000)))); double pilotBasePrice = GameObject.GetInstance().HumanAirline.Fees.getValue(FeeTypes.GetType("Pilot Base Salary"));//GeneralHelpers.GetInflationPrice(133.53);< lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1008"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(((int)this.Pilot.Rating) * pilotBasePrice).ToString()))); panelPilot.Children.Add(lbPilotInformation); panelPilot.Children.Add(createButtonsPanel()); this.Content = panelPilot; }
//simulates the landing of a flight private static void SimulateLanding(FleetAirliner airliner) { DateTime landingTime = airliner.CurrentFlight.FlightTime.Add(MathHelpers.GetFlightTime(airliner.CurrentFlight.Entry.DepartureAirport.Profile.Coordinates.convertToGeoCoordinate(), airliner.CurrentFlight.Entry.Destination.Airport.Profile.Coordinates.convertToGeoCoordinate(), airliner.Airliner.Type)); double fdistance = MathHelpers.GetDistance(airliner.CurrentFlight.getDepartureAirport(), airliner.CurrentFlight.Entry.Destination.Airport); TimeSpan flighttime = landingTime.Subtract(airliner.CurrentFlight.FlightTime); double groundTaxPerPassenger = 5; double tax = 0; if (airliner.CurrentFlight.Entry.Destination.Airport.Profile.Country != airliner.CurrentFlight.getDepartureAirport().Profile.Country) { tax = 2 * tax; } double ticketsIncome = 0; double feesIncome = 0; double mealExpenses = 0; double fuelExpenses = 0; if (airliner.CurrentFlight.isPassengerFlight()) { tax = groundTaxPerPassenger * airliner.CurrentFlight.getTotalPassengers(); fuelExpenses = FleetAirlinerHelpers.GetFuelExpenses(airliner, fdistance); foreach (FlightAirlinerClass fac in airliner.CurrentFlight.Classes) { ticketsIncome += fac.Passengers * ((PassengerRoute)airliner.CurrentFlight.Entry.TimeTable.Route).getRouteAirlinerClass(fac.AirlinerClass.Type).FarePrice; } FeeType employeeDiscountType = FeeTypes.GetType("Employee Discount"); double employeesDiscount = airliner.Airliner.Airline.Fees.getValue(employeeDiscountType); double totalDiscount = ticketsIncome * (employeeDiscountType.Percentage / 100.0) * (employeesDiscount / 100.0); ticketsIncome = ticketsIncome - totalDiscount; foreach (FeeType feeType in FeeTypes.GetTypes(FeeType.eFeeType.Fee)) { if (GameObject.GetInstance().GameTime.Year >= feeType.FromYear) { foreach (FlightAirlinerClass fac in airliner.CurrentFlight.Classes) { double percent = 0.10; double maxValue = Convert.ToDouble(feeType.Percentage) * (1 + percent); double minValue = Convert.ToDouble(feeType.Percentage) * (1 - percent); double value = Convert.ToDouble(rnd.Next((int)minValue, (int)maxValue)) / 100; feesIncome += fac.Passengers * value * airliner.Airliner.Airline.Fees.getValue(feeType); } } } foreach (FlightAirlinerClass fac in airliner.CurrentFlight.Classes) { foreach (RouteFacility facility in ((PassengerRoute)airliner.CurrentFlight.Entry.TimeTable.Route).getRouteAirlinerClass(fac.AirlinerClass.Type).getFacilities()) { if (facility.EType == RouteFacility.ExpenseType.Fixed) { mealExpenses += fac.Passengers * facility.ExpensePerPassenger; } else { FeeType feeType = facility.FeeType; double percent = 0.10; double maxValue = Convert.ToDouble(feeType.Percentage) * (1 + percent); double minValue = Convert.ToDouble(feeType.Percentage) * (1 - percent); double value = Convert.ToDouble(rnd.Next((int)minValue, (int)maxValue)) / 100; mealExpenses -= fac.Passengers * value * airliner.Airliner.Airline.Fees.getValue(feeType); } } } } if (airliner.CurrentFlight.isCargoFlight()) { tax = groundTaxPerPassenger * airliner.CurrentFlight.Cargo; fuelExpenses = FleetAirlinerHelpers.GetFuelExpenses(airliner, fdistance); ticketsIncome = airliner.CurrentFlight.Cargo * airliner.CurrentFlight.getCargoPrice(); } Airport dest = airliner.CurrentFlight.Entry.Destination.Airport; Airport dept = airliner.CurrentFlight.Entry.DepartureAirport; double dist = MathHelpers.GetDistance(dest.Profile.Coordinates.convertToGeoCoordinate(), dept.Profile.Coordinates.convertToGeoCoordinate()); double expenses = fuelExpenses + dest.getLandingFee() + tax; if (double.IsNaN(expenses)) { expenses = 0; } if (double.IsNaN(ticketsIncome) || ticketsIncome < 0) { ticketsIncome = 0; } FleetAirlinerHelpers.SetFlightStats(airliner); long airportIncome = Convert.ToInt64(dest.getLandingFee()); dest.Income += airportIncome; Airline airline = airliner.Airliner.Airline; var agreements = airline.Codeshares.Where(c => c.Airline1 == airline || c.Type == CodeshareAgreement.CodeshareType.Both_Ways); foreach (CodeshareAgreement agreement in agreements) { var tAirline = agreement.Airline1 == airline ? agreement.Airline2 : agreement.Airline1; double agreementIncome = ticketsIncome * (CodeshareAgreement.TicketSalePercent / 100); AirlineHelpers.AddAirlineInvoice(tAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Tickets, agreementIncome); } AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Flight_Expenses, -expenses); AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Tickets, ticketsIncome); AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.OnFlight_Income, -mealExpenses); AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Fees, feesIncome); airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Flight_Expenses, -expenses)); airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Tickets, ticketsIncome)); airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.OnFlight_Income, -mealExpenses)); airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Fees, feesIncome)); double wages = 0; if (airliner.CurrentFlight.isPassengerFlight()) { int cabinCrew = ((AirlinerPassengerType)airliner.Airliner.Type).CabinCrew; wages = cabinCrew * flighttime.TotalHours * airliner.Airliner.Airline.Fees.getValue(FeeTypes.GetType("Cabin Wage"));// +(airliner.CurrentFlight.Entry.TimeTable.Route.getTotalCabinCrew() * airliner.Airliner.Airline.Fees.getValue(FeeTypes.GetType("Cabin kilometer rate")) * fdistance) + (airliner.Airliner.Type.CockpitCrew * airliner.Airliner.Airline.Fees.getValue(FeeTypes.GetType("Cockpit kilometer rate")) * fdistance); //wages AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Wages, -wages); HolidayYearEvent holiday = HolidayYear.GetHoliday(airline.Profile.Country, GameObject.GetInstance().GameTime); if (holiday != null && (holiday.Holiday.Travel == Holiday.TravelType.Both || holiday.Holiday.Travel == Holiday.TravelType.Normal)) { wages = wages * 1.50; } airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Wages, -wages)); CreatePassengersHappiness(airliner); } airliner.Statistics.addStatisticsValue(GameObject.GetInstance().GameTime.Year, StatisticsTypes.GetStatisticsType("Airliner_Income"), ticketsIncome - expenses - mealExpenses + feesIncome - wages); airliner.Airliner.Flown += fdistance; if (airliner.CurrentFlight.isPassengerFlight()) { foreach (Cooperation cooperation in airliner.CurrentFlight.Entry.Destination.Airport.Cooperations.Where(c => c.Airline == airline)) { double incomePerPax = MathHelpers.GetRandomDoubleNumber(cooperation.Type.IncomePerPax * 0.9, cooperation.Type.IncomePerPax * 1.1); double incomeFromCooperation = Convert.ToDouble(airliner.CurrentFlight.getTotalPassengers()) * incomePerPax; AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.OnFlight_Income, incomeFromCooperation); } } if (airliner.Airliner.Airline.IsHuman && Settings.GetInstance().MailsOnLandings) { GameObject.GetInstance().NewsBox.addNews(new News(News.NewsType.Flight_News, GameObject.GetInstance().GameTime, string.Format("{0} landed", airliner.Name), string.Format("Your airliner [LI airliner={0}] has landed in [LI airport={1}], {2} with {3} passengers.\nThe airliner flow from [LI airport={4}], {5}", new object[] { airliner.Airliner.TailNumber, dest.Profile.IATACode, dest.Profile.Country.Name, airliner.CurrentFlight.getTotalPassengers(), dept.Profile.IATACode, dept.Profile.Country.Name }))); } if (airliner.CurrentFlight is StopoverFlight && !((StopoverFlight)airliner.CurrentFlight).IsLastTrip) { SimulateFlight(airliner.CurrentFlight.Entry); } else { airliner.CurrentFlight = null; } }
public PageShowPilot(Pilot pilot) { this.Pilot = pilot; InitializeComponent(); double pilotBasePrice = GameObject.GetInstance().HumanAirline.Fees.getValue(FeeTypes.GetType("Pilot Base Salary"));//GeneralHelpers.GetInflationPrice(133.53);< this.Salary = ((int)this.Pilot.Rating) * pilotBasePrice; }