Argument function and multiactive states

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

Argument function and multiactive states

Post by vincentt »

Hello,

I am going to try to resume my issue and hope that I am clear enough :)

I am working on DiceForge game (if you want to look at the code to have clearer understanding).

I have a chain of states that could be defined like that : blessing (active state) -> ressourceChoice (multiactive).
At the end of my blessing state, I activate all the users that needs to be active. This works correctly as when my JS enter the new state, in args, I do have the list of the various active players.
Then, in my arg function (called for ressourceChoice), I send back information if the user running the code is active. From the PHP side it looks like it works as I had put some "print" in the PHP and they were triggered, however, on the JS, my args.args are empty...

If I refresh the web page, my args.args is correctly filled-in and therefore the JS have the necessary information to follow.

Did you encounter this issue before? Do you have an idea as to why?

Thanks a lot for you help as I do not understand where is the issue :(

Regards

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

Re: Argument function and multiactive states

Post by Victoria_La »

You mean your js handler like onEnteringState or onUpdateActionButtons?

With multiactive state its tricky because when user becomes active it happens on previous state, when you press reload though you already in right state,
so onUpdateActionButtons usually misfires in this case. Unless you means something else by JS handler

There was this post long time ago

https://en.boardgamearena.com/#!forum/v ... =12&t=3637

I also posted one but I cannot find it...
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Argument function and multiactive states

Post by vincentt »

Hi Victoria,

Thank your for your reply.
I do not have an issue with the onUpdateActionsButtons but something else.

In my state, I call a argument function. In the PHP, the function fills the array with some information, however, in the JS it is not available (only when I have a state change). If I refresh the page, everything works :(

Please tell me if I am unclear!

Thanks a lot!

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

Re: Argument function and multiactive states

Post by Victoria_La »

Well args available only through the functions that carry state change events, where do you expect it be available?
One is onUpdateActionsButtons and another onEnteringState. What do you mean
by
In my state, I call a argument function.
?
You can also send your args as notification.
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Argument function and multiactive states

Post by vincentt »

Hi,

Sorry Victoria, I guess I am not clear.

My state is defined like that

Code: Select all

 STATE_RESSOURCE_CHOICE => array(
        "name"              => "ressourceChoice",
        "description"       => clienttranslate('Everyone choose the ressources'),
        "descriptionmyturn" => clienttranslate('${you} choose the ressources'),
        "type"              => "multipleactiveplayer",
        "args"              => "argsRessourceChoice",
        "action"            => "stRessourceChoice",
        "possibleactions"   => array('actRessourceChoice'),
        "transitions"       => array( "reinforcement" => STATE_REINFORCEMENT, "blessing" => STATE_BLESSING )
    )
So when I enter this state, I expect my argument function (argsRessourceChoice) to work on state change and on browser initialisation.

In my argument function I am doing that:

Code: Select all

    function argsRessourceChoice() {
        $player_id = self::getCurrentPlayerId();
        if (in_array($player_id, $this->gamestate->getActivePlayerList())) {
        ...
        return something
        }
        else return [];
In the PHP side, if I put a print('test') in my If statement, it is displayed therefore I can conclude that it works. However, the args in the JS is empty.

My codeveloper has made a workaround where we send the information for all the players and we filter it in the JS but I find this not optimum.

Thanks a lot and if I am still unclear, I will bury the subject :)

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

Re: Argument function and multiactive states

Post by Victoria_La »

The only question I have is where are you reading it on JS side!
Can you give me print from JS side that prints arguments. I already mention the only two functions
that accept args are onUpdateActionButton and onEnteringState is this in one of those? They have some issue with multistateactive
states
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Argument function and multiactive states

Post by vincentt »

Ok sorry :)

Yes I was reading it on onEnteringState.
When I made a console.debug(args.args), it was empty :(

I don't have the print anymore as we have updated the code. I could try to rollback to get it. It will let you know, but if there are issues on multiactive (from your experience) Yes I would like to know!)

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

Re: Argument function and multiactive states

Post by Victoria_La »

When you return [] from the php, add something to it, i.e. return ['status'=>'no active players'], so you know it was your args but
another branch of it.
I suspect it entering state in some way that don't expect (such as without active players or something ). Also print the state name.
You have state action stRessourceChoice it maybe entering the state before this function is called, so you active player is different,
and add debug in onUpdateActionButtons (print args there too), because that one will be called when active player changes.
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Argument function and multiactive states

Post by vincentt »

Hi,

Thanks a lot.
I did change where I put my players multiactive and it looked like it worked better.
I suppose it came from that :)

Anyway thanks a lot!

Vincent
Post Reply

Return to “Developers”