GameRocket

This add-on is operated by Work Bandits

Powerful game mechanics platform and data hosting for mobile and web game.

GameRocket

Last Updated: 15 January 2014

The GameRocket add-on is currently in beta.

Table of Contents

GameRocket is an API-based game mechanics engine service. GameRocket is designed to give you a modern, flexible game platform.

GameRocket helps you to concentrate on your game and keep simple complicated things like flexibility, scalibility, availibility. GameRocket provides a highly flexible structure for your game and implements entities like Players, Actions, Items, Quests, Achievements, Crons, Versions. Just pick what you need and script the platform to your needs.

GameRocket is accessible via an API and has supported client libraries for Java, PHP, Ruby, C# (Python and Node.js arrived really soon).

Provisioning the add-on

GameRocket can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:add gamerocket
-----> Adding gamerocket to sharp-mountain-4005... done, v18 (free)

Once GameRocket has been addeed your GAMEROCKET_APIKEY and GAMEROCKET_SECRETKEY will be availabled in the app configuration. These items will be used when making requests against the GameRocket API. Check to make sure the addon was successfully installed by running heroku config.

$ heroku config:get | grep GAMEROCKET
GAMEROCKET_APIKEY   => 33a80383c7d84e85b769f0f026067390
GAMEROCKET_SECRETKEY    => 21fedcb57a1348d18fe4ffb1754d4615

After installing GameRocket the application should be configured to fully integrate with the add-on.

Using with Ruby

Install

First, install the Ruby gem:

$ gem install gamerocket
Fetching: gamerocket.gem (100%)
Successfully installed gamerocket

If you’re building for a Rails application or anything that uses Bundler, add the following to your Gemfile:

gem 'gamerocket'

Ruby usage

Create a Player resource is as simple as this:

require "gamerocket"

GameRocket::Configuration.environment = :production
GameRocket::Configuration.apiKey = ENV['GAMEROCKET_APIKEY']
GameRocket::Configuration.secretKey = ENV['GAMEROCKET_SECRETKEY']

result = GameRocket::Player.create(
    :name => "player_name",
    :locale => "player_locale" # Ex: en_US
)

if result.success?
    # store result.player.id in your database
end

Once the player is created, you can execute an Action.

Actions are created using the GameRocket Dashboard. It can be accessed via the CLI:

$ heroku addons:open gamerocket
Opening gamerocket for sharp-mountain-4005...

Click on the Edit button of your game.

Once in your game, click on Actions in the left navigation bar.

Click on “New” at the top of the screen and complete the form:

Ref: hello-world

In the JSON field:

{
    "dynProp": {
    },
    "locales": {
    },
    "name":"Hello world action",
    "secured":false
}

In the Script field:

return ["hello":"Hello world!"]

Scripts are written in Groovy. It’s an agile and dynamic language very similar to JavaScript. Don’t be afraid, it’s really easy!

̀[:] is a key-value structure in Groovy. With the hello key, we have associated the value “Hello world!”.

Click on Create.

You now have an Action ready to be executed.

Execute an Action is as easy as this:

result = GameRocket::Action.run("hello-world", {
    :player => "<use_player_id>"
})

if result.success?
    p result.data["hello"]
end

You can see the full documentation here.

Using with Java

Install

First, install the Maven dependency.

In repositories, add:

<repository>
    <id>gamerocket</id>
    <name>GameRocket</id>
    <url>https://raw.github.com/workbandits/gamerocket-java-repo/master/releases</url>
</repository>

In dependencies, add:

<dependency>
    <groupId>com.workbandits.gamerocket</groupId>
    <artifactId>gamerocket-java</artifactId>
    <version>1.1.3</version>
</dependency>

Now you can download any outstanding dependencies with:

$ mvn package

Java usage

Create a Player resource is as simple as this:

import com.workbandits.gamerocket.*;

private static GameRocketGateway gateway = new GameRocketGateway(
    Environment.PRODUCTION,
    "use_your_apikey",
    "use_your_secretkey"
);

PlayerRequest playerRequest = new PlayerRequest()
    .name("player_name")
    .locale("player_locale"); // Ex: en_US

Result<Player> result = gateway.player().create(playerRequest);

if (result.isSuccess()) {
    // store result.getTarget().getId() in your database
}

Once the player is created, you can execute an Action.

Actions are created using the GameRocket Dashboard. It can be accessed via the CLI:

$ heroku addons:open gamerocket
Opening gamerocket for sharp-mountain-4005...

Click on the Edit button of your game.

Once in your game, click on Actions in the left navigation bar.

Click on “New” at the top of the screen and complete the form:

Ref: hello-world

In the JSON field:

{
    "dynProp": {
    },
    "locales": {
    },
    "name":"Hello world action",
    "secured":false
}

In the Script field:

return ["hello":"Hello world!"]

Scripts are written in Groovy. It’s an agile and dynamic language very similar to JavaScript. Don’t be afraid, it’s really easy!

[:] is a key-value structure in Groovy. With the hello key, we have associated the value “Hello world!”.

Click on Create.

You now have an Action ready to be executed.

Execute an Action is as easy as this:

ActionRequest actionRequest = new ActionRequest()
    .player(<use_player_id>);

