Handle buttons on actions - best practices

Game development with Board Game Arena Studio
Post Reply
User avatar
AndreaGot
Posts: 13
Joined: 28 November 2016, 20:55

Handle buttons on actions - best practices

Post by AndreaGot »

I started my first small project yesterday, based on the Reversi tutorial, and I would like to apply some changes to the basic gameplay.

I would like to show two buttons after choosing an available cell, asking the player to select the colour of the token they want to place:
What is the common workflow in order to achieve this behaviour?

I see that the buttons need to be added in onUpdateActionButtons() function, but I don't understand how to show them when a specific condition is met (in this case, just after a click on a cell). Colour is just a variable to be set before the onPlayDisc() function since it's the only thing that changes between the two options.

Do I have to setup 2 different states (one for choosing the cell and another for the colour selection) or is it feasible in just one state?
Image
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: Handle buttons on actions - best practices

Post by robinzig »

AndreaGot wrote: 18 January 2022, 17:16 I started my first small project yesterday, based on the Reversi tutorial, and I would like to apply some changes to the basic gameplay.

I would like to show two buttons after choosing an available cell, asking the player to select the colour of the token they want to place:
What is the common workflow in order to achieve this behaviour?

I see that the buttons need to be added in onUpdateActionButtons() function, but I don't understand how to show them when a specific condition is met (in this case, just after a click on a cell). Colour is just a variable to be set before the onPlayDisc() function since it's the only thing that changes between the two options.

Do I have to setup 2 different states (one for choosing the cell and another for the colour selection) or is it feasible in just one state?
Yes you want 2 states, but one can be a "client state" - ie just handled in your Javascript file, without any mention in the states PHP file or the other players being aware of any state change. You will find documentation on client states in the Studio docs/wiki.
Post Reply

Return to “Developers”