Skip to content

GCP.GamesConfiguration reference

Source: src/GCP/GamesConfiguration/AchievementConfiguration.ts

A Play Games Services achievement configuration.

Achievement configurations have no labels field and a server-assigned id, so only a recorded achievement can be read back. applicationId and achievementId are identity — changing either replaces the configuration. achievementType is immutable after create. Name, description, initial state, steps, and point value update in place.

AchievementConfiguration: Creating an Achievement

Section titled “AchievementConfiguration: Creating an Achievement”

Standard achievement

const achievement = yield* GCP.GamesConfiguration.AchievementConfiguration(
"FirstWin",
{
applicationId: "123456789012",
name: "First Win",
description: "Win your first match",
},
);

Incremental achievement

const achievement = yield* GCP.GamesConfiguration.AchievementConfiguration(
"Centurion",
{
applicationId: "123456789012",
achievementType: "INCREMENTAL",
stepsToUnlock: 100,
name: "Centurion",
description: "Win 100 matches",
pointValue: 20,
},
);

AchievementConfiguration: Updating an Achievement

Section titled “AchievementConfiguration: Updating an Achievement”
// Same logical id as before; only the changed props differ.
const achievement = yield* GCP.GamesConfiguration.AchievementConfiguration(
"FirstWin",
{
applicationId: "123456789012",
name: "First Win",
description: "Win a match",
},
);

Source: src/GCP/GamesConfiguration/LeaderboardConfiguration.ts

A Play Games Services leaderboard configuration.

Leaderboard configurations have no labels field and a server-assigned id, so only a recorded leaderboard can be read back. applicationId and leaderboardId are identity — changing either replaces the configuration. Score order, bounds, name, and format update in place.

LeaderboardConfiguration: Creating a Leaderboard

Section titled “LeaderboardConfiguration: Creating a Leaderboard”

High-score board

const board = yield* GCP.GamesConfiguration.LeaderboardConfiguration(
"HighScore",
{
applicationId: "123456789012",
name: "High Score",
scoreOrder: "LARGER_IS_BETTER",
},
);

Fastest-time board

const board = yield* GCP.GamesConfiguration.LeaderboardConfiguration(
"BestTime",
{
applicationId: "123456789012",
name: "Best Time",
scoreOrder: "SMALLER_IS_BETTER",
scoreFormat: { numberFormatType: "TIME_DURATION" },
},
);

LeaderboardConfiguration: Updating a Leaderboard

Section titled “LeaderboardConfiguration: Updating a Leaderboard”
// Same logical id as before; only the changed props differ.
const board = yield* GCP.GamesConfiguration.LeaderboardConfiguration(
"HighScore",
{
applicationId: "123456789012",
name: "All-time High Score",
},
);