Informing players

Game development with Board Game Arena Studio
Post Reply
User avatar
xtyner
Posts: 2
Joined: 14 May 2020, 12:29

Informing players

Post by xtyner »

Hey,

I am currently working on my first project here and I am about to get used to Studio.
The question that I have is how to inform the player about a mistake that they made. Specifically in my game the player should select exactly one card and then hit a button (one of some options).
If they select none or multiple card, I want to tell them to not do that. (I solved the issue by selecting exactly one card a time and unselecting the previous. But I am more curious about general solutions.)

The ways that I know is to put
alert("My message")
in javascript ("mygame.js"). Positive about this is that the server is not involved in the process. Negative is the ugly window and the fact that I find it very penetrative.
Also working is to call for PHP and
throw Exception("My message")
there. Or especially BgaUserException. But I am not familiar with other Exceptions that are implemented on BGA.

What would you do to inform players? Are there nice Exceptions or javascript-based ways, that I am not aware of?s
User avatar
paramesis
Posts: 398
Joined: 28 April 2020, 05:00

Re: Informing players

Post by paramesis »

I agree with you about alert messages, and would go further to say that the interface shouldn't punish users with big red errors for doing something that the interface allowed them to do.

I have never seen an alert window used in any implementations and would strongly advise against it (it would probably be rejected by admins). Throwing an Exception is more intended for a bug that "shouldn't ever happen" in the php side. A BgaUserException is the translatable exception that would be preferred to cancel the effect of a user action that the server side game logic has determined to be illegal. Cases like the one you mentioned would be better handled entirely in javascript.

If you're using a stock for selecting cards, you don't need to handle deselecting other options manually. Instead you can use the setSelectionMode method when setting it up. See here: http://en.doc.boardgamearena.com/Stock

My approach for handling cases that don't require extensive game logic this is to clearly describe what is expected (select 1 card) and grey out the action button and set pointer-events to none in CSS when that condition is not satisfied.
grey out option.png
grey out option.png (19.56 KiB) Viewed 784 times
Last edited by paramesis on 24 July 2020, 16:38, edited 4 times in total.
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Informing players

Post by Tisaac »

The best way in my opinion would be to make the button clickable only if exactly one card is selected.
A bga user exception on the server side would also do the job if you dont want to duplicate the logic
User avatar
fafa-fr
Posts: 383
Joined: 22 December 2013, 21:58

Re: Informing players

Post by fafa-fr »

You can use this.showMessage( msg, type ) in JS to display an info or error message. See Game interface logic page in the Studio doc.

I think it's ok to use this when doing what paramesis says is not easy:
paramesis wrote: clearly describe what is expected (select 1 card) and grey out the action button and set pointer-events to none in CSS when that condition is not satisfied.
Sometimes I think it's better to explain players why it is not possible to do something than to let them with an unresponsive button / card / tile. Of course I agree that the first thing to do is to explain them in the action bar what they must do. But we can also correct them when they don't do what is expected. In this example, the instruction is simple and can be written right next to the button, so I agree that players that don't respect the instruction are really not paying attention. But it's not always that simple, so I wouldn't go as far as advising not to use error messages (BGA's ones, not alert), I don't see them as punishments, but as reminders. You can't write in the action bar long messages like "You can click a card, but only if you have enough resources to buy it, and if you didn't use etc.".
Post Reply

Return to “Developers”