Beispiel #1
0
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 2, - 410000.00 + 10000.00 - 5000.00 + 89.86 * 1 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 15, - 410000.00 + 10000.00 - 5000.00 + 89.86 * 14 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2019, 2, 3, - 410000.00 + 10000.00 - 5000.00 + 89.86 * 33 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2020, 1, 2, -410000.00 + 10000.00 - 5000.00 + 89.86 * 366 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2020, 1, 3, - 410000.00 + 10000.00 - 5000.00 + 89.86 * 367 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2020, 1, 4, - 410000.00 + 500000.00 + 10000.00 - 5000.00 + 89.86 * 368 - (1000.00 + 8500 + 800) - (25000 + 1000 + 1000) - 317588.78)]
        // [TestCase(InflationTypes.NoopInflation, 2020, 2, 3, - 410000.00 + 500000.00 + 10000.00 - 5000.00 + 89.86 * 398 - (1000.00 + 8500 + 800) - (25000 + 1000 + 1000) - 317588.78)]
        // [TestCase(InflationTypes.NoopInflation, 2020, 2, 4, - 410000.00 + 500000.00 - 410000.00 + 10000.00 - 5000.00 + 89.86 * 399 - (1000.00 + 8500 + 800) - (25000 + 1000 + 1000) - 317588.78 - (1000.00 + 8500 + 800))]
        public void Test_BalanceSheet_GetCashAt(InflationTypes inflationType, int year, int month, int day, decimal expected)
        {
            var inflation = Inflations.GetInflation(inflationType);

            Assert.That(
                Subject.GetCashAt(inflation, new DateTime(year, month, day)),
                Is.EqualTo(expected)
                );
        }
Beispiel #2
0
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 2, - 410000.00 + 10000.00 - 5000.00 + 89.86 * 1 - (1000.00 + 8500 + 800) + 0.00 - 1584.39)]
        // [TestCase(InflationTypes.NoopInflation, 2020, 2, 4, - 410000.00 + 500000.00 - 410000.00 + 10000.00 - 5000.00 + 89.86 * 399 - (1000.00 + 8500 + 800) - (25000 + 1000 + 1000) - 317588.78 - (1000.00 + 8500 + 800) + 0.00 - (1584.39 * 13 + 1584.39))]
        public void Test_BalanceSheet_GetNetWorthAt(InflationTypes inflationType, int year, int month, int day, decimal expected)
        {
            var inflation = Inflations.GetInflation(inflationType);

            Assert.That(
                Subject.GetNetWorthAt(inflation, new DateTime(year, month, day)),
                // Is.EqualTo(expected)
                Is.InRange(
                    Convert.ToDecimal(1.0001) * expected,
                    Convert.ToDecimal(0.9999) * expected
                    )
                );
        }
Beispiel #3
0
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 1, 2019, 1, 2, - 410000.00 + 89.86 * 1 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 1, 2019, 1, 15, - 410000.00 + 89.86 * 14 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 2, 2019, 1, 15, + 89.86 * 13)]
        // [TestCase(InflationTypes.NoopInflation, 2019, 1, 1, 2020, 2, 4, - 410000.00 + 500000.00 - 410000.00 + 89.86 * 399 - (1000.00 + 8500 + 800) - (25000 + 1000 + 1000) - 317588.78 - (1000.00 + 8500 + 800))]
        // [TestCase(InflationTypes.NoopInflation, 2020, 1, 4, 2020, 2, 4, - 410000.00 + 89.86 * 31 - (1000.00 + 8500 + 800))]
        public void Test_BalanceSheet_GetCash(InflationTypes inflationType, int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, decimal expected)
        {
            var inflation = Inflations.GetInflation(inflationType);

            Assert.That(
                Subject.GetCash(
                    inflation,
                    new DateTime(startYear, startMonth, startDay),
                    new DateTime(endYear, endMonth, endDay)
                    ),
                Is.EqualTo(expected)
                );
        }
