|
1 | 1 | # laravel-game-essentials
|
2 |
| -The essentials and basic data for a gaming backend server. |
| 2 | + |
| 3 | +[](https://packagist.org/packages/furic/game-essentials) |
| 4 | +[](https://packagist.org/packages/furic/game-essentials) |
| 5 | +[](https://packagist.org/packages/furic/game-essentials) |
| 6 | +[](https://scrutinizer-ci.com/g/furic/laravel-game-essentials/?branch=main) |
| 7 | +[](https://scrutinizer-ci.com/g/furic/laravel-game-essentials/build-status/main) |
| 8 | + |
| 9 | +> Game Essentials for [Laravel 5.*](https://laravel.com/). This package is required and used by few packages in [Sweaty Chair Studio](https://www.sweatychair.com) creating the basic data and essential functions for a gaming server backend. This provides functions such as registering players and assign the players in a game. After that the data can be used for analytics purpose. |
| 10 | +
|
| 11 | +> If you are using other packages that requires this package, this will be added automatically and you do not need to install it manually. However, you can still use this package alone without using other packages. |
| 12 | +
|
| 13 | +## Table of Contents |
| 14 | +- [Installation](#installation) |
| 15 | +- [Configuration](#configuration) |
| 16 | +- [Usage](#usage) |
| 17 | + - [Web Console](#web-console) |
| 18 | + - [Redeem Code Parameters](#redeem-code-parameters) |
| 19 | + - [Redeem Validator API](#redeem-validator-api) |
| 20 | + - [Unity Client Repo](#unity-client-repo) |
| 21 | +- [TODO](#todo) |
| 22 | +- [License](#license) |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | +Install this package via Composer: |
| 27 | +```bash |
| 28 | +$ composer require furic/game-essentials |
| 29 | +``` |
| 30 | + |
| 31 | +> If you are using Laravel 5.5 or later, then installation is done. Otherwise follow the next steps. |
| 32 | +
|
| 33 | +#### Open `config/app.php` and follow steps below: |
| 34 | + |
| 35 | +Find the `providers` array and add our service provider. |
| 36 | + |
| 37 | +```php |
| 38 | +'providers' => [ |
| 39 | + // ... |
| 40 | + Furic\GameEssentials\GameEssentialsServiceProvider::class |
| 41 | +], |
| 42 | +``` |
| 43 | + |
| 44 | +## Configuration |
| 45 | + |
| 46 | +Publish config & migration file using Artisan command: |
| 47 | +```bash |
| 48 | +$ php artisan vendor:publish |
| 49 | +``` |
| 50 | + |
| 51 | +To create table for redeem codes in database run: |
| 52 | +```bash |
| 53 | +$ php artisan migrate |
| 54 | +``` |
| 55 | + |
| 56 | +## Usage |
| 57 | + |
| 58 | +### Game Parameters |
| 59 | + |
| 60 | +A game has following parameters: |
| 61 | +``` |
| 62 | + $table->string('name', 128); |
| 63 | + $table->smallInteger('version_ios')->unsigned(); |
| 64 | + $table->smallInteger('version_android')->unsigned(); |
| 65 | + $table->smallInteger('version_tvos')->unsigned(); |
| 66 | +``` |
| 67 | +- Name: The name of the game/app. |
| 68 | +- iOS Version: The latest version number in iOS, used for force update in client. |
| 69 | +- Android Version: The latest version number in Android, used for force update in client. |
| 70 | +- tvOS Version: The latest version number in tvOS, used for force update in client. |
| 71 | + |
| 72 | +### Player Parameters |
| 73 | + |
| 74 | +A game has following parameters: |
| 75 | +``` |
| 76 | + $table->string('facebook_id', 128)->nullable(); |
| 77 | + $table->string('gamecenter_id', 128)->nullable(); |
| 78 | + $table->string('playgames_id', 128)->nullable(); |
| 79 | + $table->string('udid', 128); |
| 80 | + $table->string('name', 128)->nullable; |
| 81 | + $table->string('ip', 15); |
| 82 | +``` |
| 83 | +- Facebook ID: The Facebook ID of a player. (Optional) |
| 84 | +- Game Center ID: The Game Center ID of a player in iOS. (Optional) |
| 85 | +- Google Play Games ID: The Google Play Games ID of a player in Android. (Optional) |
| 86 | +- UDID: The unique device UDID of a player. If the player is using multiple devices, only the first device UDID is used here. |
| 87 | +- Name: The name of the player input in game/app. (Optional) |
| 88 | +- IP: The IP of the player when being first seen. |
| 89 | + |
| 90 | +### Player Parameters |
| 91 | + |
| 92 | +Finally, a player-game has following parameters: |
| 93 | +``` |
| 94 | + $table->integer('player_id')->unsigned(); |
| 95 | + $table->integer('game_id')->unsigned(); |
| 96 | + $table->tinyInteger('channel')->unsigned(); |
| 97 | + $table->smallInteger('version')->unsigned(); |
| 98 | + $table->boolean('is_hack')->default(false); |
| 99 | +``` |
| 100 | +- Player ID: The ID of a player. |
| 101 | +- Game ID: The ID of a the game that player launched. |
| 102 | +- Channel: The channel of the player getting into the game. Mostly used for Android players, e.g. Sumsung Store, Huawei App Gallery, etc. (Optional) |
| 103 | +- Version: The current game version that the player device running. |
| 104 | +- Is Hacked: A boolean to mark if the player ever performed any hack in game, for analytics and limiting functions in client. |
| 105 | + |
| 106 | +### API |
| 107 | + |
| 108 | +GET `<server url>/games/{game-id}` |
| 109 | +Returns a JSON data from a given game ID, for debug usage only. |
| 110 | + |
| 111 | +GET `<server url>/games/{game-id}/versions` |
| 112 | +Returns a JSON data containing the versions from a given game ID, for client checking the latest game version and perform force-update. |
| 113 | + |
| 114 | +GET `<server url>/players/{player-id}` |
| 115 | +Returns a JSON data from a given player ID, for debug usage only. |
| 116 | + |
| 117 | +GET `<server url>/players/name/{player-name}` |
| 118 | +Returns a JSON data from a given player name, for debug usage only. |
| 119 | + |
| 120 | +POST `<server url>/players` |
| 121 | +Creates a player with given POST data. |
| 122 | + |
| 123 | +POST `<server url>/players/{player-id}` |
| 124 | +Updates a player with a given player id and POST data. |
| 125 | + |
| 126 | +GET `<server url>/games/{game-id}/players` |
| 127 | +Returns a JSON array of all players from a given game ID, for debug usage only. |
| 128 | + |
| 129 | +## TODO |
| 130 | + |
| 131 | +- Create the web console to add/edit games. |
| 132 | +- Add admin login for web console. |
| 133 | +- Add tests. |
| 134 | + |
| 135 | +## License |
| 136 | + |
| 137 | +laravel-redeem-codes is licensed under a [MIT License](https://github.com/furic/laravel-game-essentials/blob/main/LICENSE). |
0 commit comments