Setting Up the Content Catalog #
In this section we’ll be creating the protos that define a battlepass specification, and then we’ll build on these when we add content for a specific battlepass using JSON files.
Getting 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:
make skip-tests protos engine
make ext
Define the battlepass specification with protos #
First let’s create the structure of a battlepass using protos.
Define the battlepass specification #
This is where we’ll define the battlepass specification that includes:
- the ability to set a start and end time
- a level spec with the ability to set the XP required to complete a level
- rewards which can be instanced or stackable items
- Open the
5-ext/ext-protos/src/main/proto/shared/inventoryContentExt.proto
file. - Add the following messages that define the battlepass specification to the bottom of the file:
message BattlepassSpec {
repeated BattlepassLevelSpec levels = 1;
int64 start_unix_timestamp = 2;
int64 end_unix_timestamp = 3;
}
message BattlepassLevelSpec {
int32 xp_to_complete = 1;
repeated Reward rewards = 2;
}
message Reward {
oneof item {
InstancedServerReward instanced = 1;
StackableServerReward stackable = 2;
}
}
message InstancedServerReward {
string catalog_id = 1;
}
message StackableServerReward {
string catalog_id = 1;
int64 amount = 2;
}
- Declare the battlepass specification as an instanced spec by editing the
extInstancedSpec
and inserting the followingoneof
:
message ExtInstancedSpec {
oneof data {
BattlepassSpec battlepass_spec = 1;
}
}
Define the battlepass instanced item #
This is where we’ll define attributes of a specific battlepass, which should contain a level and XP.
- Open the
5-ext/ext-protos/src/main/proto/shared/inventoryExt.proto
file. - Add the battlepass definition message to the bottom of the file:
message Battlepass {
int64 xp = 1;
int64 level = 2;
}
- Declare the battlepass as an instanced item by editing the
ExtInstancedItem
and inserting the followingoneof
:
message ExtInstancedItem {
oneof data {
Battlepass battlepass = 1;
}
}
Define the battlepass update message #
This is where we’ll define the way a battlepass updates XP.
- Open the
5-ext/ext-protos/src/main/proto/shared/inventoryRpcExt.proto
file. - Define a message that will be used to update the battlepass to the bottom of the file, in the case the amount of XP gained:
message BattlepassXp {
int64 amount = 1;
}
- Declare the update message as an instanced item server update by editing
ExtInstancedItemServerUpdate
and inserting the followingoneof
:
message ExtInstancedItemServerUpdate {
oneof data {
BattlepassXp xp_update = 1;
}
}
Build the specification #
Run make ext
using a terminal from the platform
directory.
Define the battlepass content with JSON files #
Now that we’ve finished defining the structural pieces of a battlepass, we can author the actual battlepass content.
If you do not already have the content source files initialized, runmake init-inventory-content
using a terminal from theplatform
directory.
Define a battlepass instanced item #
This is where we’ll create a real battlepass item using the specifications we made earlier with valid start and end times, levels and XP, and rewards per level.
- Open the
5-ext/content/src/InstancedSpecs.json
file. - Replace the contents with the following JSON to create a battlepass called “Season 1 Battlepass”:
[
{
"catalogId": "battlepass_season1",
"name": "Season 1 Battlepass",
"tags": [],
"ext": {
"battlepassSpec": {
"startUnixTimestamp": 1648796400000,
"endUnixTimestamp": 1659337199999,
"levels": [
{
"xpToComplete": 100,
"rewards": [
{
"stackable": {
"catalogId": "gold_coins",
"amount": 150
}
}
]
},
{
"xpToComplete": 125,
"rewards": [
{
"stackable": {
"catalogId": "gold_coins",
"amount": 150
}
}
]
}
]
}
}
}
]
Define a stackable item reward #
This is where we’ll create the gold coins item that we give players when they gain enough XP to advance levels in the battlepass.
- Open the
5-ext/content/src/StackableSpecs.json
file. - Replace the contents with the following JSON to create a gold coin stackable item:
[
{
"catalogId": "gold_coins",
"name": "gold coins",
"limit": 1000000,
"tags": [
"currency"
],
"removeIfNone": false
}
]
Define limited grants #
This is where we’ll create the on-login limited grant that will give players our Season 1 Battlepass.
- Open the
5-ext/content/src/LimitedGrants.json
file. - Replace the contents with the following JSON to create the battlepass limited grant:
[
{
"trackingId": "battlepass_tracker",
"instancedGrants": [
{
"catalogId": "battlepass_season1"
}
]
}
]
Define an update entry #
This is where we’ll create the entry that enables a battlepass update system, which allows players to progress through levels.
- Open the
5-ext/content/src/UpdateEntries.json
file. - Replace the contents with the following JSON to create the battlepass update entry:
[
{
"id": "battlepass-update",
"costByCatalogId": {},
"tags": [],
"ext": {}
}
]
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.