Beispiel #4
0
        //creates a new game
        private void createNewGame()
        {
            if (txtName.Text.Trim().Length > 2)
            {
                object    o         = null;
                int       startYear = (int)cbStartYear.SelectedItem;
                int       opponents = (int)cbOpponents.SelectedItem;
                Airline   airline   = (Airline)cbAirline.SelectedItem;
                Continent continent = (Continent)cbContinent.SelectedItem;
                Region    region    = (Region)cbRegion.SelectedItem;


                if (this.OpponentType == OpponentSelect.User)
                {
                    if (cbSameRegion.IsChecked.Value)
                    {
                        o = PopUpSelectOpponents.ShowPopUp(airline, opponents, startYear, airline.Profile.Country.Region);
                    }
                    else
                    {
                        o = PopUpSelectOpponents.ShowPopUp(airline, opponents, startYear, region, continent);
                    }
                }



                // popUpSplash.IsOpen = true;

                DoEvents();

                GameTimeZone gtz = (GameTimeZone)cbTimeZone.SelectedItem;
                GameObject.GetInstance().DayRoundEnabled = cbDayTurnEnabled.IsChecked.Value;
                GameObject.GetInstance().TimeZone        = gtz;
                GameObject.GetInstance().Difficulty      = (DifficultyLevel)cbDifficulty.SelectedItem;
                GameObject.GetInstance().GameTime        = new DateTime(startYear, 1, 1);
                GameObject.GetInstance().StartDate       = GameObject.GetInstance().GameTime;
                //sets the fuel price
                GameObject.GetInstance().FuelPrice = Inflations.GetInflation(GameObject.GetInstance().GameTime.Year).FuelPrice;

                airline.Profile.Country = (Country)cbCountry.SelectedItem;
                airline.Profile.CEO     = txtName.Text.Trim();

                GameObject.GetInstance().setHumanAirline(airline);
                GameObject.GetInstance().MainAirline = GameObject.GetInstance().HumanAirline;

                if (cbLocalCurrency.IsChecked.Value)
                {
                    GameObject.GetInstance().CurrencyCountry = airline.Profile.Country;
                }
                // AppSettings.GetInstance().resetCurrencyFormat();

                Airport airport = (Airport)cbAirport.SelectedItem;

                AirportHelpers.RentGates(airport, airline, 2);

                AirportFacility checkinFacility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.CheckIn).Find(f => f.TypeLevel == 1);
                AirportFacility facility        = AirportFacilities.GetFacilities(AirportFacility.FacilityType.Service).Find((delegate(AirportFacility f) { return(f.TypeLevel == 1); }));

                airport.addAirportFacility(GameObject.GetInstance().HumanAirline, facility, GameObject.GetInstance().GameTime);
                airport.addAirportFacility(GameObject.GetInstance().HumanAirline, checkinFacility, GameObject.GetInstance().GameTime);

                if (continent.Uid != "100" || region.Uid != "100")
                {
                    var airlines = Airlines.GetAirlines(a => a.Profile.Country.Region == region || (region.Uid == "100" && continent.hasRegion(a.Profile.Country.Region)) && a.Profile.Founded <= startYear && a.Profile.Folded > startYear);
                    var airports = Airports.GetAirports(a => a.Profile.Country.Region == region || (region.Uid == "100" && continent.hasRegion(a.Profile.Country.Region)) && a.Profile.Period.From.Year <= startYear && a.Profile.Period.To.Year > startYear);

                    //Airports.RemoveAirports(a => (a.Profile.Country.Region != region && !continent.hasRegion(a.Profile.Country.Region)) || (a.Profile.Town.State != null && a.Profile.Town.State.IsOverseas));
                    Airports.Clear();
                    foreach (Airport a in airports)
                    {
                        Airports.AddAirport(a);
                    }

                    Airlines.Clear();
                    foreach (Airline a in airlines)
                    {
                        Airlines.AddAirline(a);
                    }
                }

                PassengerHelpers.CreateAirlineDestinationDemand();

                AirlinerHelpers.CreateStartUpAirliners();

                if (this.OpponentType == OpponentSelect.Random || o == null)
                {
                    Setup.SetupMainGame(opponents, cbSameRegion.IsChecked.Value);
                }
                else
                {
                    Setup.SetupMainGame((List <Airline>)o);
                }


                airline.MarketFocus = (Airline.AirlineFocus)cbFocus.SelectedItem;

                GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year);

                //PassengerHelpers.CreateDestinationPassengers();

                GameObjectWorker.GetInstance().start();
                // AIWorker.GetInstance().start();

                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

                PageNavigator.ClearNavigator();

                //GameObject.GetInstance().HumanAirline.Money = 10000000000000;

                GameObject.GetInstance().NewsBox.addNews(new News(News.NewsType.Standard_News, GameObject.GetInstance().GameTime, Translator.GetInstance().GetString("News", "1001"), string.Format(Translator.GetInstance().GetString("News", "1001", "message"), GameObject.GetInstance().HumanAirline.Profile.CEO, GameObject.GetInstance().HumanAirline.Profile.IATACode)));

                popUpSplash.IsOpen = false;



                Action action = () =>
                {
                    Stopwatch swPax = new Stopwatch();
                    swPax.Start();

                    PassengerHelpers.CreateDestinationDemand();

                    Console.WriteLine("Demand have been created in {0} ms.", swPax.ElapsedMilliseconds);
                    swPax.Stop();
                };

                Task.Factory.StartNew(action);
                //Task.Run(action);
                //Task t2 = Task.Factory.StartNew(action, "passengers");
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2403"), Translator.GetInstance().GetString("MessageBox", "2403"), WPFMessageBoxButtons.Ok);
            }
        }
        //sets up a scenario
        public static void SetupScenario(Scenario scenario)
        {
            Airline airline = scenario.Airline;

            GameObject.GetInstance().DayRoundEnabled = true;
            GameObject.GetInstance().TimeZone        = scenario.Homebase.Profile.TimeZone;
            GameObject.GetInstance().Difficulty      = scenario.Difficulty;
            GameObject.GetInstance().GameTime        = new DateTime(scenario.StartYear, 1, 1);
            GameObject.GetInstance().StartDate       = GameObject.GetInstance().GameTime;
            //sets the fuel price
            GameObject.GetInstance().FuelPrice = Inflations.GetInflation(GameObject.GetInstance().GameTime.Year).FuelPrice;

            GameObject.GetInstance().setHumanAirline(airline);
            GameObject.GetInstance().MainAirline = GameObject.GetInstance().HumanAirline;
            GameObject.GetInstance().HumanAirline.Money = scenario.StartCash;

            GameObject.GetInstance().Scenario = new ScenarioObject(scenario);

            Airport airport = scenario.Homebase;

            SetupScenarioAirport(airline, airport);


            // PassengerHelpers.CreateDestinationPassengers();

            AirlinerHelpers.CreateStartUpAirliners();

            int pilotsPool = 100 * Airlines.GetAllAirlines().Count;

            GeneralHelpers.CreatePilots(pilotsPool);

            int instructorsPool = 75 * Airlines.GetAllAirlines().Count;

            GeneralHelpers.CreateInstructors(instructorsPool);

            SetupScenarioAirlines(scenario);
            SetupScenario();
            Setup.SetupAlliances();

            PassengerHelpers.CreateAirlineDestinationDemand();

            GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year);
            GameObjectWorker.GetInstance().start();

            PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

            PageNavigator.ClearNavigator();

            // GameObject.GetInstance().HumanAirline.Money = 1000000000;

            GameObject.GetInstance().NewsBox.addNews(new News(News.NewsType.Standard_News, GameObject.GetInstance().GameTime, Translator.GetInstance().GetString("News", "1001"), string.Format(Translator.GetInstance().GetString("News", "1001", "message"), GameObject.GetInstance().HumanAirline.Profile.CEO, GameObject.GetInstance().HumanAirline.Profile.IATACode)));


            Action <object> action = (object obj) =>
            {
                PassengerHelpers.CreateDestinationDemand();

                SetupScenarioPassengerDemand(scenario);
            };


            Task t2 = Task.Factory.StartNew(action, "passengers");
        }