Creating Stackable Items #

In this section, we’ll be creating a stackable item of gold coins to purchase items in a store.


Get started #

Run the following commands in the terminal from the platform directory to build the engine and make 5-ext if it doesn’t already exist:

  1. make skip-tests protos engine
  2. make ext

Define stackable item specs #

  1. Go to 5-ext/content/src/StackableSpecs.json and add the following code to create a gold_coins stackable item:
[
  {
    "catalogId": "gold_coins",
    "name": "gold_coins",
    "limit":  100000000,
    "tags": ["currency"],
    "removeIfNone": false
  }
]

Stackable items are items with no special properties. Each item in the stack is identical.

Apply content data #

In order to register the content you just defined with Pragma Engine, you must apply your content data changes. You may apply content data either using the command line with make or via an IntelliJ run configuration.

Applying content data using Make

In a terminal with platform as the working directory, run:

make ext-contentdata-apply
Applying content data using IntelliJ
From the IntelliJ toolbar in the upper right, ensure contentdata apply is selected, then click the play button.

Test the stackable item in Postman #

In this section, we’ll test our stackable items by running API calls in Postman.

Start Pragma Engine #

Run Pragma Engine via one of the following methods.

Running via Make
Run make run to start the platform. Run this in a terminal with platform as the working directory.
Running in IntelliJ

From the IntelliJ toolbar in the upper right, ensure MainKt - LocalConfigured is selected, then click the play button.

If MainKt - LocalConfigured isn’t available, you will need to configure it. In the IntelliJ toolbar, click the dropdown next to the run button, then click Edit Configurations…. In the Run/Debug Configurations window that appears, expand Kotlin in the left hand side, then select MainKt - LocalConfigured. Click OK. Click the play button in the IntelliJ toolbar to start Pragma Engine.

Once the engine has started successfully, it prints the message [main] INFO main - Pragma server startup complete.

Simulate granting a player a gold coin #

  1. Open Postman.
  2. Navigate to the two service calls PragmaDev ➨ Public ➨ Operator - AuthenticateOrCreateV2 and PragmaDev ➨ Public ➨ Player - AuthenticateOrCreateV2.
  3. Click Send for both service calls and check that the response body for each call has pragmaTokens with a filled pragmaGameToken and pragmaSocialToken.
  4. Open Game➨RPC - Operator➨Inventory➨GrantItemsOperatorV1 and edit the body with the following payload:
  • Find the stackable object and fill the catalogId with the value gold_coins.
  • Then fill the amount with a value of 1.
  1. Click Send and check the response body to see if gold_coins are present in the object’s delta and segment payloads. If the amount of gold_coins is now 1, we have successfully granted a gold coin to our player.