You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Then it can have a method for each section of code below.
53
53
@@ -171,7 +171,7 @@ function import_fen($fen) {
171
171
}
172
172
}
173
173
174
-
functionexport_fen() {
174
+
functionexport_fen(): string {
175
175
$string = '';
176
176
177
177
// A chessboard looks like this
@@ -250,7 +250,7 @@ function export_fen() {
250
250
}
251
251
252
252
// Keeping this for debug reasons.
253
-
functionget_ascii_board() {
253
+
functionget_ascii_board(): string {
254
254
$string = '';
255
255
256
256
if ( $this->color_to_move == ChessPiece::WHITE ) {
@@ -284,7 +284,7 @@ function get_ascii_board() {
284
284
return$string;
285
285
}
286
286
287
-
functionget_graphical_board() {
287
+
functionget_graphical_board(): array {
288
288
// We need to throw some variables into an array so our view can build the board.
289
289
// The array shall be in the following format:
290
290
// square_color = black / white
@@ -325,7 +325,7 @@ function get_graphical_board() {
325
325
return$graphical_board_array;
326
326
}
327
327
328
-
functionget_side_to_move_string() {
328
+
functionget_side_to_move_string(): string {
329
329
$string = '';
330
330
331
331
if ( $this->color_to_move == ChessPiece::WHITE ) {
@@ -337,7 +337,7 @@ function get_side_to_move_string() {
337
337
return$string;
338
338
}
339
339
340
-
functionget_who_is_winning_string() {
340
+
functionget_who_is_winning_string(): string {
341
341
$points = 0;
342
342
343
343
foreach ( $this->boardas$value1 ) {
@@ -358,21 +358,21 @@ function get_who_is_winning_string() {
358
358
}
359
359
}
360
360
361
-
functioninvert_rank_or_file_number($number) {
361
+
functioninvert_rank_or_file_number(int$number): int {
362
362
// 1 => 8
363
363
// 2 => 7
364
364
// etc.
365
365
366
366
return9 - $number;
367
367
}
368
368
369
-
functionnumber_to_file($number) {
369
+
functionnumber_to_file(int$number) {
370
370
returnself::FILE_NUMS_AND_LETTERS[$number];
371
371
}
372
372
373
373
// Note: This does not check for and reject illegal moves. It is up to code in the ChessGame class to generate a list of legal moves, then only make_move those moves.
374
374
// In fact, sometimes make_move will be used on illegal moves (king in check moves), then the illegal moves will be deleted from the list of legal moves in a later step.
0 commit comments