Page 1 of 1

Is it possible to limit a game option to training mode?

Posted: 06 June 2021, 19:05
by User Already Exists
In Hex, there are game options for various board sizes: 6x6, 11x11, 14x14, etc.

Is there a way to limit the use the 6x6 option so that it can only be used in training mode?

Thanks, -- Peter

Re: Is it possible to limit a game option to training mode?

Posted: 06 June 2021, 20:04
by Tisaac
User Already Exists wrote: 06 June 2021, 19:05 In Hex, there are game options for various board sizes: 6x6, 11x11, 14x14, etc.

Is there a way to limit the use the 6x6 option so that it can only be used in training mode?

Thanks, -- Peter
I think you can use classic displaycondition filter with the following id :

Code: Select all

   'displaycondition' => [
     [
      'type' => 'otheroption',
      'id' => GAMESTATE_CLOCK_MODE,
      'value' => [0,1,2,9],
    ],
  ]
These values ([0,1,2,9])were used to filter "real time only" tables, so you will need to test a little bit to find the correct setting for your use case.
I found the values by looking at the "global" DB table differences when changing the mode from one to another one. (Or maybe you can look at the html for the "select" on the table page).

Re: Is it possible to limit a game option to training mode?

Posted: 06 June 2021, 21:44
by Een
Game clock mode is not the same thing as game rating mode (normal/training).

You can use a displaycondition or a startcondition with the game rating mode, for example for a startcondition:

Code: Select all

array(
                'type' => 'otheroption',
                'id' => 201,
                'value' => 1,
                'message' => totranslate('Training mode is required to play with this value')
            )

Re: Is it possible to limit a game option to training mode?

Posted: 06 June 2021, 23:49
by Tisaac
Een wrote: 06 June 2021, 21:44 Game clock mode is not the same thing as game rating mode (normal/training).

You can use a displaycondition or a startcondition with the game rating mode, for example for a startcondition:

Code: Select all

array(
                'type' => 'otheroption',
                'id' => 201,
                'value' => 1,
                'message' => totranslate('Training mode is required to play with this value')
            )
My bad, I never realized you could actually played a ranked game without time limit!

Re: Is it possible to limit a game option to training mode?

Posted: 07 June 2021, 00:42
by User Already Exists
Hi, thanks for the pointers. Indeed, this works. There is only one problem: I have a game option called "board size", and it has several possible values: 6x6, 11x11, 13x13, and so on. The displaycondition can apparently only be attached to the entire "board size" choice, rather than to an individual value within that choice. So I had to make two separate options, one for training mode and one for everything else like this:

Code: Select all

$game_options = array(

    // For training mode
    100 => array(
        'name' => totranslate('Board size'),
        'displaycondition' => array(
            array(
                'type' => 'otheroption',
                'id' => GAMESTATE_RATING_MODE,
                'value' => 1
            )
        ),
        'values' => array(
            6 => ...,
            11 => ...,
            13 => ...,
            etc.
        ),
    ),

    // For anything other than training mode
    101 => array(
        'name' => totranslate('Board size'),
        'displaycondition' => array(
            array(
                'type' => 'otheroptionisnot',  // negation!
                'id' => GAMESTATE_RATING_MODE,
                'value' => 1
            )
        ),
        'values' => array(
            11 => ...,
            13 => ...,
            etc.
        ),
    ),
)
That's a lot of repetition, and then my *.game.php has to check both variables 100 and 101 to figure out the actual board size. Another small disadvantage is that if a user selects a board size first (say, 13x13) and then switches to or from training mode, the board size gets reset to the default (say, 11x11).

What I was hoping I would be able to do was something like this instead:

Code: Select all

$game_options = array(

    100 => array(
        'name' => totranslate('Board size'),
        'values' => array(
            6 => array(
                'name' => ...,
                'displaycondition' => array(
                    array(
                        'type' => 'otheroption',
                        'id' => GAMESTATE_RATING_MODE,
                        'value' => 1
                    )
                )
            ),
            11 => ...,
            13 => ...,
            etc.
        ),
    )
)
i.e., to disable just one individual *value* within the choice, rather than disabling the entire choice. But I could not figure out a way to make this latter approach work. Is there such a way? It's fine if there is not, as the first approach above is a workable solution. It's just not quite as smooth as I was hoping it could be.

I have not yet looked into using "startcondition" rather than "displaycondition". If the startcondition can be used to disable individual combinations of options, then it may solve my problem. The user could select 6x6 in non-training mode, but would not be able to start the game.

Re: Is it possible to limit a game option to training mode?

Posted: 07 June 2021, 00:51
by User Already Exists
Update: I just tried "startcondition" and indeed, it does exactly what I want. When non-training mode is selected, there is a 6x6 option, but the user cannot select it (gets an error). When 6x6 is selected, there are non-training mode options, but the user cannot select it (gets an error). Brilliant! Thanks again for your help.