File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,20 @@ public function testBlankBoardFen()
71
71
$ this ->assertEquals ('8/8/8/8/8/8/8/8 w KQkq - 1 1 ' , $ this ->game ->renderFen ());
72
72
}
73
73
74
+ public function testCastlingForbiddenIfNotRook ()
75
+ {
76
+ $ startFen = 'q3k2q/pbpqppbp/1pnp1np1/8/8/1PNP1NP1/PBPQPPBP/Q3K2Q w KQkq - 2 9 ' ;
77
+ $ this ->game ->resetGame ($ startFen );
78
+
79
+ $ this ->assertFalse ($ this ->game ->canCastleKingside ());
80
+ $ this ->assertFalse ($ this ->game ->canCastleQueenside ());
81
+
82
+ $ this ->game ->moveSAN ('e3 ' );
83
+
84
+ $ this ->assertFalse ($ this ->game ->canCastleKingside ());
85
+ $ this ->assertFalse ($ this ->game ->canCastleQueenside ());
86
+ }
87
+
74
88
public function testCastlingBlackFromTheKingSide ()
75
89
{
76
90
$ startFen = 'rnbqk2r/pppp1ppp/5n2/2b1p3/P1P1P1P1/8/1P1P1P1P/RNBQKBNR b KQkq a3 0 4 ' ;
Original file line number Diff line number Diff line change @@ -2200,16 +2200,16 @@ public function _parseFen($fen)
2200
2200
}
2201
2201
switch ($ splitFen [2 ][$ i ]) {
2202
2202
case 'K ' :
2203
- $ this ->_WCastleK = true ;
2203
+ $ this ->_WCastleK = $ this -> getPiece ( ' WR1 ' ) !== false ;
2204
2204
break ;
2205
2205
case 'Q ' :
2206
- $ this ->_WCastleQ = true ;
2206
+ $ this ->_WCastleQ = $ this -> getPiece ( ' WR2 ' ) !== false ;
2207
2207
break ;
2208
2208
case 'k ' :
2209
- $ this ->_BCastleK = true ;
2209
+ $ this ->_BCastleK = $ this -> getPiece ( ' BR1 ' ) !== false ;
2210
2210
break ;
2211
2211
case 'q ' :
2212
- $ this ->_BCastleQ = true ;
2212
+ $ this ->_BCastleQ = $ this -> getPiece ( ' BR2 ' ) !== false ;
2213
2213
break ;
2214
2214
default :
2215
2215
return $ this ->raiseError (self ::GAMES_CHESS_ERROR_FEN_CASTLEWRONG ,
You can’t perform that action at this time.
0 commit comments