コード例 #1
0
        /// <summary>
        /// Starts a game and attempts to run it a specified number of generations. Will call the connected
        /// clients on completion or error.
        /// </summary>
        /// <param name="settings">Settings to start the game with.</param>
        public void StartGame(GameSettingsModel settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            try
            {
                var rules    = RuleFactory.Build(settings.Rules);
                var lifeForm = LifeFormFactory.Build(settings.LifeForm);

                var game = bootstrapper.Boot <LinqGame>(rules);
                game.InitializeFrom(lifeForm.GetPattern());

                game.GameStepEvent += OnGameStepEvent;

                game.RunThrough(settings.NumberOfGenerations);

                Clients.All.DisplayResults(game);
            }
            catch (BootFailedException)
            {
                var message = "Booting the game failed.";
                Clients.All.DisplayError(message);
            }
        }
コード例 #2
0
        public void Build_GivenRandomPattern_ReturnsRandomPatternObject()
        {
            // act
            var lifeForm = LifeFormFactory.Build(LifeForm.RandomPattern) as RandomPattern;

            // assert
            Assert.IsNotNull(
                lifeForm,
                message: "Life form not built as per expectation.");
        }
コード例 #3
0
        public void Build_GivenEmptyLifeForm_ReturnsEmptyLifeFormObject()
        {
            // act
            var lifeForm = LifeFormFactory.Build(LifeForm.Empty) as Empty;

            // assert
            Assert.IsNotNull(
                lifeForm,
                message: "Life form not built as per expectation.");
        }
コード例 #4
0
        public void Build_GivenFivePoint_ReturnsFivePointObject()
        {
            // act
            var lifeForm = LifeFormFactory.Build(LifeForm.FivePoint) as FivePoint;

            // assert
            Assert.IsNotNull(
                lifeForm,
                message: "Life form not built as per expectation.");
        }
コード例 #5
0
        public void Build_GivenAircraftCarrier_ReturnsAircraftCarrierObject()
        {
            // act
            var lifeForm = LifeFormFactory.Build(LifeForm.AircraftCarrier) as AircraftCarrier;

            // assert
            Assert.IsNotNull(
                lifeForm,
                message: "Life form not built as per expectation.");
        }