-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcastle.rb
More file actions
33 lines (33 loc) · 995 Bytes
/
castle.rb
File metadata and controls
33 lines (33 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require './move'
require './board'
require './rook'
class Castle<Move
def initialize(board,movedPiece,destination,castleRook,castleRookStart,castleRookDestination)
super(board,movedPiece,destination)
@castleRook=castleRook
@castleRookStart=castleRookStart
@castleRookDestination=castleRookDestination
end
def getCastleRook
@castleRook
end
def isCastlingMove
true
end
def execute
newBoard=Board.new
@board.getCurrentPlayer.getLivePieces.each do |piece|
if (@movedPiece!=piece && @castleRook!=piece)
newBoard.setPiece(piece)
end
end
@board.getCurrentPlayer.getOpponent.getLivePieces.each do |piece|
newBoard.setPiece(piece)
end
newBoard.setPiece(@movedPiece.movePiece(self))
newBoard.setPiece(Rook.new(@castleRookDestination,@castleRook.getPieceAlliance,false))
newBoard.setTurn(@board.getCurrentPlayer.getOpponent.getAlliance)
newBoard.build
newBoard
end
end