Page 1 of 1

Implementing multi-stage secret action

Posted: 03 October 2020, 21:17
by salty-horse
The game I'm working on, Mottainai, has a flow similar to Race for the Galaxy.
On a turn you can "build" a card by "paying" for it from your hand.

The player needs to provide me with several pieces of information before I'm willing to reveal the results to the other players:
1) Which build type they wish to make.
2) Which card they wish to build.
3) Which cards they wish to use as payment.

It makes sense to me to do all these things on the client-side, only sending the full action to the server after the player made all the choices.
However, I have a few questions:
1) RFTG (from what I can gleam from its client-side implementation) involves the server somehow, but I'm not sure how. Apparently you first pick a card, then get a notification from the server regarding how much you need to pay. How is that implemented without informing the other players of a state change?
2) If I wish to implement everything in the client side, I would like to update the status bar with new text and buttons after each step, but in the BGA this seems "reserved" to the game state mechanism. Is it OK to force different values to appear in it?

Re: Implementing multi-stage secret action

Posted: 03 October 2020, 21:25
by Inaofr
I don't know for 1).
For 2), modifying the title bar (you call it status bar) is described in the BGA doc, see updatePageTitle() in http://en.doc.boardgamearena.com/Game_i ... eful_stuff.

Re: Implementing multi-stage secret action

Posted: 03 October 2020, 21:35
by salty-horse
Thanks. Very weird how the rest of the doc calls it a "status bar".
Also, removeActionButtons isn't documented.
Is there a way to discover more of these functions that's not through the wiki documentation?

Re: Implementing multi-stage secret action

Posted: 03 October 2020, 22:54
by Victoria_La
There are few ways to do that, document here in Multi Step Interactions

https://en.doc.boardgamearena.com/BGA_S ... _Selection

Regarding 1 you should send all possible moves in state args, if they secret make them private (see notification docs).
It possible to do server data request but its not officially supported/documentd, so just stick with documented stuff.

Re: Implementing multi-stage secret action

Posted: 03 October 2020, 23:09
by salty-horse
Thanks!

Re: Implementing multi-stage secret action

Posted: 09 January 2021, 20:38
by Hornir91
Victoria_La wrote: 03 October 2020, 22:54 There are few ways to do that, document here in Multi Step Interactions

https://en.doc.boardgamearena.com/BGA_S ... _Selection

Regarding 1 you should send all possible moves in state args, if they secret make them private (see notification docs).
It possible to do server data request but its not officially supported/documentd, so just stick with documented stuff.
Hello. I'm trying to implement client states for selecting a card and playing it through a button, but there is a problem. How can I send args needed for such a state? I'm getting error, because ${You} isn't provided (needed for 'descriptionmyturn') and I can't figure out a way to do it for this client state.

Also I can't do it with two server states (one for selecting card and one for generate buttons and send ajax call), because active state is a multipleplayer one and I would prefer just to sent ajax after all the operations in the client.

Re: Implementing multi-stage secret action

Posted: 09 January 2021, 21:00
by Tisaac
Are you sure it's not ${you } instead ?

Re: Implementing multi-stage secret action

Posted: 09 January 2021, 21:30
by Hornir91
Nope. I have something like this.

Code: Select all

        onCardClicked: function(e) {
            dojo.stopEvent(e);
            dojo.addClass(e.path[0].id, 'card_selected');
            this.setClientState('client_PlayerChooseCard', {
                "descriptionmyturn": "${You} must choose a card place",
            });
        },
And In client_PlayerChooseCard I have ofcourse buttons for ajax calls to send data to the server but I'm getting an error:
"Invalid or missing substitution argument for log message: ${You} must choose a card place error"

Re: Implementing multi-stage secret action

Posted: 09 January 2021, 21:34
by Hornir91
Heh, writing post above I've noticed that ${You} was typed with upper letter. With "you" it started working >.>

Re: Implementing multi-stage secret action

Posted: 09 January 2021, 23:53
by Tisaac
Hornir91 wrote: 09 January 2021, 21:34 Heh, writing post above I've noticed that ${You} was typed with upper letter. With "you" it started working >.>
That's precisely what I meant ;)