Page 1 of 1

Reversi: wrong formatted data

Posted: 12 January 2025, 04:59
by edward_green
Hello, I am new to BGA developer side and trying to follow the reversi tutorial. I successfully completed the front end section and had the board and single disc displayed. I'm attempting the next section (subtitled "The database"). When I attempt to start a game now, it doesn't do anything except for display this error message:

Unexpected error: Wrong formatted data from gameserver 1 (method: createGame): JSON_ERROR_SYNTAX
Warning: Undefined array key 1 in /var/tournoi/release/games/edsreversitutorial/999999-9999/modules/php/Game.php on line 288
{"status":1,"data":true} (reference: GS0 12/01 04:46:19)

I am quite certain I have the code correct from the 5 code sections that follow. (accessed database, creating the table in .sql, table was there in the test, initialize board in modules/php/Game.php, show initial token setup). I replaced the code I typed with code copied/pasted from the instructions. So far I have determined the line that causes the error is "list( $blackplayer_id, $whiteplayer_id ) = array_keys( $players );" in the board initialization. Which makes me think something is wrong with $players. Any pointers or advice would be appreciated.

Re: Reversi: wrong formatted data

Posted: 12 January 2025, 06:39
by xiongmao1298
If that's in fact the line that causes the issue, the $players array must have only a single element.
One cause that's easy to imagine without further context is that you're launching the game in Solo mode.

Re: Reversi: wrong formatted data

Posted: 12 January 2025, 15:17
by edward_green
You are right that the $players array has only one element, but I am definitely running it in two player mode.

Re: Reversi: wrong formatted data

Posted: 12 January 2025, 15:30
by edward_green
UPDATE: Its working now. All I had to do was set the 'players' value to [2] in gameinfos.inc.php. I guess somehow it was stuck on one player even though I'm sure I set it to two in the game setup? But that simple change did the trick. Thank you for the help!