예제 #1
0
 static void Main(string[] args)
 {
     IRenderer renderer = new ConsoleRenderer();
     renderer.RenderMainMenu();
     IInputProvider provider = new ConsoleInputProvider();
     IWinningConditions winningConditions=new WinningConditions();
     IBoard board=new Board();
     IChessEngine chessEngine = new KingSurvivalEngine(renderer, provider,board,winningConditions);
     chessEngine.Initialize();
     chessEngine.Start();
     //TODO:add main menu
 }
예제 #2
0
        public void Start(IRenderer renderer, IInputProvider provider)
        {
            renderer.RenderMainMenu();
            IWinningConditions winningConditions = new WinningConditions();
            var players = new List<IPlayer>();
            var kingPlayer = new Player("king");
            var pawnPlayer = new Player("pawn");
            players.Add(kingPlayer);
            players.Add(pawnPlayer);

            var board = new Board.Board();

            var engine = new KingSurvivalEngine(renderer, provider, board, winningConditions, players);
            engine.InitializeGame().StartGame();
        }
예제 #3
0
 /// <summary>
 /// Method for starting a game
 /// </summary>
 /// <param name="renderer">The renderer on which the info is going to be rendered</param>
 /// <param name="provider">The input provider that provides information</param>
 public void Start(IRenderer renderer, IInputProvider provider)
 {
     renderer.RenderMainMenu();
     IWinningConditions winningConditions = new WinningConditions();
     var players = new List<IPlayer>();
     var kingPlayer = new Player(provider.GetPlayerName());
     var pawnPlayer = new Player(provider.GetPlayerName());
     players.Add(kingPlayer);
     players.Add(pawnPlayer);
     var board = new Board.Board();
     var memory = new BoardMemory();
     var context = new CommandContext(memory, board, players[0]);
     var commandFactory = new CommandFactory();
     var engine = new KingSurvivalEngine(renderer, provider, board, winningConditions, players, memory, context, commandFactory);
     engine.InitializeGame().StartGame();
 }
        public void CheckIfKingDoesntWinWhenKingDoesnMeetWiningConditions()
        {
            IFigure kingFigure = new KingFigure("K");
            IPosition kingPosition = new Position(1, 2);
            IBoard board = new Board(8, 8);
            board.AddFigure(kingFigure, kingPosition);
            PawnFigure pawnA = new PawnFigure(Constants.FirstPawnDisplaySign);
            board.AddFigure(pawnA, new Position(1, 2));

            PawnFigure pawnB = new PawnFigure(Constants.SecondPawnDisplaySign);
            board.AddFigure(pawnB, new Position(1, 4));

            PawnFigure pawnC = new PawnFigure(Constants.ThirdPawnDisplaySign);
            board.AddFigure(pawnC, new Position(1, 6));

            PawnFigure pawnD = new PawnFigure(Constants.FourthPawnDisplaySign);
            board.AddFigure(pawnD, new Position(1, 0));

            var kingPlayer = new Player("king");
            kingPlayer.AddFigure(new MoveableFigure(kingFigure));

            var pawnPlayer = new Player("pawn");
            pawnPlayer.AddFigure(new MoveableFigure(pawnA));
            pawnPlayer.AddFigure(new MoveableFigure(pawnB));
            pawnPlayer.AddFigure(new MoveableFigure(pawnC));
            pawnPlayer.AddFigure(new MoveableFigure(pawnD));

            var players = new List<IPlayer>()
            {
                kingPlayer,
                pawnPlayer
            };
            var winningConditions = new WinningConditions();
            var isKingWin = winningConditions.KingWon(players, board);
            Assert.AreEqual(isKingWin, false);
        }