Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Rook
- Inherits Piece
- Public Overrides Function CalculateMove(CurrentBoard As Board, SourcePoint As Point) As List(Of Point)
- Dim DestinationLst As New List(Of Point)
- Dim PDirections() As Point = {
- New Point(-1, 0), 'N
- New Point(0, 1), 'E
- New Point(1, 0), 'S
- New Point(0, -1) 'W
- }
- For Each Direction In PDirections
- Dim NextDestination As New Point(SourcePoint.X + Direction.X, SourcePoint.Y + Direction.Y)
- While CheckWithinArray(NextDestination)
- If CurrentBoard.PieceBoard(SourcePoint.X, SourcePoint.Y) > 0 Then
- If CurrentBoard.PieceBoard(NextDestination.X, NextDestination.Y) = 0 Then
- DestinationLst.Add(NextDestination)
- ElseIf CurrentBoard.PieceBoard(NextDestination.X, NextDestination.Y) < 0 Then
- DestinationLst.Add(NextDestination)
- Exit While
- Else
- Exit While
- End If
- ElseIf CurrentBoard.PieceBoard(SourcePoint.X, SourcePoint.Y) < 0 Then
- If CurrentBoard.PieceBoard(NextDestination.X, NextDestination.Y) = 0 Then
- DestinationLst.Add(NextDestination)
- ElseIf CurrentBoard.PieceBoard(NextDestination.X, NextDestination.Y) > 0 Then
- DestinationLst.Add(NextDestination)
- Exit While
- Else
- Exit While
- End If
- End If
- NextDestination.X += Direction.X
- NextDestination.Y += Direction.Y
- End While
- Next
- Return DestinationLst
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement