This is a documentation for Board Game Arena: play board games online !
Game database model: dbmodel.sql: Розніца паміж версіямі
PurplishCat (размовы | уклад) дрНяма тлумачэння праўкі |
|||
(Не паказана адна прамежкавая версія яшчэ аднаго ўдзельніка) | |||
Радок 26: | Радок 26: | ||
</pre> | </pre> | ||
The commonly used columns of default "player" table are: | |||
* <strong>player_no</strong>: the index of player in natural playing order (starting with 1) | * <strong>player_no</strong>: the index of player in natural playing order (starting with 1) | ||
* <strong>player_id</strong> | * <strong>player_id</strong> (int) | ||
* <strong>player_name</strong>: (note: | * <strong>player_name</strong>: (note: it is better to access this date with getActivePlayerName() or loadPlayersBasicInfos() methods)<br/><br/> | ||
* <strong>player_score</strong>: the current score of the player (displayed in the player panel). You must update this field to update player's scores. | * <strong>player_score</strong>: the current score of the player (displayed in the player panel). You must update this field to update player's scores. | ||
* <strong>player_score_aux</strong>: the secondary score, used as a tie breaker. You must update this field according to tie breaking rules of the game (see also: [[Main_game_logic:_yourgamename.game.php#Manage_player_scores_and_Tie_breaker|Manage_player_scores_and_Tie_breaker]])<br/><br/> | * <strong>player_score_aux</strong>: the secondary score, used as a tie breaker. You must update this field according to tie breaking rules of the game (see also: [[Main_game_logic:_yourgamename.game.php#Manage_player_scores_and_Tie_breaker|Manage_player_scores_and_Tie_breaker]])<br/><br/> | ||
* <strong>player_table_order</strong>: gives an indication of the rank of the player by order of arrival in the lobby (starting with 1). It is not the same as player_no which is the player order <u>within</u> the game. This is useful to set custom teams if wished in a game option (for instance 1st-2nd vs 3rd-4th).<br /><strong><u>CAUTION:</u></strong> This value is currently <u>not | * <strong>player_table_order</strong>: gives an indication of the rank of the player by order of arrival in the lobby (starting with 1). It is not the same as player_no which is the player order <u>within</u> the game. This is useful to set custom teams if wished in a game option (for instance 1st-2nd vs 3rd-4th).<br /><strong><u>CAUTION:</u></strong> This value is currently <u>not guaranteed</u> to be actually equal with the rank of the player in the table. For example, in a 4 player game, if the table was full but the 3rd player have left before the game starts, the 4th player becomes 3rd on this table <u>but</u> their player_table_no is still equal to 4! If another player then joins, their player_table_no will then be 5...<br />Thus, it is essential to normalize these values first in the game setup if you wish to use them to prevent bugs at game launch. For example, if the set of player_table_order are <player A>: 3, <player B>: 2, <player C>: 5, <player D>: 7, you see that you can't read that values as ranks directly, but you can still deduce that <player B> was 1st on the table, then <player A> then <player C> then <player D> 😉 | ||
== CREATE TABLES == | == CREATE TABLES == |
Актуальная версія на 16:42, 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 specify the database schema of your game.
This file contains SQL queries that will be executed during the creation of your game table.
Note: you can't change the database schema during the game.
Create your schema
To build this file, we recommend you to build the tables you need with the PhpMyAdmin tool (see BGA user guide), and then to export them and to copy/paste the content inside this file.
Note: you must not use for a column the same name as for the table, as the framework replay function relies on regexp substitution to save/restore a previous state in a clone table with another name.
Default tables
Important: by default, BGA creates 4 tables for your game: global, stats, gamelog, and player.
You must not modify the schema of global, stats and gamelog tables (and you must not access them directly with SQL queries in your PHP code).
You may add columns to "player" table. This is very practical to add simple values associated with players.
Example:
ALTER TABLE `player` ADD `player_reserve_size` SMALLINT UNSIGNED NOT NULL DEFAULT '7';
The commonly used columns of default "player" table are:
- player_no: the index of player in natural playing order (starting with 1)
- player_id (int)
- player_name: (note: it is better to access this date with getActivePlayerName() or loadPlayersBasicInfos() methods)
- player_score: the current score of the player (displayed in the player panel). You must update this field to update player's scores.
- player_score_aux: the secondary score, used as a tie breaker. You must update this field according to tie breaking rules of the game (see also: Manage_player_scores_and_Tie_breaker)
- player_table_order: gives an indication of the rank of the player by order of arrival in the lobby (starting with 1). It is not the same as player_no which is the player order within the game. This is useful to set custom teams if wished in a game option (for instance 1st-2nd vs 3rd-4th).
CAUTION: This value is currently not guaranteed to be actually equal with the rank of the player in the table. For example, in a 4 player game, if the table was full but the 3rd player have left before the game starts, the 4th player becomes 3rd on this table but their player_table_no is still equal to 4! If another player then joins, their player_table_no will then be 5...
Thus, it is essential to normalize these values first in the game setup if you wish to use them to prevent bugs at game launch. For example, if the set of player_table_order are <player A>: 3, <player B>: 2, <player C>: 5, <player D>: 7, you see that you can't read that values as ranks directly, but you can still deduce that <player B> was 1st on the table, then <player A> then <player C> then <player D> 😉
CREATE TABLES
you can create tables, using engine InnoDB
CREATE TABLE IF NOT EXISTS `hands` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `player_id` TINYINT(1) NOT NULL, `1` BOOL NOT NULL DEFAULT 1, `2` BOOL NOT NULL DEFAULT 1, `3` BOOL NOT NULL DEFAULT 1, `4` BOOL NOT NULL DEFAULT 1, `5` BOOL NOT NULL DEFAULT 1, `6` BOOL NOT NULL DEFAULT 1, `7` BOOL NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Note: if you put comments, you cannot do it in the same line as code.
Example:
`3` BOOL NOT NULL DEFAULT 1, -- activated or not
will also comment out `3` BOOL, and that code will not be executed.
Link
You can add your Db inits in function SetupNewGame() from file 'gamename.game.php'
Errors Log
To trace Database creation check the logs that you can access in /admin/studio.
Post-release database modification
If you want to modify your database schema after the first release of your game in production, you should consult the related section