Setting Up the Content Catalog #

In this section, we’ll be defining the protos that build out a battlepass specification, and build out a proto as an example to build a specific battlepass.


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 battlepass concepts with protobufs #

In this section, we’ll build out the blueprint of a battlepass using protos. Later, we’ll build on these blueprints when we add content for a specific battlepass using JSON files.

Edit the inventory content ext file #

This is where we’ll create the battlepass specifications by defining:

  • 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
  1. Open 5-ext/ext-protos/src/main/proto/shared/inventoryContentExt.proto.
  2. Edit extInstancedSpec by inserting the following oneof:
message ExtInstancedSpec {
    oneof data {
        BattlepassSpec battlepass_spec = 1;
    }
}
  1. Add the following messages to define the battlepass spec, level spec, and server-based rewards:
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;
}

Edit the inventory ext file #

This is where we’ll define attributes of a specific battlepass, which should contain a level and XP.

  1. Open 5-ext/ext-protos/src/main/proto/shared/inventoryExt.proto.
  2. Edit ExtInstancedItem by inserting the following oneof:
message ExtInstancedItem  {
   oneof data {
       Battlepass battlepass = 1;
   }
}
  1. Add the battlepass definition.
message Battlepass {
   int64 xp = 1;
   int64 level = 2;
}

Edit the inventory RPC ext file #

This is where we’ll define the way a battlepass updates XP.

  1. Open 5-ext/ext-protos/src/main/proto/shared/inventoryRpcExt.proto.
  2. Edit ExtInstancedItemServerUpdate by inserting the following oneof and proto message:
message ExtInstancedItemServerUpdate {
   oneof data {
       BattlepassXp xp_update = 1;
   }
}

message BattlepassXp {
   int64 amount = 1;
}

Build #

Run make ext using a terminal from the platform directory.

Define the battlepass content files #

Now that we’ve finished defining the structural pieces of a battlepass, we can author the actual battlepass specifications.

If you do not already have the content source files initialized, run make init-inventory-content using a terminal from the platform directory.

Define a battlepass instanced item #

This is where we’ll create a battlepass item with a valid start and end time, levels and XP, and rewards per level.

  1. Add the following code to the contents of platform/5-ext/content/src/InstancedSpecs.json:
[
  {
    "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 and earn a reward.

  1. Add the following code to the contents of platform/5-ext/content/src/StackableSpecs.json:
[
  {
    "catalogId": "gold_coins",
    "name": "gold coins",
    "limit": 1000000,
    "tags": ["currency"],
    "removeIfNone": false
  }
]

Define limited grants #

This is where we’ll create the on-login grant for the battlepass instanced item.

  1. Add the following code to the contents of platform/5-ext/content/src/LimitedGrants.json:
[
  {
    "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.

  1. Add the following code to the contents of platform/5-ext/content/src/UpdateEntries.json:
[
 {
   "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.

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.