Пример #1
0
        /// <summary>
        /// Adds a GameObject to a Board
        /// </summary>
        /// <param name="coordinate">Coordinate to be added</param>
        /// <param name="objectTBA">Object to be added</param>
        public void AddGameObject(Coordinate coordinate, GameObject objectTBA)
        {
            var tileItem = this.Tiles.FirstOrDefault(tile => tile.Coordinate.IsSame(coordinate));

            BoardValidation.ValidateTileObject(tileItem);
            BoardValidation.ValidateConcurrentObject(tileItem);

            tileItem.CurrentObject = objectTBA;
        }
Пример #2
0
        /// <summary>
        /// Previews a movement of an object on the Board
        /// </summary>
        /// <param name="targetCoordinate">Target Coordinate to be moved</param>
        public void PreviewMoveObject(Coordinate targetCoordinate)
        {
            Tile targetTile = GetTile(targetCoordinate);

            // GameOver.OutOfBounds if tile does not exist
            BoardValidation.ValidateTargetTile(targetTile);

            GameObject targetGameObject = targetTile.CurrentObject;

            BoardValidation.ValidateLegitMovement(targetGameObject, targetCoordinate);
        }
Пример #3
0
        /// <summary>
        /// Moves an object on the Board
        /// </summary>
        /// <param name="targetCoordinate">Target Coordinate to be moved</param>
        /// <param name="sourceCoordinate">Source Coordinate where the object stands currently</param>
        public void MoveObject(Coordinate targetCoordinate, Coordinate sourceCoordinate)
        {
            Tile currentTile = GetTile(sourceCoordinate);
            Tile targetTile  = GetTile(targetCoordinate);

            BoardValidation.ValidateSourceTile(currentTile);
            // GameOver.OutOfBounds if tile does not exist
            BoardValidation.ValidateTargetTile(targetTile);

            GameObject sourceGameObject = currentTile.CurrentObject;
            GameObject targetGameObject = targetTile.CurrentObject;

            BoardValidation.ValidateMovingObject(sourceGameObject);
            BoardValidation.ValidateLegitMovement(targetGameObject, targetCoordinate);

            targetTile.CurrentObject  = sourceGameObject;
            currentTile.CurrentObject = null;
        }
Пример #4
0
        public void TestValidate()
        {
            SudokuBoard board  = new SudokuBoard();
            Validity    valid1 = BoardValidation.Validate(board);

            Assert.AreEqual(Validity.CONSISTENT, valid1);

            BoardFactory.FillSequential(board);
            Validity valid2 = BoardValidation.Validate(board);

            Assert.AreEqual(Validity.INCONSISTENT, valid2);

            BoardFactory.FillStriped(board);
            Validity valid3 = BoardValidation.Validate(board);

            Assert.AreEqual(Validity.COMPLETE, valid3);

            board[3] = 15;
            Validity valid4 = BoardValidation.Validate(board);

            Assert.AreEqual(Validity.INVALID, valid4);
        }