Result<Map<String, Object>> result = gateway.action().run("hello-world", actionRequest);

if (result.isSuccess()) {
    System.out.println(((Map) result.getTarget().get("data")).get("hello"));
}

You can see the full documentation here.

Using with PHP

Install

First, add a dependency in your composer.json file:

{
    "require": {
        "workbandits/gamerocket-php":"1.1.1"
    }
}

Now you can download any outstanding dependencies with:

$ php composer.phar install

PHP usage

Create a Player resource is as simple as this:

<?php

require_once __DIR__ . '/vendor/autoload.php';

GameRocket_Configuration::environment('production');
GameRocket_Configuration::apikey('use_your_apikey');
GameRocket_Configuration::secretkey('use_your_secrekey');

$result = GameRocket_Player::create(array(
    'name' => 'player_name',
    'locale' => 'player_locale' // Ex: en_US
));

if ($result->success) {
    // store $result->player->id in your database
}

Once the player is created, you can execute an Action.

Actions are created using the GameRocket Dashboard. It can be accessed via the CLI:

$ heroku addons:open gamerocket
Opening gamerocket for sharp-mountain-4005...

Click on the Edit button of your game.

Once in your game, click on Actions in the left navigation bar.

Click on “New” at the top of the screen and complete the form:

Ref: hello-world

In the JSON field:

{
    "dynProp": {
    },
    "locales": {
    },
    "name":"Hello world action",
    "secured":false
}

In the Script field:

return ["hello":"Hello world!"]

Scripts are written in Groovy. It’s an agile and dynamic language very similar to JavaScript. Don’t be afraid, it’s really easy!

̀[:] is a key-value structure in Groovy. With the hello key, we have associated the value “Hello world!”.

Click on Create.

You now have an Action ready to be executed.

Execute an Action is as easy as this:

$result = GameRocket_Action::run('hello-world', array(
    'player' => '<use_player_id>'
));

if ($result->success) {
    print_r($result->map->data['hello']);
}

You can see the full documentation here.

Using with .NET

Install

First, in the Package Manager Console:

PM> Install-Package GameRocket

.NET usage

Create a Player resource is as simple as this:

using GameRocket;

public class Constants
{
    public static GameRocketGateway Gateway = new GameRocketGateway
    {
        Environment = GameRocket.Environment.PRODUCTION,
        Apikey = "your_apikey",
        Secretkey = "your_secretkey"
    };
}

PlayerRequest request = new PlayerRequest
{
    Name = "player_name",
    Locale = "player_locale" // Ex: en_US
};

Result<Player> result = Constants.Gateway.Player.Create(request);

if (result.IsSuccess())
{
    // store result.Target.id in your database
}

Once the player is created, you can execute an Action.

Actions are created using the GameRocket Dashboard. It can be accessed via the CLI:

$ heroku addons:open gamerocket
Opening gamerocket for sharp-mountain-4005...

Click on the Edit button of your game.

Once in your game, click on Actions in the left navigation bar.

Click on “New” at the top of the screen and complete the form:

Ref: hello-world

In the JSON field:

{
    "dynProp": {
    },
    "locales": {
    },
    "name":"Hello world action",
    "secured":false
}

In the Script field:

return ["hello":"Hello world!"]

Scripts are written in Groovy. It’s an agile and dynamic language very similar to JavaScript. Don’t be afraid, it’s really easy!

̀[:] is a key-value structure in Groovy. With the hello key, we have associated the value “Hello world!”.

Click on Create.

You now have an Action ready to be executed.

Execute an Action is as easy as this:

ActionRequest request = new ActionRequest
{
    Player = "<use_player_id>"
};

Result<Dictionary<string, object>> result = Constants.Gateway.Action.Run("hello-world", request);

if (result.IsSuccess())
{
    Dictionary<string, object> data = (Dictionary<string, object>)result.Target["data"];
    Console.WriteLine(data["hello"]);
}

You can see the full documentation here.

Monitoring & Logging

GameRocket activity can be observed within the Heroku log-stream by grepping for the string “gamerocket”.

$ heroku logs -t | grep 'gamerocket'

Dashboard

The GameRocket dashboard allows you to see players, manage your game, analyze statistics.

The dashboard can be accessed via the CLI:

$ heroku addons:open gamerocket
Opening gamerocket for sharp-mountain-4005...

or by visiting the Heroku apps web interface and selecting the application in question. Select GameRocket from the Add-ons menu.

Troubleshooting

Plans purchased have an API request limit. If you reach that limit for the month you will start getting errors on your API requests. Make sure to keep an eye on this and upgrade your plan accordingly.

Migrating between plans

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade gamerocket:serious
-----> Upgrading gamerocket:serious to sharp-mountain-4005... done, v18 ($100/mo)
       Your plan has been updated to: gamerocket:serious

Removing the add-on

GameRocket can be removed via the CLI.

This will destroy all associated data and cannot be undone!

$ heroku addons:remove gamerocket
-----> Removing gamerocket from sharp-mountain-4005... done, v20 (free)

Support

All GameRocket support and runtime issues should be submitted via one of the Heroku Support channels. Any non-support related issues or product feedback is welcome at support@gamerocket.io.