A new Player Data service has been released that is more up to date and supported with this current release of Pragma Engine. We recommend you check it out by viewing the Player Data Overview page.

Purchasing Stackable Items in a Store #

In this section, we’ll create a store with items to purchase with our gold coins. For demonstration purposes, we’ll be manually simulating service calls with Postman.

Prerequisites:


Create stackable ores #

  1. Open 5-ext/content/src/StackableSpecs.json.
  2. Edit the JSON to add in copper_ore, tin_ore, and iron_ore:
The stackable item gold_coins should have been previously added in the Creating Stackable Items section.
[
  {
    "catalogId": "gold_coins",
    "name": "gold coins",
    "limit": 1000000,
    "tags": ["currency"],
    "removeIfNone": false
  },

  {
    "catalogId": "copper_ore",
    "name": "copper ore",
    "limit": 1000000,
    "tags": ["resource"],
    "removeIfNone": true
  },

  {
    "catalogId": "tin_ore",
    "name": "tin ore",
    "limit": 1000000,
    "tags": ["resource"],
    "removeIfNone": true
  },

  {
    "catalogId": "iron_ore",
    "name": "iron ore",
    "limit": 1000000,
    "tags": ["resource"],
    "removeIfNone": true
  }
]

Create a store #

  1. Open 5-ext/content/src/Stores.json.
  2. Add the following code to create a store called shopkeeper:
[
  {
    "id": "shopkeeper",
    "name": "Shopkeeper",
    "storeEntries": []
  }
]
  1. Add the following entries into the storeEntries square brackets to give our shopkeeper 6 possible item transactions:
{
  "id": "buy_copper_ore",
  "receivedQuantityByCatalogId": {
    "copper_ore": 1
  },
  "costByCatalogId": {
    "gold_coins": {
      "cost": 30
    }
  }
},
{
  "id": "sell_copper_ore",
  "receivedQuantityByCatalogId": {
    "gold_coins": 30
  },
  "costByCatalogId": {
    "copper_ore": {
      "cost": 1
    }
  }
},
{
  "id": "buy_tin_ore",
  "receivedQuantityByCatalogId": {
    "tin_ore": 1
  },
  "costByCatalogId": {
    "gold_coins": {
      "cost": 20
    }
  }
},
{
  "id": "sell_tin_ore",
  "receivedQuantityByCatalogId": {
    "gold_coins": 20
  },
  "costByCatalogId": {
    "tin_ore": {
      "cost": 1
    }
  }
},
{
  "id": "buy_iron_ore",
  "receivedQuantityByCatalogId": {
    "iron_ore": 1
  },
  "costByCatalogId": {
    "gold_coins": {
      "cost": 10
    }
  }
},
{
  "id": "sell_iron_ore",
  "receivedQuantityByCatalogId": {
    "gold_coins": 10
  },
  "costByCatalogId": {
    "iron_ore": {
      "cost": 1
    }
  }
}

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.

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 purchasing ores #

  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 given us pragmaTokens with a filled pragmaGameToken and pragmaSocialToken.
  4. Open PragmaDev ➨ Game ➨ RPC - Operator ➨Inventory ➨ GrantItemsOperatorV1 and edit catalogId to have a value of gold_coins and amount with 1000. This ensures the player has enough currency when purchasing stackable items from the store we’ve just created.
  5. Navigate to PragmaDev ➨ Game ➨ RPC - Player ➨ Inventory ➨ StorePurchaseV4.
  • Edit the storeId to have the value shopkeeper.
  • Edit the storeEntryId to have the value buy_copper_ore.
  • Edit the amount to have the value 5.
  1. Click Send to purchase 5 copper ores.
  2. Repeat steps 5-6 two more times, replacing buy_copper_ore with buy_iron_ore and then buy_tin_ore.
  3. Confirm the player has the items (5 copper_ore, 5 iron_ore, and 5 tin_ore) they’ve purchased in their inventory by using the GetInventoryOperatorV1 call.