|
@@ -300,10 +300,10 @@ discard block |
|
|
block discarded – undo |
|
300
|
300
|
|| ('-' != $this->gamestate['fen_en_passant_target_square'] && 6 == $this->gamestate['fen_en_passant_target_square'][1] && 'w' != $this->gamestate['fen_active_color'])) { |
|
301
|
301
|
return _MD_CHESS_FENBAD_EP_COLOR; // en passant target square wrong color |
|
302
|
302
|
} elseif ('-' != $this->gamestate['fen_en_passant_target_square'] && 3 == $this->gamestate['fen_en_passant_target_square'][1] |
|
303
|
|
- && 'wP' != $this->board[$this->boardCoordToIndex($this->gamestate['fen_en_passant_target_square'][0] . '4')]) { |
|
|
303
|
+ && 'wP' != $this->board[$this->boardCoordToIndex($this->gamestate['fen_en_passant_target_square'][0].'4')]) { |
|
304
|
304
|
return _MD_CHESS_FENBAD_EP_NO_PAWN; // en passant target square for nonexistent pawn |
|
305
|
305
|
} elseif ('-' != $this->gamestate['fen_en_passant_target_square'] && 6 == $this->gamestate['fen_en_passant_target_square'][1] |
|
306
|
|
- && 'bP' != $this->board[$this->boardCoordToIndex($this->gamestate['fen_en_passant_target_square'][0] . '5')]) { |
|
|
306
|
+ && 'bP' != $this->board[$this->boardCoordToIndex($this->gamestate['fen_en_passant_target_square'][0].'5')]) { |
|
307
|
307
|
return _MD_CHESS_FENBAD_EP_NO_PAWN; // en passant target square for nonexistent pawn |
|
308
|
308
|
} |
|
309
|
309
|
|
|
@@ -1876,7 +1876,7 @@ discard block |
|
|
block discarded – undo |
|
1876
|
1876
|
if ('P' == $fig_type && 16 == \abs($fig_pos - $dest_pos)) { |
|
1877
|
1877
|
$file_chars = 'abcdefgh'; |
|
1878
|
1878
|
|
|
1879
|
|
- $this->gamestate['fen_en_passant_target_square'] = $file_chars[$fig_pos % 8] . ('w' == $cur_player ? '3' : '6'); |
|
|
1879
|
+ $this->gamestate['fen_en_passant_target_square'] = $file_chars[$fig_pos % 8].('w' == $cur_player ? '3' : '6'); |
|
1880
|
1880
|
} else { |
|
1881
|
1881
|
// clear 'en passant' |
|
1882
|
1882
|
|
|
@@ -1904,7 +1904,7 @@ discard block |
|
|
block discarded – undo |
|
1904
|
1904
|
|
|
1905
|
1905
|
$this->board[$dest_pos] = "$cur_player$pawn_upg"; |
|
1906
|
1906
|
|
|
1907
|
|
- $result .= ' ... ' . $this->move_msg(_MD_CHESS_MOVE_PROMOTED, $this->getFullFigureName($pawn_upg)); |
|
|
1907
|
+ $result .= ' ... '.$this->move_msg(_MD_CHESS_MOVE_PROMOTED, $this->getFullFigureName($pawn_upg)); |
|
1908
|
1908
|
} |
|
1909
|
1909
|
} |
|
1910
|
1910
|
|
|
@@ -1933,27 +1933,27 @@ discard block |
|
|
block discarded – undo |
|
1933
|
1933
|
|
|
1934
|
1934
|
$history_move .= '#'; |
|
1935
|
1935
|
|
|
1936
|
|
- $result .= ' ... ' . _MD_CHESS_MOVE_CHECKMATE; |
|
|
1936
|
+ $result .= ' ... '._MD_CHESS_MOVE_CHECKMATE; |
|
1937
|
1937
|
} else { |
|
1938
|
1938
|
$history_move .= '+'; |
|
1939
|
1939
|
} |
|
1940
|
1940
|
} elseif ($this->isStaleMate($cur_opp, $cur_player)) { |
|
1941
|
1941
|
$this->gamestate['pgn_result'] = '1/2-1/2'; |
|
1942
|
1942
|
|
|
1943
|
|
- $result .= ' ... ' . _MD_CHESS_MOVE_STALEMATE; |
|
|
1943
|
+ $result .= ' ... '._MD_CHESS_MOVE_STALEMATE; |
|
1944
|
1944
|
|
|
1945
|
1945
|
$comment = _MD_CHESS_DRAW_STALEMATE; |
|
1946
|
1946
|
} elseif ($this->insufficient_mating_material()) { |
|
1947
|
1947
|
$this->gamestate['pgn_result'] = '1/2-1/2'; |
|
1948
|
1948
|
|
|
1949
|
|
- $result .= ' ... ' . _MD_CHESS_MOVE_MATERIAL; |
|
|
1949
|
+ $result .= ' ... '._MD_CHESS_MOVE_MATERIAL; |
|
1950
|
1950
|
|
|
1951
|
1951
|
$comment = _MD_CHESS_DRAW_NO_MATE; |
|
1952
|
1952
|
} |
|
1953
|
1953
|
|
|
1954
|
1954
|
// store possible castling-availability modification |
|
1955
|
1955
|
|
|
1956
|
|
- $KQkq = ($white_may_castle_short ? 'K' : '') . ($white_may_castle_long ? 'Q' : '') . ($black_may_castle_short ? 'k' : '') . ($black_may_castle_long ? 'q' : ''); |
|
|
1956
|
+ $KQkq = ($white_may_castle_short ? 'K' : '').($white_may_castle_long ? 'Q' : '').($black_may_castle_short ? 'k' : '').($black_may_castle_long ? 'q' : ''); |
|
1957
|
1957
|
|
|
1958
|
1958
|
$this->gamestate['fen_castling_availability'] = !empty($KQkq) ? $KQkq : '-'; |
|
1959
|
1959
|
|
|
@@ -1972,20 +1972,20 @@ discard block |
|
|
block discarded – undo |
|
1972
|
1972
|
$this->gamestate['pgn_movetext'] .= ' '; |
|
1973
|
1973
|
} |
|
1974
|
1974
|
|
|
1975
|
|
- $this->gamestate['pgn_movetext'] .= $this->gamestate['fen_fullmove_number'] . '.'; |
|
|
1975
|
+ $this->gamestate['pgn_movetext'] .= $this->gamestate['fen_fullmove_number'].'.'; |
|
1976
|
1976
|
// if black move, no moves yet, and game is setup, output move number with special '...' terminator |
|
1977
|
1977
|
} elseif (empty($this->gamestate['pgn_movetext']) && !empty($this->gamestate['pgn_fen'])) { |
|
1978
|
|
- $this->gamestate['pgn_movetext'] .= $this->gamestate['fen_fullmove_number'] . '...'; |
|
|
1978
|
+ $this->gamestate['pgn_movetext'] .= $this->gamestate['fen_fullmove_number'].'...'; |
|
1979
|
1979
|
} |
|
1980
|
1980
|
|
|
1981
|
1981
|
// update movetext |
|
1982
|
1982
|
|
|
1983
|
1983
|
// comment is added only for a concluded game |
|
1984
|
1984
|
|
|
1985
|
|
- $this->gamestate['pgn_movetext'] .= ' ' . $history_move . ' ' . $this->gamestate['pgn_result']; |
|
|
1985
|
+ $this->gamestate['pgn_movetext'] .= ' '.$history_move.' '.$this->gamestate['pgn_result']; |
|
1986
|
1986
|
|
|
1987
|
1987
|
if (!empty($comment)) { |
|
1988
|
|
- $this->gamestate['pgn_movetext'] .= ' {' . $comment . '}'; |
|
|
1988
|
+ $this->gamestate['pgn_movetext'] .= ' {'.$comment.'}'; |
|
1989
|
1989
|
} |
|
1990
|
1990
|
|
|
1991
|
1991
|
// if black move, increment move-number |
|
@@ -2100,9 +2100,9 @@ discard block |
|
|
block discarded – undo |
|
2100
|
2100
|
$coordinates = $this->boardIndexToCoord($i); |
|
2101
|
2101
|
|
|
2102
|
2102
|
if ('w' == $tile[0]) { |
|
2103
|
|
- $this->w_figures[] = $tile[1] . $coordinates; |
|
|
2103
|
+ $this->w_figures[] = $tile[1].$coordinates; |
|
2104
|
2104
|
} elseif ('b' == $tile[0]) { |
|
2105
|
|
- $this->b_figures[] = $tile[1] . $coordinates; |
|
|
2105
|
+ $this->b_figures[] = $tile[1].$coordinates; |
|
2106
|
2106
|
} |
|
2107
|
2107
|
} |
|
2108
|
2108
|
|
|
@@ -2144,7 +2144,7 @@ discard block |
|
|
block discarded – undo |
|
2144
|
2144
|
|
|
2145
|
2145
|
// Then replace each string of x's with the string length. |
|
2146
|
2146
|
|
|
2147
|
|
- $this->gamestate['fen_piece_placement'] = \preg_replace_callback('/(x+)/', static function($matches) {return \strlen($matches[1]);}, \implode('/', $rows)); |
|
|
2147
|
+ $this->gamestate['fen_piece_placement'] = \preg_replace_callback('/(x+)/', static function($matches) {return \strlen($matches[1]); }, \implode('/', $rows)); |
|
2148
|
2148
|
} |
|
2149
|
2149
|
|
|
2150
|
2150
|
/** |
|
@@ -2160,15 +2160,15 @@ discard block |
|
|
block discarded – undo |
|
2160
|
2160
|
|
|
2161
|
2161
|
$counts = \count_chars($pieces, 1); |
|
2162
|
2162
|
|
|
2163
|
|
- $num_queens = (int)@$counts[\ord('Q')]; |
|
|
2163
|
+ $num_queens = (int) @$counts[\ord('Q')]; |
|
2164
|
2164
|
|
|
2165
|
|
- $num_rooks = (int)@$counts[\ord('R')]; |
|
|
2165
|
+ $num_rooks = (int) @$counts[\ord('R')]; |
|
2166
|
2166
|
|
|
2167
|
|
- $num_bishops = (int)@$counts[\ord('B')]; |
|
|
2167
|
+ $num_bishops = (int) @$counts[\ord('B')]; |
|
2168
|
2168
|
|
|
2169
|
|
- $num_knights = (int)@$counts[\ord('N')]; |
|
|
2169
|
+ $num_knights = (int) @$counts[\ord('N')]; |
|
2170
|
2170
|
|
|
2171
|
|
- $num_pawns = (int)@$counts[\ord('P')]; |
|
|
2171
|
+ $num_pawns = (int) @$counts[\ord('P')]; |
|
2172
|
2172
|
|
|
2173
|
2173
|
return 0 == $num_queens && 0 == $num_rooks && ($num_bishops + $num_knights) <= 1 && 0 == $num_pawns; |
|
2174
|
2174
|
} |