This is a documentation for Board Game Arena: play board games online !
Game statistics: stats.inc.php: Розніца паміж версіямі
Victoria la (размовы | уклад) Няма тлумачэння праўкі |
(Add info on statistic labels) |
||
(Не паказана 2 прамежкавыя версіі 2 удзельнікаў) | |||
Радок 1: | Радок 1: | ||
{{Studio_Framework_Navigation}} | |||
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. | ||
Радок 13: | Радок 15: | ||
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" | 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 !! | ||
Радок 62: | Радок 65: | ||
); | ); | ||
</pre> | |||
Sometimes you may want to display a label instead of a number (for instance if you want to indicate the winning faction as a table statistic, and the faction chosen by each player as a player statistic in a game like Terra Mystica). | |||
You can do this by adding a "value_labels" array following the "table" and "players" array. Please note that the labels apply to both table and player statistics, so you should pay attention to use the same statistic number for the same type of statistic (or to skip one number if labelling should not be applied for both) | |||
<pre> | |||
"value_labels" => array( | |||
11 => array( | |||
0 => totranslate("None (or tied)"), | |||
1 => totranslate("Auren"), | |||
2 => totranslate("Witches"), | |||
3 => totranslate("Fakirs"), | |||
4 => totranslate("Nomads"), | |||
5 => totranslate("Chaos Magicians"), | |||
6 => totranslate("Giants"), | |||
7 => totranslate("Swarmlings"), | |||
8 => totranslate("Mermaids"), | |||
9 => totranslate("Dwarves"), | |||
10 => totranslate("Engineers"), | |||
11 => totranslate("Halflings"), | |||
12 => totranslate("Cultists"), | |||
13 => totranslate("Alchemists"), | |||
14 => totranslate("Darklings"), | |||
), | |||
) | |||
</pre> | </pre> |
Актуальная версія на 10:44, 19 мая 2020
- Main game logic: yourgamename.game.php
- Your game state machine: states.inc.php
- Game database model: dbmodel.sql
- Players actions: yourgamename.action.php
- Game material description: material.inc.php
- Game statistics: stats.inc.php
- Game interface logic: yourgamename.js
- Game art: img directory
- Game interface stylesheet: yourgamename.css
- Game layout: view and template: yourgamename.view.php and yourgamename_yourgamename.tpl
- Your game mobile version
- Translations (how to make your game translatable)
- Game options and preferences: gameoptions.inc.php
- Game meta-information: gameinfos.inc.php
- Game replay
- 3D
- Some usual board game elements image ressources
- Deck: a PHP component to manage cards (deck, hands, picking cards, moving cards, shuffle deck, ...).
- Counter: a JS component to manage a counter that can increase/decrease (ex: player's score).
- Scrollmap: a JS component to manage a scrollable game area (useful when the game area can be infinite. Examples: Saboteur or Takenoko games).
- Stock: a JS component to manage and display a set of game elements displayed at a position.
- Zone: a JS component to manage a zone of the board where several game elements can come and leave, but should be well displayed together (See for example: token's places at Can't Stop).
Undocumented component (if somebody knows please help with docs)
- Draggable: a JS component to manage drag'n'drop actions.
- ExpandableSection: a JS component to manage a rectangular block of HTML than can be displayed/hidden.
- Wrapper: a JS component to wrap a <div> element around its child, even if these elements are absolute positioned.
- BGA game Lifecycle
- First steps with BGA Studio
- Tutorial reversi
- Tutorial gomoku
- Tutorial hearts
- Create a game in BGA Studio: Complete Walkthrough
- Tools and tips of BGA Studio - Tips and instructions on setting up development environment
- Practical debugging - Tips focused on debugging
- Studio logs - Instructions for log access
- BGA Studio Cookbook - Tips and instructions on using API's, libraries and frameworks
- BGA Studio Guidelines
- Troubleshooting - Most common "I am really stuck" situations
- Studio FAQ
- Pre-release checklist - Go throught this list if you think you done development
- Post-release phase
- BGA Code Sharing - Shared resources, projects on git hub, common code, other links
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" ) ) );
Sometimes you may want to display a label instead of a number (for instance if you want to indicate the winning faction as a table statistic, and the faction chosen by each player as a player statistic in a game like Terra Mystica).
You can do this by adding a "value_labels" array following the "table" and "players" array. Please note that the labels apply to both table and player statistics, so you should pay attention to use the same statistic number for the same type of statistic (or to skip one number if labelling should not be applied for both)
"value_labels" => array( 11 => array( 0 => totranslate("None (or tied)"), 1 => totranslate("Auren"), 2 => totranslate("Witches"), 3 => totranslate("Fakirs"), 4 => totranslate("Nomads"), 5 => totranslate("Chaos Magicians"), 6 => totranslate("Giants"), 7 => totranslate("Swarmlings"), 8 => totranslate("Mermaids"), 9 => totranslate("Dwarves"), 10 => totranslate("Engineers"), 11 => totranslate("Halflings"), 12 => totranslate("Cultists"), 13 => totranslate("Alchemists"), 14 => totranslate("Darklings"), ), )