Page 1 of 1

updatePageTitle() ?

Posted: 09 June 2020, 09:48
by fafa-fr
Hi,
I'd like to know if it's possible to update descriptionmyturn (the string that tells players what they can or must do now) without changing state. This exists in some games, but it is not documented, so I'd like to have a confirmation, because it would be very convenient for many games!
Example :

Code: Select all

this.gamedatas.gamestate.descriptionmyturn = titleHtml;
this.updatePageTitle();

Re: updatePageTitle() ?

Posted: 09 June 2020, 12:57
by Quinarbre
Yes, it works just as in your example.
You can also build a complex description such as :

Code: Select all

this.gamedatas.gamestate.descriptionmyturn = dojo.string.substitute(_('${you} will score ${points}.<br/>'), {points:points, you:'${you}'} );
Don't forget the translation marks.

An interesting and related undocumented feature is the ability to change state on the client side :

Code: Select all

this.setClientState("someStateName", { "descriptionmyturn":_("${you} must play a piece or select a card") } );

Re: updatePageTitle() ?

Posted: 10 June 2020, 15:06
by MikeIsHere
I need this also -- when would I call this-- onEnteringState?

Re: updatePageTitle() ?

Posted: 10 June 2020, 18:19
by fafa-fr
Hi, thanks for your answer. I guess my post wasn't clear enough, my question wasn't "How does it work?", my question was "Is it possible (for us common developers) to use this even if it's not documented?" So it was more a question for the admins, but I posted it here because a lot of developers could be interested. I've been thinking of asking a confirmation for a long time, but this post made me finally do it.

Re: updatePageTitle() ?

Posted: 11 June 2020, 09:06
by docthib

Code: Select all

this.setClientState()
is widely used in projects you can use it.

There is a use case in Studio Cookbook (Multi Step Interactions: Select Worker/Place Worker - Using Client States)
http://en.doc.boardgamearena.com/BGA_Studio_Cookbook

Re: updatePageTitle() ?

Posted: 11 June 2020, 10:29
by fafa-fr
Yeah, for this one I wouldn't have worried too much, since Alena added it in the doc a long time ago. (Though I think it would be better if there was an official confirmation from the admins, because since they're very busy, we cannot be sure that they often read the Studio doc to see what other developers added.)
But concerning gamedatas.gamestate.descriptionmyturn and updatePageTitle(), there's nothing about it in the doc, so I think it would really be nice to have a confirmation.

Re: updatePageTitle() ?

Posted: 11 June 2020, 10:58
by Een
Documentation could definitely be better ^^
updatePageTitle() is used heavily in Terra Mystica, so if we break it, we break Terra Mystica. I think it's safe to confirm it.
I have quickly added it to the documentation : http://en.doc.boardgamearena.com/Game_i ... eful_stuff

Re: updatePageTitle() ?

Posted: 11 June 2020, 11:09
by fafa-fr
Thanks a lot! :)
same for setClientState() as described in BGA Studio Cookbook?

Re: updatePageTitle() ?

Posted: 11 June 2020, 11:13
by Een
No idea on that one. Never used it myself, sourisdudesert would have to confirm that. But as it has been heavily used by Victoria_La, breaking it would break multiple games too, so we probably will be careful not to break it ;)