How Are Actice Players Handled?

Game development with Board Game Arena Studio
Post Reply
abkan
Posts: 5
Joined: 08 March 2020, 20:55

How Are Actice Players Handled?

Post by abkan »

I finished the BGA Studio reversi tutorial, and there is one aspect that really confuses me.

When I run my game, if I try to place a piece when it is not my turn, there is a warning saying "It is not your turn". However, this was never coded in the tutorial. In fact, there is no distinction made in the front end at all between the active player. So my question is, how does BGA know that I am not the active player, and is there any way to modify this warning to day something other than "It is not your turn"? Also, is there a way to have multiple active players (for simultaneous games like Sushi Go).

My best guess is that when the client calls bgaPerformAction(), they receive this warning if they are not listed as the active player, but I am not sure if I am correct here.
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: How Are Actice Players Handled?

Post by RicardoRix »

Yes.
The BGA framework provides various automations for you. Also there are helper CheckAction functions for both client(js) and server(php), they will bring up similar red error message banners.

Take a look at the states for multiplayer / single player.
https://en.doc.boardgamearena.com/Your_ ... es.inc.php

Client side, you can if you like change the ability for the user to even click anything, or at-least stop the server call being made, so you could protect against that specific automated message. It's the server that knows who's turn it is and who's job it is to enforce that, or indeed any game logic.
There are a couple of client functions that are automatically called for you, like onEnteringState where you can setup whatever need. The simplest mechanism you could adopt is set a boolean flag that is then used to protect the non-playing user action from doing anything. Or there is also some helper functions like isCurrentPlayerActive().
https://en.doc.boardgamearena.com/Game_ ... _structure
Post Reply

Return to “Developers”