Exemplo n.º 1
0
        public void RotateBoat()
        {
            int    size             = BoardDimentions.GetColumns().Count;
            string lastColumn       = BoardDimentions.GetColumns()[size - 1];
            string secondlastColumn = BoardDimentions.GetColumns()[size - 2];
            string lastRow          = BoardDimentions.GetRows()[size - 1];
            string secondlastRow    = BoardDimentions.GetRows()[size - 2];

            if (personalBoatLocation.GetColumn() == secondlastColumn && personalBoatLocation.GetOrientation() == Orientation.X)
            {
                this.MoveBoatUp();
            }
            if (personalBoatLocation.GetColumn() == lastColumn && personalBoatLocation.GetOrientation() == Orientation.X)
            {
                this.MoveBoatUp();
                this.MoveBoatUp();
            }
            if (personalBoatLocation.GetRow() == secondlastRow && personalBoatLocation.GetOrientation() == Orientation.Y)
            {
                this.MoveBoatLeft();
            }
            if (personalBoatLocation.GetRow() == lastRow && personalBoatLocation.GetOrientation() == Orientation.Y)
            {
                this.MoveBoatLeft();
                this.MoveBoatLeft();
            }
            if (personalBoatLocation.GetOrientation() == Orientation.Y)
            {
                personalBoatLocation.SetOrientation(Orientation.X);
            }
            else
            {
                personalBoatLocation.SetOrientation(Orientation.Y);
            }
        }
Exemplo n.º 2
0
        public string RenderBoard(Board board)
        {
            string board_string = @"
";

            foreach (string firstRow in BoardDimentions.GetRows())
            {
                board_string += "   |   ";
                board_string += firstRow;
            }
            board_string += @"   |
";
            foreach (string column in BoardDimentions.GetColumns())
            {
                board_string += @"-
";
                board_string += column;
                board_string += "  ";
                foreach (string row in BoardDimentions.GetRows())
                {
                    board_string += "    ";
                    board_string += board.ReturnBoard[row][column];
                    board_string += "   ";
                }
                board_string += @"
-

";
            }
            return(board_string);
        }
Exemplo n.º 3
0
        public Dictionary <string, Dictionary <string, string> > InitializeBoard()
        {
            var board = new Dictionary <string, Dictionary <string, string> >()
            {
            };

            foreach (string i in BoardDimentions.GetRows())
            {
                board.Add(i, new Dictionary <string, string>()
                {
                });
                foreach (string j in BoardDimentions.GetColumns())
                {
                    board[i][j] = StringContants.EmptySpot;
                }
            }
            return(board);
        }
Exemplo n.º 4
0
        public void MoveBoatLeft()
        {
            int    size          = BoardDimentions.GetRows().Count;
            string lastRow       = BoardDimentions.GetRows()[size - 1];
            string firstRow      = BoardDimentions.GetRows()[0];
            string secondlastRow = BoardDimentions.GetRows()[size - 3];

            if (personalBoatLocation.GetRow() == firstRow && personalBoatLocation.GetOrientation() == Orientation.X)
            {
                personalBoatLocation.SetRow(secondlastRow);
            }
            else if (personalBoatLocation.GetRow() == firstRow && personalBoatLocation.GetOrientation() == Orientation.Y)
            {
                personalBoatLocation.SetRow(lastRow);
            }
            else
            {
                int rowIndex = BoardDimentions.GetRows().IndexOf(personalBoatLocation.GetRow());
                personalBoatLocation.SetRow(BoardDimentions.GetRows()[rowIndex - 1]);
            }
        }
Exemplo n.º 5
0
        public void PlaceItem(BoatLocation location, string item)
        {
            string      row         = location.GetRow();
            string      column      = location.GetColumn();
            Orientation orientation = location.GetOrientation();
            int         rowIndex    = BoardDimentions.GetRows().IndexOf(row);
            int         columnIndex = BoardDimentions.GetColumns().IndexOf(column);

            if (orientation == Orientation.X)
            {
                this.boardValue[row][column] = item;
                this.boardValue[BoardDimentions.GetRows()[rowIndex + 1]][column] = item;
                this.boardValue[BoardDimentions.GetRows()[rowIndex + 2]][column] = item;
            }
            if (orientation == Orientation.Y)
            {
                this.boardValue[row][column] = item;
                this.boardValue[row][BoardDimentions.GetColumns()[columnIndex + 1]] = item;
                this.boardValue[row][BoardDimentions.GetColumns()[columnIndex + 2]] = item;
            }
        }
Exemplo n.º 6
0
 public bool ValidateMissileInput(string input)
 {
     return(BoardDimentions.GetRows().Contains(input[0].ToString()) && BoardDimentions.GetColumns().Contains(input[1].ToString()));
 }