{"id":15654221,"url":"https://github.com/danielholmes/bga-workbench","last_synced_at":"2025-04-15T16:42:11.202Z","repository":{"id":42535525,"uuid":"104312342","full_name":"danielholmes/bga-workbench","owner":"danielholmes","description":"Set of tools to work with a BoardGameArena project","archived":false,"fork":false,"pushed_at":"2021-06-01T23:36:16.000Z","size":358,"stargazers_count":33,"open_issues_count":15,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T22:35:07.528Z","etag":null,"topics":["bga","board-game","boardgame","boardgamearena","boardgamegeek"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielholmes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-21T06:53:40.000Z","updated_at":"2025-02-27T12:30:46.000Z","dependencies_parsed_at":"2022-09-22T14:24:49.070Z","dependency_job_id":null,"html_url":"https://github.com/danielholmes/bga-workbench","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielholmes%2Fbga-workbench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielholmes%2Fbga-workbench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielholmes%2Fbga-workbench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielholmes%2Fbga-workbench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielholmes","download_url":"https://codeload.github.com/danielholmes/bga-workbench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248662226,"owners_count":21141534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bga","board-game","boardgame","boardgamearena","boardgamegeek"],"created_at":"2024-10-03T12:49:59.626Z","updated_at":"2025-04-15T16:42:11.176Z","avatar_url":"https://github.com/danielholmes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BoardGameArena Workbench\n\n[![Build](https://github.com/danielholmes/bga-workbench/actions/workflows/build.yml/badge.svg)](https://github.com/danielholmes/bga-workbench/actions/workflows/build.yml)\n[![Latest Stable Version](https://img.shields.io/packagist/v/dholmes/bga-workbench.svg)](https://packagist.org/packages/dholmes/bga-workbench)\n\nA set of tools to work with [BoardGameArena](https://boardgamearena.com/) projects.\n\n   * [Installation](#installation)\n   * [Initialise BGA Project](#initialise-bga-project)\n   * [Deploying to BGA Studio](#deploying-to-bga-studio)\n   * [Compiling composer projects](#compiling-composer-projects)\n   * [Testing utilities](#testing-utilities)\n\n \n   * [Projects Using BGA Workbench](#projects-using-bga-workbench)\n\n \n   * [Development](#development)\n      * [Requirements](#requirements)\n      * [Setting up Developer Machine](#setting-up-developer-machine)\n      * [Running tests](#running-tests)\n\n\n## Installation\n\nVia composer:\n\n```bash\ncomposer require --dev dholmes/bga-workbench\n```\n\nVia Docker:\n```bash\ndocker build -t bgawb .\nalias bgawb=\"docker run --rm -v $PWD:/data -w /data bgawb\"\n```\n(this last line should be set in your ~/.bashrc to keep the alias working in a new terminal)\n\n\nTo set up your project to work with BGA Workbench you need to have a `bgaproject.yml` file in the root. To generate one \nsee the [`bgawb init` command](#initialise-bga-project).\n\n\n## Initialise BGA Project\n\nOnce you've installed bgawb you can run the below command to interactively create a `bgaproject.yml` file in your \ncurrent directory.\n\n```bash\nbgawb init\n```\n\n\n## Deploying to BGA Studio\n\n```bash\nbgawb build --deploy\n```\n\n### Continuous Deployment to Studio\n\nWatches development files and deploys them as they change.\n\n```bash\nbgawb build --deploy --watch\n```\n\n\n## Compiling composer projects\n\nThe Board Game Arena production framework/environment doesn't natively support a [Composer](https://getcomposer.org/) \nproject setup. By having `useComposer: true` set in your `bgaproject.yml` file, the \n[`bgawb build`](Deploying to BGA Studio) command will merge all non-dev composer dependencies inline into your .game.php \nfile before deploying. \n\n\n## Testing Utilities\n\nSome testing utilities are provided to help test various parts of a standard BGA project game.\n\n### The Validate Command\n\nWill run some basic checks on your project setup. e.g. whether you have the required files to function on the BGA \nplatform (`.game.php`, `.action.php`, etc), whether your `states.inc.php` file is valid, etc. \n\n```bash\nbgawb validate\n```\n\n### PHPUnit TestHelp trait\n\nIncluding this trait and implementing the `createGameTableInstanceBuilder` method will set up and tear down a game table \ninstance for each test that is run. Note that this makes use of the `setUp` and `tearDown` PHPUnit hooks\n\n```php\n\u003c?php\n\nnamespace Game\\Tests;\n\nuse PHPUnit\\Framework\\TestCase;\nuse BGAWorkbench\\Test\\TestHelp;\nuse Doctrine\\DBAL\\Connection;\nuse BGAWorkbench\\Utils;\n\nclass ChooseAttackTest extends TestCase\n{\n    use TestHelp;\n    \n    protected function createGameTableInstanceBuilder() : TableInstanceBuilder\n    {\n        return $this-\u003egameTableInstanceBuilder()\n            -\u003esetPlayersWithIds([66, 77])\n            -\u003eoverridePlayersPostSetup([\n                66 =\u003e ['player_color' =\u003e 'ff0000'],\n                77 =\u003e ['player_color' =\u003e '00ff00']\n            ]);\n    }\n    \n    public function testAction()\n    {\n        $action = $this-\u003etable\n            -\u003esetupNewGame()\n            -\u003ewithDbConnection(function (Connection $db) {\n                $db-\u003eexec('INSERT battlefield_card (player_id, type, x, y) VALUES (' .\n                    join('), (', [\n                        [77, '\"infantry\"', 0, -1],  \n                        [66, '\"infantry\"', 0, 1],  \n                        [66, '\"artillery\"', 6, 1],  \n                    ])\n                . ')');\n            })\n            -\u003ecreateActionInstanceForCurrentPlayer(66)\n            -\u003estubActivePlayerId(66)\n            -\u003estubArgs(['x' =\u003e 5, 'y' =\u003e 5]);\n\n        $action-\u003echooseAttack();\n        \n        // TODO: Run some asserts on the db\n    }\n    \n    public function testStateFunc()\n    {\n        $game = $this-\u003etable\n            -\u003esetupNewGame()\n            -\u003ecreateGameInstanceWithNoBoundedPlayer()\n            -\u003estubActivePlayerId(66);\n        \n        $game-\u003estNextPlayer();\n    }\n    \n    public function testGetAllDatas()\n    {\n        $game = $this-\u003etable\n            -\u003esetupNewGame()\n            -\u003ewithDbConnection(function (Connection $db) {\n                $db-\u003eexec('DELETE FROM deck_card');\n                $db-\u003eexec('DELETE FROM playable_card');\n                $db-\u003eexec('INSERT INTO battlefield_card (player_id, type, x, y) VALUES (66, \"tank\", 0, 2)');\n                $db-\u003eexecuteUpdate('UPDATE player SET player_score_aux = 1 WHERE player_id = 66');\n            })\n            -\u003ecreateGameInstanceForCurrentPlayer(66);\n\n        $datas = Utils::callProtectedMethod($game, 'getAllDatas');\n        \n        // TODO: Some asserts on $datas\n    }\n}\n```\n\n\n## Projects Using BGA Workbench\n\n - [The Battle for Hill 218](https://github.com/danielholmes/battle-for-hill-218)\n - [Tablut](https://github.com/Lucas-C/tablut)\n\n\n## Development\n\ni.e. if you want to make some changes to the BGA Workbench project. This is not required for using the library in your \nown project.\n\n### Requirements\n\n - [Vagrant](https://www.vagrantup.com/)\n\n### Setting up Developer Machine\n\n```bash\nvagrant up\n```\n\n### Running Tests\n\n```bash\nvagrant ssh\ncomposer test\n```\n\n### Publishing a New Version\n\n 1. Add a release/tag on github with the version number.\n 2. Go to the packagist url and click \"Update\": \u003chttps://packagist.org/packages/dholmes/bga-workbench\u003e. This should be \n    done automatically though if just left.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielholmes%2Fbga-workbench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielholmes%2Fbga-workbench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielholmes%2Fbga-workbench/lists"}