Exemplo n.º 1
0
        private List <Move> GetAllAvailableMove(Game game, GameSide gameSide)
        {
            var availableMoves = new List <Move>();

            foreach (var figure in game.Board.Figures.Where(x => x.Side == gameSide))
            {
                var allMovesForFigure = figure.GetFieldsICanMoveTo();
                foreach (var locationToMoveTo in allMovesForFigure)
                {
                    var move = new Move(figure.Location, locationToMoveTo, gameSide);
                    if (_moveValidator.MoveIsValid(move, game.Board))
                    {
                        availableMoves.Add(move);
                    }
                }
            }

            return(availableMoves);
        }
Exemplo n.º 2
0
        public Move GetNextMove(Game game)
        {
            var  player = game.GetNextToMove();
            Move move;

            if (player.IsAIPlayer)
            {
                move = _moveGenerator.GenerateMove(game, player.GameSide);
            }
            else
            {
                while (true)
                {
                    move = _userMoveReader.FetchMove(player.GameSide);
                    if (_moveValidator.MoveIsValid(move, game.Board))
                    {
                        break;
                    }
                }
            }

            game.SwitchNextPlayer();
            return(move);
        }