Reversi tutorial - error on the test the token step

Game development with Board Game Arena Studio
Post Reply
User avatar
diffy
Posts: 2
Joined: 16 June 2020, 00:42

Reversi tutorial - error on the test the token step

Post 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!
User avatar
diffy
Posts: 2
Joined: 16 June 2020, 00:42

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

Post 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?
PanzerLeader
Posts: 2
Joined: 02 December 2025, 19:04

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

Post 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).
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

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

Post 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()
Post Reply

Return to “Developers”