Page 1 of 1

Informing players

Posted: 24 July 2020, 15:08
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

Re: Informing players

Posted: 24 July 2020, 16:32
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 789 times

Re: Informing players

Posted: 24 July 2020, 16:32
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

Re: Informing players

Posted: 24 July 2020, 17:31
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.".