예제 #1
0
        public void Run()
        {
            //stories:square do event, then table response
            //tom and jerry is square
            //tom and jerry sit at table 1
            //tom ready
            //jerry ready
            //a chessing start
            //begin while
            //tom move
            //jerry move
            //if kill king or give up then chessing stop and report
            //end while

            ISquare tom   = new Square(Camp.RedCamp, ChessColor.Red);
            ISquare jerry = new Square(Camp.BlackCamp, ChessColor.Black);

            tom.Logger   = new LogDemo();
            jerry.Logger = tom.Logger;
            ITable table = new ChessTable();

            tom.Sit(table);
            jerry.Sit(table);

            Show(tom);
            Show(jerry);

            tom.Ready();
            //table.Clear();
            jerry.Ready();
            //table.Start();
            IChess cannon  = tom.GetChess(ChessType.Cannons);
            IChess cannon2 = jerry.GetChess(ChessType.Cannons);
            var    flag    = false;

            try
            {
                flag = cannon.MoveTo(new ChessPoint(cannon.Square.Camp, 4, 2));   //2 5
                flag = cannon2.MoveTo(new ChessPoint(cannon2.Square.Camp, 4, 2)); // 2 5
                flag = cannon.MoveTo(new ChessPoint(cannon.Square.Camp, 4, 6));   //5 j 4
                flag = cannon2.MoveTo(new ChessPoint(cannon2.Square.Camp, 4, 1)); // 2 5
                flag = cannon.MoveTo(new ChessPoint(cannon.Square.Camp, 4, 9));   //5 j 4
            }
            catch (GameLoseException ex)
            {
                Console.WriteLine(ex.Message);
            }

            //table.Stop();
            //table.Report();
        }