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

Game statistics: stats.json: Difference between revisions

From Board Game Arena
Jump to navigation Jump to search
(Copy/paste of the explanations inside stats.inc.php)
No edit summary
(One intermediate revision by the same user not shown)
Line 1: Line 1:
(to be completed)
In this file, you are describing game statistics, that will be displayed at the end of the
In this file, you are describing game statistics, that will be displayed at the end of the
game.
game.


!! After modifying this file, you must use "Reload  statistics configuration" in BGA Studio backoffice ("Your game configuration" section):
After modifying this file, you must use "Reload  statistics configuration"  
http://en.studio.boardgamearena.com/admin/studio
in BGA Studio Control Panel -> Manage Games ("Game Configuration" section):
 
http://en.studio.boardgamearena.com/#!studio


There are 2 types of statistics:
There are 2 types of statistics:
_ table statistics, that are not associated to a specific player (ie: 1 value for each game).
* table statistics, that are not associated to a specific player (i.e.: one value for each game).
_ player statistics, that are associated to each players (ie: 1 value for each player in the game).
* player statistics, that are associated to each players (i.e.: one value for each player in the game).


Statistics types can be "int" for integer, "float" for floating point values, and "bool" for boolean
Statistics types can be "int" for integer, "float" for floating point values, and "bool" for boolean.


Once you defined your statistics there, you can start using "initStat", "setStat" and "incStat" method
Once you defined your statistics there, you can start using "initStat", "setStat" and "incStat" methods
in your game logic, using statistics names defined below.
in your game logic, using statistics names defined below.
See API http://en.doc.boardgamearena.com/Main_game_logic:_yourgamename.game.php#Game_statistics.


!! It is not a good idea to modify this file when a game is running !!
!! It is not a good idea to modify this file when a game is running !!
Line 30: Line 30:
* Statistics ID is the reference used by BGA website. If you change the ID, you lost all historical statistic data. Do NOT re-use an ID of a deleted statistic
* Statistics ID is the reference used by BGA website. If you change the ID, you lost all historical statistic data. Do NOT re-use an ID of a deleted statistic
* Statistic name is the English description of the statistic as shown to players
* Statistic name is the English description of the statistic as shown to players
<pre>
  $stats_type = array(
    // Statistics global to table
    "table" => array(
        "turns_number" => array("id"=> 10,
                    "name" => totranslate("Number of turns"),
                    "type" => "int" ),
    ),
   
    // Statistics existing for each player
    "player" => array(
        "turns_number" => array("id"=> 10,
                    "name" => totranslate("Number of turns"),
                    "type" => "int" ),
   
        "player_teststat1" => array(  "id"=> 11,
                                "name" => totranslate("player test stat 1"),
                                "type" => "int" ),
                               
        "player_teststat2" => array(  "id"=> 12,
                                "name" => totranslate("player test stat 2"),
                                "type" => "float" )
 
    )
  );
</pre>

Revision as of 03:17, 23 July 2016

In this file, you are describing game statistics, that will be displayed at the end of the game.

After modifying this file, you must use "Reload statistics configuration" in BGA Studio Control Panel -> Manage Games ("Game Configuration" section):

http://en.studio.boardgamearena.com/#!studio

There are 2 types of statistics:

  • table statistics, that are not associated to a specific player (i.e.: one value for each game).
  • player statistics, that are associated to each players (i.e.: one value for each player in the game).

Statistics types can be "int" for integer, "float" for floating point values, and "bool" for boolean.

Once you defined your statistics there, you can start using "initStat", "setStat" and "incStat" methods in your game logic, using statistics names defined below. See API http://en.doc.boardgamearena.com/Main_game_logic:_yourgamename.game.php#Game_statistics.

!! It is not a good idea to modify this file when a game is running !!

If your game is already public on BGA, please read the following before any change: http://en.doc.boardgamearena.com/Post-release_phase#Changes_that_breaks_the_games_in_progress

Notes:

  • Statistic index is the reference used in setStat/incStat/initStat PHP method
  • Statistic index must contains alphanumerical characters and no space. Example: 'turn_played'
  • Statistics IDs must be >=10
  • Two table statistics can't share the same ID, two player statistics can't share the same ID
  • A table statistic can have the same ID than a player statistics
  • Statistics ID is the reference used by BGA website. If you change the ID, you lost all historical statistic data. Do NOT re-use an ID of a deleted statistic
  • Statistic name is the English description of the statistic as shown to players


  $stats_type = array(

    // Statistics global to table
    "table" => array(

        "turns_number" => array("id"=> 10,
                    "name" => totranslate("Number of turns"),
                    "type" => "int" ),
    ),
    
    // Statistics existing for each player
    "player" => array(

        "turns_number" => array("id"=> 10,
                    "name" => totranslate("Number of turns"),
                    "type" => "int" ),
    

        "player_teststat1" => array(   "id"=> 11,
                                "name" => totranslate("player test stat 1"), 
                                "type" => "int" ),
                                
        "player_teststat2" => array(   "id"=> 12,
                                "name" => totranslate("player test stat 2"), 
                                "type" => "float" )

  
    )

  );