This is a documentation for Board Game Arena: play board games online !

Game options and preferences: gameoptions.inc.php — разлика између измена

Извор: Board Game Arena
Пређи на навигацију Пређи на претрагу
Ред 6: Ред 6:
== Game Options ==
== Game Options ==


Game options is something selected by table creator and usually correspond to game variation, for example if game
Game options is something selected by table creator and usually correspond to game variation, for example if game includes expansion or certain special rule.
includes expansion or certain special rule.
 
* '''displaycondition''' checks the conditions before displaying the option for selection. All conditions must be true for the option to display. Supported condition types:
** ''otheroption'' condition ensures another option is set to this given value
* '''startcondition''' checks the conditions before starting the game. All conditions must be true for the game to start, otherwise players will get a red error message when attempting to begin the game. Supported condition types:
** ''minplayers'' condition ensures at least this many players
** ''maxplayers'' conditions ensure at most this many players


<pre>
<pre>
$game_options = array (
$game_options = array(
       
    100 => array(
        100 => array (
        'name' => totranslate('my game option'),
                'name' => totranslate ( 'my game option' ),
        'values' => array(
                'values' => array (
            // A simple value for this option:
                       
            1 => array(
                        // A simple value for this option:
                 'name' => totranslate('option 1')
                        1 => array (
            ),
                                'name' => totranslate ( 'option 1' )
                        ),
                       
                        // A simple value for this option.
                        // If this value is chosen, the value of "tmdisplay" is displayed in the game lobby
                        2 => array (
                                'name' => totranslate ( 'option 2' ),
                                'tmdisplay' => totranslate ( 'option 2' )
                        ),
                       
                        // Another value, with other options:
                        //  beta=true => this option is in beta version right now.
                        //  nobeginner=true  =>  this option is not recommended for beginners
                        3 => array (
                                'name' => totranslate ( 'option 3' ),
                                'beta' => true,
                                'nobeginner' => true
                        ),
                )
        ),
101 => array(
                'name' => totranslate('Draft variant'),
                'values' => array(
                            1 => array( 'name' => totranslate('No draft') ),
                            2 => array( 'name' => totranslate('Draft'),  'tmdisplay' => totranslate('Draft'),  'premium'=>true,  'nobeginner' => true ),
                        ),
                'displaycondition' => array(    // Note: do not display this option unless these conditions are met
              array( 'type' => 'otheroption', 'id' => 100, 'value' => array(2,3,4) )
            ),
              'startcondition' => array(
                 1 => array( ),
                2 => array( array( 'type' => 'maxplayers', 'value' => 3, 'message' => totranslate( 'Draft option is available for 3 players maximum.' ) ) ),
                ),
                'disable' => true
 
        ),
    102 => array(
                'name' => totranslate('Takeovers'),
                'values' => array(
                            2 => array( 'name' => totranslate('No takeover') ),
                            1 => array( 'name' => totranslate('Allow takeovers'),  'tmdisplay' => totranslate('Takeovers'),  'premium'=>true,  'nobeginner' => true ),
                            3 => array( 'name' => totranslate('2-Player Rebel vs Imperium Takeover Scenario'),  'tmdisplay' => totranslate('RvI scenario'),  'premium'=>true,  'nobeginner' => true ),
                        ),
                'displaycondition' => array(    // Note: do not display this option unless these conditions are met
              array( 'type' => 'otheroption', 'id' => 100, 'value' => array(3,4) )
            ),
                'startcondition' => array(
                        1 => array( ),
                        2 => array( ),
                        3 => array( array( 'type' => 'maxplayers', 'value' => 2, 'message' => totranslate( 'Rebel vs Imperium Takeover Scenario is available for 2 players only.' ) ) ),
                ),
      'disable' => true


        )
            // A simple value for this option.
);
            // If this value is chosen, the value of "tmdisplay" is displayed in the game lobby
            2 => array(
                'name' => totranslate('option 2'),
                'tmdisplay' => totranslate('option 2')
            ),


            // Another value, with other options:
            //  beta=true => this option is in beta version right now.
            //  nobeginner=true  =>  this option is not recommended for beginners
            3 => array(
                'name' => totranslate('option 3'),
                'beta' => true,
                'nobeginner' => true
            ),
        )
    ),
   
    101 => array(
        'name' => totranslate('Draft variant'),
        'values' => array(
            1 => array(
                'name' => totranslate('No draft')
            ),
            2 => array(
                'name' => totranslate('Draft'),
                'tmdisplay' => totranslate('Draft'),
                'premium' => true,
                'nobeginner' => true
            ),
        ),
        'displaycondition' => array( // Note: do not display this option unless these conditions are met
            array(
                'type' => 'otheroption',
                'id' => 100,
                'value' => array(2, 3, 4)
            )
        ),
        'startcondition' => array(
            1 => array(),
            2 => array(
                array(
                    'type' => 'maxplayers',
                    'value' => 3,
                    'message' => totranslate('Draft option is available for 3 players maximum.')
                )
            ),
        ),
        'disable' => true
    ),
   
    102 => array(
        'name' => totranslate('Takeovers'),
        'values' => array(
            2 => array(
                'name' => totranslate('No takeover')
            ),
            1 => array(
                'name' => totranslate('Allow takeovers'),
                'tmdisplay' => totranslate('Takeovers'),
                'premium' => true,
                'nobeginner' => true
            ),
        ),
        'displaycondition' => array( // Note: do not display this option unless these conditions are met
            array(
                'type' => 'otheroption',
                'id' => 100,
                'value' => array(3, 4)
            )
        ),
        'startcondition' => array(
            2 => array(),
            1 => array(
                array(
                    'type' => 'maxplayers',
                    'value' => 2,
                    'message' => totranslate('Rebel vs Imperium Takeover Scenario is available for 2 players only.')
                )
            ),
        ),
        'disable' => true
    )
);
</pre>
</pre>



