Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub MakeMove(ByRef Board(,) As String, ByRef PlayersPieces(,) As Integer, ByRef OpponentsPieces(,) As Integer, ByVal ListOfMoves() As MoveRecord, ByVal PieceIndex As Integer)
- Dim Piece, MiddlePiece, Answer As String
- Dim NewRow, NewColumn, PlayersPieceIndex, CurrentRow, CurrentColumn, MiddlePieceRow, MiddlePieceColumn, Direction As Integer
- Dim Jumping, CheckedRight, CheckedLeft, JumpAgainRight, JumpAgainLeft As Boolean
- PlayersPieces(0, 0) = PlayersPieces(0, 0) + 1
- If PieceIndex > 0 Then
- Piece = ListOfMoves(PieceIndex).Piece
- NewRow = ListOfMoves(PieceIndex).NewRow
- NewColumn = ListOfMoves(PieceIndex).NewColumn
- If Len(Piece) = 2 Then
- PlayersPieceIndex = CInt(Right(Piece, 1))
- Else
- PlayersPieceIndex = CInt(Right(Piece, 2))
- End If
- If Left(Piece, 1).ToUpper = "A" Then
- Direction = 1
- Else
- Direction = -1
- End If
- CurrentRow = PlayersPieces(PlayersPieceIndex, Row)
- CurrentColumn = PlayersPieces(PlayersPieceIndex, Column)
- Jumping = ListOfMoves(PieceIndex).CanJump
- MovePiece(Board, PlayersPieces, Piece, NewRow, NewColumn)
- While Jumping
- MiddlePieceRow = (CurrentRow + NewRow) \ 2
- MiddlePieceColumn = (CurrentColumn + NewColumn) \ 2
- MiddlePiece = Board(MiddlePieceRow, MiddlePieceColumn)
- Console.WriteLine("jumped over " & MiddlePiece)
- If ValidJump(Board, PlayersPieces, Piece, NewRow + Direction + Direction, NewColumn + 2) Then
- JumpAgainRight = True
- End If
- If ValidJump(Board, PlayersPieces, Piece, NewRow + Direction + Direction, NewColumn - 2) Then
- JumpAgainLeft = True
- End If
- If JumpAgainRight And Not CheckedRight Then
- DisplayBoard(Board)
- Console.WriteLine("The selected piece can jump again to the right - do you want to make this move(Y/N)?")
- Answer = Console.ReadLine
- If Answer = "Y" Then
- CheckedRight = False
- CurrentRow = NewRow
- CurrentColumn = NewColumn
- NewRow = NewRow + Direction + Direction
- NewColumn = NewColumn + 2
- MovePiece(Board, PlayersPieces, Piece, NewRow, NewColumn)
- Else
- CheckedRight = True
- End If
- JumpAgainRight = False
- ElseIf JumpAgainLeft And Not CheckedLeft Then
- DisplayBoard(Board)
- Console.WriteLine("The selected piece can jump again to the left - do you want to make this move(Y/N)?")
- Answer = Console.ReadLine
- If Answer = "Y" Then
- CheckedLeft = False
- CurrentRow = NewRow
- CurrentColumn = NewColumn
- NewRow = NewRow + Direction + Direction
- NewColumn = NewColumn - 2
- MovePiece(Board, PlayersPieces, Piece, NewRow, NewColumn)
- Else
- CheckedLeft = True
- End If
- JumpAgainLeft = False
- Else
- Jumping = False
- End If
- End While
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement