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:
make skip-tests protos engine
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
- Open
5-ext/ext-protos/src/main/proto/shared/inventoryContentExt.proto
. - Edit
extInstancedSpec
by inserting the followingoneof
:
message ExtInstancedSpec {
oneof data {
BattlepassSpec battlepass_spec = 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.
- Open
5-ext/ext-protos/src/main/proto/shared/inventoryExt.proto
. - Edit
ExtInstancedItem
by inserting the followingoneof
:
message ExtInstancedItem {
oneof data {
Battlepass battlepass = 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.
- Open
5-ext/ext-protos/src/main/proto/shared/inventoryRpcExt.proto
. - Edit
ExtInstancedItemServerUpdate
by inserting the followingoneof
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, runmake init-inventory-content
using a terminal from theplatform
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.
- 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.
- 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.
- 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.
- 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.