Верзија на датум 8. јануар 2018. у 02:12

In this file, you can define your game options (= game variants) and user preferences.

Note: If your game has no variants or preferences, you don't have to modify this file.

Game Options

Game options is something selected by table creator and usually correspond to game variation, for example if game includes expansion or certain special rule.

  • displaycondition checks the conditions before displaying the option for selection. All conditions must be true for the option to display. Supported condition types:
    • otheroption condition ensures another option is set to this given value
  • startcondition checks the conditions before starting the game. All conditions must be true for the game to start, otherwise players will get a red error message when attempting to begin the game. Supported condition types:
    • minplayers condition ensures at least this many players
    • maxplayers conditions ensure at most this many players
 $game_options = array(
     100 => array(
         'name' => totranslate('my game option'),
         'values' => array(
             // A simple value for this option:
             1 => array(
                 'name' => totranslate('option 1')
             ),

             // A simple value for this option.
             // If this value is chosen, the value of "tmdisplay" is displayed in the game lobby
             2 => array(
                 'name' => totranslate('option 2'),
                 'tmdisplay' => totranslate('option 2')
             ),

             // Another value, with other options:
             //  beta=true => this option is in beta version right now.
             //  nobeginner=true  =>  this option is not recommended for beginners
             3 => array(
                 'name' => totranslate('option 3'),
                 'beta' => true,
                 'nobeginner' => true
             ),
         )
     ),
     
     101 => array(
         'name' => totranslate('Draft variant'),
         'values' => array(
             1 => array(
                 'name' => totranslate('No draft')
             ),
             2 => array(
                 'name' => totranslate('Draft'),
                 'tmdisplay' => totranslate('Draft'),
                 'premium' => true,
                 'nobeginner' => true
             ),
         ),
         'displaycondition' => array( // Note: do not display this option unless these conditions are met
             array(
                 'type' => 'otheroption',
                 'id' => 100,
                 'value' => array(2, 3, 4)
             )
         ),
         'startcondition' => array(
             1 => array(),
             2 => array(
                 array(
                     'type' => 'maxplayers',
                     'value' => 3,
                     'message' => totranslate('Draft option is available for 3 players maximum.')
                 )
             ),
         ),
         'disable' => true
     ),
     
     102 => array(
         'name' => totranslate('Takeovers'),
         'values' => array(
             2 => array(
                 'name' => totranslate('No takeover')
             ),
             1 => array(
                 'name' => totranslate('Allow takeovers'),
                 'tmdisplay' => totranslate('Takeovers'),
                 'premium' => true,
                 'nobeginner' => true
             ),
         ),
         'displaycondition' => array( // Note: do not display this option unless these conditions are met
             array(
                 'type' => 'otheroption',
                 'id' => 100,
                 'value' => array(3, 4)
             )
         ),
         'startcondition' => array(
             2 => array(),
             1 => array(
                 array(
                     'type' => 'maxplayers',
                     'value' => 2,
                     'message' => totranslate('Rebel vs Imperium Takeover Scenario is available for 2 players only.')
                 )
             ),
         ),
         'disable' => true
     )
 );

Note²: All options defined in this file should have a corresponding "game state labels" with the same ID (see "initGameStateLabels" in yourgame.game.php)


            self::initGameStateLabels ( array (
                       ...
                       "my_first_game_variant" => 100,
             ) );


IMPORTANT: After you edited and deployed this file you have to go to control panel and press "Reload game options configuration"

User Preferences

User preferences is something cosmetic about the game interface which however can create user wars, so you can satisfy all user by giving them individual preferences. Do not use this unless absolutely necessary and usually only after game has been in production for a while. If you add these currently only admins can apply these settings, so you would have to contact them after editing this file.

$game_preferences = array(
    100 => array(
			'name' => totranslate('Notation style'),
			'needReload' => true, // after user changes this preference game interface would auto-reload
			'values' => array(
					1 => array( 'name' => totranslate( 'Classic' ), 'cssPref' => 'notation_classic' ),
					2 => array( 'name' => totranslate( 'Tournament' ), 'cssPref' => 'notation_tournament' )
			)
	)
);

There is two ways to check/apply this. In java Script

 if (this.prefs[100].value == 2) ...

This checks if preferences 100 has selected value 2.

Second, if cssPref specified it will be applied to the body tag. So you can use different css styling for the preference.

As user you have to select them from the Gear menu when game is started. On studio only user0 will have it actually working (bug?).