Multiactive state and JS triggering

Game development with Board Game Arena Studio
Post Reply
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Multiactive state and JS triggering

Post by vincentt »

Hi,

I hope that someone will be able to help me because I am pulling my hair out :(

In my game, Dice Forge, I have a state called RessourceChoice where we ask specific users to choose some ressource. One of the side is specific (mirror) and therefore before choosing the ressource, the user needs to select a side on one of the visible die.

I have managed this exception inside the same state RessourceChoice but add a previous step before.
When I have only one user that need to make the choice, it is working, however, when two users have a choice to make (user 1 : mirror, user 2: gold), when user 2 makes his choice, automatically my action buttons and everything disappears.

You can see it happening here : http://en.1.studio.boardgamearena.com/d ... ayFrom=126 (I am not sure that other users can view it but hell let's try it :))

I am guessing this happen due to the reception of a notification or the use of the updateCounters method, but I do not understand why...

Here is the notification log

Code: Select all

< gameStateMultipleActiveUpdate
["2305535"]
< updateCounters
{"goldcount_p2305529":{"counter_name":"goldcount_p2305529","counter_value":"7"},"mooncount_p2305529":{"counter_name":"mooncount_p2305529","counter_value":"6"},"firecount_p2305529":{"counter_name":"firecount_p2305529","counter_value":"2"},"hammercount_p2305529":{"counter_name":"hammercount_p2305529","counter_value":"3"},"player_score_2305529":{"counter_name":"player_score_2305529","counter_value":"41"},"goldcount_p2305531":{"counter_name":"goldcount_p2305531","counter_value":"8"},"mooncount_p2305531":{"counter_name":"mooncount_p2305531","counter_value":"5"},"firecount_p2305531":{"counter_name":"firecount_p2305531","counter_value":"3"},"player_score_2305531":{"counter_name":"player_score_2305531","counter_value":"40"},"goldcount_p2305535":{"counter_name":"goldcount_p2305535","counter_value":"7"},"mooncount_p2305535":{"counter_name":"mooncount_p2305535","counter_value":"1"},"firecount_p2305535":{"counter_name":"firecount_p2305535","counter_value":"3"},"hammercount_p2305535":{"counter_name":"hammercount_p2305535","counter_value":"0"},"player_score_2305535":{"counter_name":"player_score_2305535","counter_value":"24"}}
< notifBlessing
{"player_id":2305531,"gold":0,"moonshard":0,"vp":2,"hammer":0,"fireshard":0}
< end_replaywaitingdelay
{}
< replaywaitingdelay
{}
< gameStateChange
{"name":"ressourceChoice","description":"Everyone choose the ressources","descriptionmyturn":"${you} choose the ressources","type":"multipleactiveplayer","args":{"2305531":{"sides":{"1":{"id":"24","type":"G3orV2","type_arg":"0","location":"dice2-p2305531","location_arg":"0"}},"allMirror":false,"mirror":0},"2305535":{"sides":[{"id":"42","type":"mirror","type_arg":"0","location":"dice1-p2305535","location_arg":"0"},{"id":"21","type":"G3orV2","type_arg":"0","location":"dice2-p2305535","location_arg":"0"}],"allMirror":false,"mirror":1}},"action":"stRessourceChoice","possibleactions":["actRessourceChoice"],"transitions":{"reinforcement":6,"blessing":4},"active_player":"2305529","reflexion":{"move":{"value":240,"total":240},"total":{"2305529":"-80773","2305531":"-1562","2305535":"-3916"}},"multiactive":["2305531","2305535"]}
< gameStateMultipleActiveUpdate
["2305531","2305535"]
< updateCounters
{"goldcount_p2305529":{"counter_name":"goldcount_p2305529","counter_value":"7"},"mooncount_p2305529":{"counter_name":"mooncount_p2305529","counter_value":"6"},"firecount_p2305529":{"counter_name":"firecount_p2305529","counter_value":"2"},"hammercount_p2305529":{"counter_name":"hammercount_p2305529","counter_value":"3"},"player_score_2305529":{"counter_name":"player_score_2305529","counter_value":"41"},"goldcount_p2305531":{"counter_name":"goldcount_p2305531","counter_value":"8"},"mooncount_p2305531":{"counter_name":"mooncount_p2305531","counter_value":"5"},"firecount_p2305531":{"counter_name":"firecount_p2305531","counter_value":"3"},"player_score_2305531":{"counter_name":"player_score_2305531","counter_value":"38"},"goldcount_p2305535":{"counter_name":"goldcount_p2305535","counter_value":"7"},"mooncount_p2305535":{"counter_name":"mooncount_p2305535","counter_value":"1"},"firecount_p2305535":{"counter_name":"firecount_p2305535","counter_value":"3"},"hammercount_p2305535":{"counter_name":"hammercount_p2305535","counter_value":"0"},"player_score_2305535":{"counter_name":"player_score_2305535","counter_value":"24"}}
< notifBlessing
{"player_id":2305535,"vp":0,"gold":0,"moonshard":0,"fireshard":0,"hammer":0,"dice1":"mirror","dice2":"G3orV2"}
< notifBlessing
{"player_id":2305531,"vp":3,"gold":0,"moonshard":0,"fireshard":0,"hammer":0,"dice1":"V3","dice2":"G3orV2"}
< notifBlessing
{"player_id":2305529,"vp":3,"gold":0,"moonshard":2,"fireshard":0,"hammer":0,"dice1":"V3","dice2":"MS2"}
< gameStateChange
{"name":"divineBlessing","description":"Everyone rolls their dice","descriptionmyturn":"${you} roll your dice","type":"game","action":"stBlessing","transitions":{"reinforcement":6,"ressourceChoice":5,"blessing":4},"active_player":"2305529","args":null,"reflexion":{"move":{"value":240,"total":240},"total":{"2305529":-80773,"2305531":"-1562","2305535":"-3916"}}}
The first notifBlessing (or updateCounters as they are immediate) change my top bar.
Has anyone encountered this issue? I am afraid to here that the workaround would be to add a server state for this step because it will slow down the game (additional step for only some users).

Thanks a lot! And if I am not clear (on this I am pretty sure), do not hesitate!

Vincent
User avatar
Victoria_La
Posts: 607
Joined: 28 December 2015, 20:55

Re: Multiactive state and JS triggering

Post by Victoria_La »

Considering nobody jump in on last thread I assume nobody knows, what I recommend is NOT use server states for short
interactions, i.e if your user has to
* click on action
* select resources
* select place where it goes
* pick a side of tile

Its only one server state, and the collection is handled with client states.
http://en.doc.boardgamearena.com/BGA_St ... ent_States
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Multiactive state and JS triggering

Post by vincentt »

Hi Victoria,

Thank you for your answer.
This is what I did.
In fact I have my server state ressourceChoice that will trigger the client state chooseRessource. For the choice of the mirror, I have not defined a client state for that. You are thinking that if I use a client state I should not have those issues?

I suppose that I am doing something not authorized where I am changing the banner with : $('pagemaintitletext').innerHTML. For this part I could understand, however for the action buttons (created through the method onUpdateActionButtons) I do not understand... :(

If nobody has another idea, I will try to implement a client state, but it would be soooooo much easier if someone had a magic answer! :D

Anyway thanks a lot!

Vincent
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Multiactive state and JS triggering

Post by vincentt »

Hi,

So i have made other tests and with addtionnal debug, I see that onUpdateActionButtons is triggered when we receive a notification (or at least a multiactive one).
I have compared the received args, they are indeed the same.

The only thing that I see that could be the issue for my problem is that, on state change, the method onUpdateActionButtons is triggered and afterwards the method onEnteringState is triggered.
When the notification is received, only the onUpdateActionButtons is triggered and maybe it is resetting other things?

Did any of you encountered this issue? Maybe the big boss has an explanation on this thing...

Thanks a lot for your inputs!

Vincent
User avatar
quietmint
Posts: 262
Joined: 31 July 2017, 00:28

Re: Multiactive state and JS triggering

Post by quietmint »

I think this is a known behavior/"feature". I did not expect it either, but onUpdateActionButtons is definitely called by the framework multiple times during same state. After I discovered this the hard way myself, I saw something on the forums that explicitly mentions it. Basically, just plan that onUpdateActionButtons will be called multiple times, specifically when other players in multiactive state take an action.

Found the post: https://en.boardgamearena.com/#!forum/v ... =12&t=3637
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Multiactive state and JS triggering

Post by vincentt »

Thanks Quietmind!
I understand but then I do not understand my bug :(
My method onUpdateActionButtons only create buttons (based on the args). However when it is triggered, it reset my buttons and my status bar text.

Thanks!

Vincent
User avatar
Victoria_La
Posts: 607
Joined: 28 December 2015, 20:55

Re: Multiactive state and JS triggering

Post by Victoria_La »

vincentt wrote:Thanks Quietmind!
I understand but then I do not understand my bug :(
My method onUpdateActionButtons only create buttons (based on the args). However when it is triggered, it reset my buttons and my status bar text.

Thanks!

Vincent
Yes it clears off the buttons and state text, you have to reset it yourself to values you need. Its called when players are become active or inactive
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Multiactive state and JS triggering

Post by vincentt »

Hi,

Great thanks a lot. Now I understand and issue corrected :)

Thanks!
Post Reply

Return to “Developers”