Reversi Tutorial Cannot switch to active player

Game development with Board Game Arena Studio
Post Reply
User avatar
UnoWho24-7
Posts: 3
Joined: 20 September 2024, 09:26

Reversi Tutorial Cannot switch to active player

Post by UnoWho24-7 »

Hi there,

I'm new to all this, but am working my way through the Reversi tutorial. I'm up to the Implementing player action (not yet implemented though).

The board loads fine and shows the possibleMoves, but is always on the White player with the "other player must take action" message. Here's where I'm stuck -- when I click the little arrow next to the other player to activate the game as that other player, the board will not load.

I've put the present state of the project on Github https://github.com/UnoWho247/bga-tutori ... ryExisting[/url]. Can someone help me identify why I cannot activate the board as the active player? It just gets stuck on the "Loading Game Art (10%)" ...
User avatar
RicardoRix
Posts: 2540
Joined: 29 April 2012, 23:43

Re: Reversi Tutorial Cannot switch to active player

Post by RicardoRix »

Try opening the developer console F12. It should show an error message of some kind.

In the JS setup() function try putting a debugger; statement to help you single step your code.
User avatar
zetaLeonis
Posts: 14
Joined: 08 September 2024, 05:42

Re: Reversi Tutorial Cannot switch to active player

Post by zetaLeonis »

Sadly I can't run your code easily without completely rewriting and breaking one of my projects. As RicardoRix said, when you get stuck on the "loading box art" screen, you're probably having a frontend issue.

Press F12 in your browser, go to the "console" tab, and refresh the page (shift + F5) and try to see if there's any errors.

Usually it's some sort of illegal operation or a typo on your .js file probably something here https://github.com/UnoWho247/bga-tutori ... reversi.js

If you're really really stuck, add me as collaborator and I will try to run and debug the project. But only do that as last measure since I don't have much free time.
User avatar
zetaLeonis
Posts: 14
Joined: 08 September 2024, 05:42

Re: Reversi Tutorial Cannot switch to active player

Post by zetaLeonis »

Sorry, I just realize you have a versioned project. Silly me.

Simply go back one commit (`git reset HEAD~1`), remove any pending changes (`git clean -df`), upload the files and see if it works.

IF it works, you definitely did something wrong in the last commit. In that case, going forward try to apply small changes, upload, refresh and see if it works and only then commit (when it's stable).

I know it's a tedious process but it guarantees stability.
User avatar
UnoWho24-7
Posts: 3
Joined: 20 September 2024, 09:26

Re: Reversi Tutorial Cannot switch to active player

Post by UnoWho24-7 »

RicardoRix wrote: 13 November 2024, 22:20 Try opening the developer console F12. It should show an error message of some kind.

In the JS setup() function try putting a debugger; statement to help you single step your code.
zetaLeonis wrote: 13 November 2024, 23:03 Sadly I can't run your code easily without completely rewriting and breaking one of my projects. As RicardoRix said, when you get stuck on the "loading box art" screen, you're probably having a frontend issue.

Press F12 in your browser, go to the "console" tab, and refresh the page (shift + F5) and try to see if there's any errors.

Usually it's some sort of illegal operation or a typo on your .js file probably something here https://github.com/UnoWho247/bga-tutori ... reversi.js

If you're really really stuck, add me as collaborator and I will try to run and debug the project. But only do that as last measure since I don't have much free time.

Thanks! I have very little frontend experience, so it didn't even occur to me to look for errors within the developer console lol. Definitely getting some errors from the javascript code file (looks like I left some template stuff in there)... I'll work on cleaning that up. :)
User avatar
UnoWho24-7
Posts: 3
Joined: 20 September 2024, 09:26

Re: Reversi Tutorial Cannot switch to active player

Post by UnoWho24-7 »

Sure enough! removing the

Code: Select all

onUpdateActionButtons
function from the template solved this problem (had references to card objects not implemented). :) Thanks for the help!
User avatar
RicardoRix
Posts: 2540
Joined: 29 April 2012, 23:43

Re: Reversi Tutorial Cannot switch to active player

Post by RicardoRix »

You need that function. Just comment out the offending lines.
User avatar
zetaLeonis
Posts: 14
Joined: 08 September 2024, 05:42

Re: Reversi Tutorial Cannot switch to active player

Post by zetaLeonis »

As RicardoRix said, you will need that function.

There's a silver lining here, you now get to learn how to debug :mrgreen: assuming you're using chrome, here's a detailed explanation:

1.- Place a `debugger;` statement at the first line of the function you know it's causing the issue, this will act as a breakpoint.
2.- Save the file and upload it (wait a few seconds). Open the developer tools (F12) and refresh the page with the game running.
3.- The dev tools will automatically go to the "source" tab and you will experiment what it's called "execution halt" (basically the code is paused at the line where you put the debugger statement) now you can use multiple tools to debug your code. The most simple tools are the "Resume script" and "Step over next function call", look for a small rectangle that says "Paused in Debugger" with two buttons. Pressing the second one will let you go line by line (you can also press F10 as shortcut), go line by line until you find the faulty block or line of code, and then simply comment that in your code.

Note there's more tips in the debugging section of the docs (see here https://en.doc.boardgamearena.com/Practical_debugging) but in some cases they are really old (for example the firebug recommendation was before firefox had developer tools, and that was around ~2017!)

Chrome dev tools are comprehensive I suggest investing some time in playing with it (or if you're a nerd like me, just read the docs https://developer.chrome.com/docs/devtools/javascript) it will really help you be a better developer.

Anyways, glad that you could find the issue, cheers and good luck.
Post Reply

Return to “Developers”