Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the notices that are thrown when loading an invalid FEN #33

Closed
programarivm opened this issue Sep 18, 2021 · 4 comments
Closed

Fix the notices that are thrown when loading an invalid FEN #33

programarivm opened this issue Sep 18, 2021 · 4 comments
Assignees
Labels
bug Something isn't working hacktoberfest

Comments

@programarivm
Copy link
Member

The chess server will complain with the following PHP notices after trying to load foo as a FEN string:

figure-01

$ php cli/ws-server.php 
Welcome to PHP Chess Server
Commands available:
/accept {"id":"id"} Accepts a friend request to play a game.
/ascii Prints the ASCII representation of the game.
/castling Gets the castling status.
/captures Gets the pieces captured by both players.
/fen Prints the FEN string representation of the game.
/heuristicpicture Takes a balanced heuristic picture of the current game.
/history The current game's history.
/ischeck Finds out if the game is in check.
/ismate Finds out if the game is over.
/piece {"position":"string"} Gets a piece by its position on the board.
/pieces {"color":["w","b"]} Gets the pieces on the board by color.
/playfen {"fen":"string"} Plays a chess move in shortened FEN format.
/quit Quits a game.
/start {"mode":["analysis","loadfen","playfriend"],"fen":"string","color":["w","b"],"min":"int"} Starts a new game.
/status The current game status.

Listening to commands...
PHP Notice:  Undefined offset: 2 in /home/standard/projects/chess-server/vendor/chesslablab/php-chess/src/FEN/StringToBoard.php on line 89
PHP Notice:  Undefined offset: 2 in /home/standard/projects/chess-server/vendor/chesslablab/php-chess/src/FEN/StringToBoard.php on line 95
PHP Notice:  Undefined offset: 2 in /home/standard/projects/chess-server/vendor/chesslablab/php-chess/src/FEN/StringToBoard.php on line 95
PHP Notice:  Undefined offset: 1 in /home/standard/projects/chess-server/vendor/chesslablab/php-chess/src/FEN/StringToBoard.php on line 52
PHP Notice:  Undefined offset: 2 in /home/standard/projects/chess-server/vendor/chesslablab/php-chess/src/FEN/StringToBoard.php on line 52
PHP Notice:  Undefined offset: 3 in /home/standard/projects/chess-server/vendor/chesslablab/php-chess/src/FEN/StringToBoard.php on line 52
@programarivm programarivm added the bug Something isn't working label Sep 18, 2021
@programarivm programarivm changed the title Fix the notices that are thrown when loading an invalid FEN string Fix the notices that are thrown when loading an invalid FEN Sep 18, 2021
@bofalke
Copy link

bofalke commented Oct 6, 2021

Hi there, happy learning and coding!

How should this errors be handled? Do you want a special exception to be thrown when an invalid FEN is entered?

@programarivm
Copy link
Member Author

programarivm commented Oct 6, 2021

It seems as if the StringToBoard.php class should be fine tuned in order to fix the issue. Not too clear about throwing an exception on this occasion.

@programarivm
Copy link
Member Author

programarivm commented Oct 6, 2021

Well, if that's the case and if I'm not very much mistaken a new issue should be opened in the chesslablab/php-chess repo.

@programarivm
Copy link
Member Author

Merged PR chesslablab/php-chess#86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants