public BoardPosition GetMovePosition()
        {
            BoardPosition position = RobotStatus.GetPosition();
            BoardPosition pos      = null;

            if (position != null)
            {
                Tuple <int, char> moveInfo = GetMoveInfo(position.Direction);
                int blockSize   = BoardStatus.GetBlockSize();
                int offset      = BoardStatus.GetOffset();
                int boardHeight = BoardStatus.GetBoardDimension().Height;

                pos = position.Clone();

                switch (moveInfo.Item2)
                {
                case 'X':
                    int XBlock = position.XBlock + moveInfo.Item1;
                    int xBlock = (position.XBlock - 1) + moveInfo.Item1;
                    pos.XBlock = XBlock;
                    pos.X      = (xBlock * blockSize) + offset;
                    break;

                case 'Y':
                    int YBlock = position.YBlock + moveInfo.Item1;
                    pos.YBlock = YBlock;
                    pos.Y      = boardHeight - (YBlock * blockSize) + offset;
                    break;
                }

                Directions dir = (Directions)Enum.Parse(typeof(Directions), GetDirectionName(position.Direction));
                RobotStatus.SetDirectionOrigin((char)dir);
            }
            return(pos);
        }
Exemple #2
0
        private static BoardPosition GetPositionAfterMove(BoardPosition boardPosition, PlayMove move)
        {
            var clone = BoardPosition.Clone(boardPosition);

            var piece = clone.Pieces.Single(p => p.PositionOnBoard == move.From);

            piece.PositionOnBoard = move.To;

            return(clone);
        }
Exemple #3
0
        public void ShouldClone()
        {
            BoardPosition position  = new BoardPosition();
            BoardPosition position2 = position.Clone();

            Assert.IsNotNull(position2);
            Assert.AreNotEqual(position, position2);
            Assert.AreEqual(position.Color, position2.Color);

            for (int pos = 0; pos < BoardPosition.Size; pos++)
            {
                Assert.AreEqual(position.GetColors(pos), position2.GetColors(pos));
            }
        }