public
Fork of scrooloose/chesticles
Description: A chess hax in ruby
Clone URL: git://github.com/halorgium/chesticles.git
added Move#moving_to_end_of_board?
scrooloose (author)
Sat Mar 08 16:21:24 -0800 2008
commit  2bf3f4e1580d6aef1cc0213a811fd9160c85d982
tree    c50d90a65772e37e05abef72e7d740c09e1bb177
parent  07ccdf23cabc790840bd01ec112a9b69f4d2098c
...
174
175
176
 
 
 
 
 
177
...
174
175
176
177
178
179
180
181
182
0
@@ -174,4 +174,9 @@ class Move
0
     rook.is_a?(Rook) && !rook.moved?
0
   end
0
 
0
+ def moving_to_end_of_board?
0
+ square.y == 0 && player.white? || square.y == 7 && player.black?
0
+ end
0
+
0
+
0
 end
...
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
26
...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -21,6 +21,21 @@ module MoveHelpers
0
       b.pieces << black_rook
0
 
0
       white_rook.move_for(Square.new(5,6))
0
+ when :white_gets_new_queen
0
+ b = Game.new.board
0
+ b.pieces.clear
0
+ b.pieces << King.new(Square.new(4,7), Player.white, b)
0
+ b.pieces << King.new(Square.new(0,7), Player.black, b)
0
+ b.pieces << pawn = Pawn.new(Square.new(0,1), Player.white, b)
0
+ pawn.move_for(Square.new(0,0))
0
+ when :black_gets_new_queen
0
+ b = Game.new.board
0
+ b.pieces.clear
0
+ b.pieces << King.new(Square.new(4,7), Player.white, b)
0
+ b.pieces << King.new(Square.new(0,7), Player.black, b)
0
+ b.pieces << pawn = Pawn.new(Square.new(0,6), Player.black, b)
0
+ pawn.move_for(Square.new(0,7))
0
     end
0
+
0
   end
0
 end
...
85
86
87
 
 
 
 
 
 
 
 
 
 
88
...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
0
@@ -85,4 +85,14 @@ describe Move do
0
     b.king_for(Player.white).move_for(Square.new(6,7)).castle?.should be
0
   end
0
 
0
+ it "should return true for #moving_to_end_of_board? when black moves to the end" do
0
+ m = moves(:black_gets_new_queen)
0
+ m.moving_to_end_of_board?.should be
0
+ end
0
+
0
+ it "should return true for #moving_to_end_of_board? when white moves to the end" do
0
+ m = moves(:white_gets_new_queen)
0
+ m.moving_to_end_of_board?.should be
0
+ end
0
+
0
 end

Comments

    No one has commented yet.