Esempio n. 1
0
        public void Given_ValidMoves_GameStateProgresses()
        {
            var gameState = _gameStateEngine.Start();

            Assert.IsTrue(gameState.Player1Turn);
            _gameStateEngine.Instruct(gameState, "4");
            Assert.IsFalse(gameState.Player1Turn);
            _gameStateEngine.Instruct(gameState, "7");

            Assert.IsTrue(gameState.GameNotation == "0123X56O8");

            Assert.IsTrue(gameState.Player1Turn);
            _gameStateEngine.Instruct(gameState, "0");
            Assert.IsFalse(gameState.Player1Turn);
            _gameStateEngine.Instruct(gameState, "8");

            Assert.IsTrue(gameState.GameNotation == "X123X56OO");
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            var gameStateEngine = new GameStateEngine(new ConsoleDisplay());
            var gameState       = gameStateEngine.Start();

            while (!gameState.Quit)
            {
                var command = gameStateEngine.RequestCommand();
                gameStateEngine.Instruct(gameState, command);
            }
            Console.WriteLine("Goodbye!");
            Thread.Sleep(3000);
        }
        protected override void OnInitialized(EventArgs e)
        {
            try
            {
                engine.Updated += Engine_Updated;
                engine.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            base.OnInitialized(e);
        }