Page 1 of 1

Reversi tutorial - error on the test the token step

Posted: 21 December 2025, 20:18
by diffy
Hi, I'm running the Reversi tutorial to wet my feet on the BGA Studio and got stuck on this issue. On the Test the Token step it says to insert this line of code in the setup function on modules/js/Game.js

Code: Select all

this.addDiscOnBoard(2, 2, this.player_id, false);
The issue is that this.player_id returns undefined, and at this stage of the tutorial I don't know how to get the player ID to pass to the addDiscOnBoard function.

Just want to know if it's me of the tutorial that is missing something. Thanks!

Re: Reversi tutorial - error on the test the token step

Posted: 21 December 2025, 20:32
by diffy
After looking into the this object I saw that there's a player_id under gameui, and using this.gameui.player_id seemed to fix the error. Can anyone confirm that this is the correct key to use or if another player_id that is stored somewhere else?

Re: Reversi tutorial - error on the test the token step

Posted: 22 December 2025, 03:27
by PanzerLeader
I recently finished the Reversi tutorial so I no longer have that sample statement "this.addDiscOnBoard(2, 2, this.player_id, false)" in my code, but you should be able to replace "this.player_id" with a 0 or 1 to pass in a hardcoded value (for testing).

Also, if you haven't done so, I suggest downloading the official BGA Reversi code so you can compare it to your code when the tutorial leaves you puzzled (once or twice for me).

Re: Reversi tutorial - error on the test the token step

Posted: 22 December 2025, 09:26
by thoun
Thanks for reporting this! The tutorial has been updated recently, and I missed this one. There is now a framework function to access to player id (with a correct typing, while this.player_id wasn't correctly typed) :

Code: Select all

this.bga.players.getCurrentPlayerId()