Example #1
0
        public IMoveResult DoMove(Position @from, Position destination)
        {
            if (!_moveManager.VerifyPositionInBoundaries(from) || !_moveManager.VerifyPositionInBoundaries(destination))
            {
                return(new InvalidMoveResult("Position out of board"));
            }

            if (!_moveManager.IsAllyAtPosition(from, _currentMovingTeam))
            {
                return(new InvalidMoveResult($"Your figure is not in the given position"));
            }

            var moveManagerValidation = _moveManager.CanMove(from, destination);

            if (!moveManagerValidation.Item1)
            {
                return(new InvalidMoveResult(moveManagerValidation.Item2));
            }

            var result = _moveManager.Move(from, destination);

            AddNewSmashed(result.Item4);
            var moveResult = new ValidMoveResult(result.Item1, result.Item2, result.Item3, result.Item4, _smashed);

            SwitchTeam();
            _isCheckMate = moveResult.IsCheckMate(_currentMovingTeam);
            return(moveResult);
        }
Example #2
0
        public void StartMoving(string moves)
        {
            Position position = _moveManager.Move(_position, moves);

            Console.WriteLine($"{position.X} {position.Y} {position.Direction.ToString()}");
        }