メインコンテンツまでスキップ

Integrate challenge interaction in the game client

Last updated on October 23, 2024

Overview

AccelByte Gaming Service (AGS) Challenge allows you to grant virtual rewards to the players upon completion of goals and challenges. This works by integrating with other services within AGS, such as AGS Identity and Access Management (IAM), AGS Statistics, AGS E-Commerce, and AGS Achievements, that will be used to define the goal’s requirements that players must achieve to earn virtual rewards.

This article provides information on how to integrate player challenge interactions and reward claiming using AGS Challenge with the AGS Game SDK.

Prerequisites

  • The AGS Game SDK installed and configured into your Unreal or Unity project.
  • An IAM client set up for your game, and access to that IAM client's ID and secret.
  • Challenges integrated into your project with AGS Challenge.

Evaluate the challenge

備考

You are required to do this step if you use statistics and entitlements in your goal configurations. Otherwise, AGS Challenge will evaluate automatically.

Challenge evaluation is designated to compute the latest progress and status of the given goals. Calling this endpoint retrieves the most recent progress update. You can evaluate the challenge from the game client by using this code:

AccelByte::FMultiRegistry::GetApiClient()->Challenge.EvaluateChallengeProgress(
FVoidHandler::CreateLambda([]()
{
// on evaluate challenge progress success
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT("[%d]: %s"),
ErrorCode, *ErrorMessage);
}));

Claim the reward

Example of Claim specific reward goal UI implementation

You can allow your player to claim rewards for a specific goal that were completed from the game client by using this code:

FAccelByteModelsChallengeRewardClaimRequest RewardClaimRequest{};
// You are able to retrieve reward IDs from this method: Challenge::GetRewards
RewardClaimRequest.RewardIDs = {"RewardId1"};
AccelByte::FMultiRegistry::GetApiClient()->Challenge.ClaimReward(RewardClaimRequest,
THandler<TArray<FAccelByteModelsChallengeReward>>::CreateLambda([]
(const TArray<FAccelByteModelsChallengeReward>& Response)
{
for (auto ChallengeReward : Response)
{
UE_LOG(LogTemp, Warning, TEXT("Item Name: %s Qty: %f"),
*ChallengeReward.ItemName, ChallengeReward.Qty);
}
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT("[%d]: %s"),
ErrorCode, *ErrorMessage);
}));

Claim all rewards

Example of Claim all reward goal UI implementation

You can allow your player to claim all rewards from completed goals under a specific challenge from the game client by using this code:

FAccelByteModelsChallengeRewardClaimRequest RewardClaimRequest{};
// You are able to retrieve rewards IDs from this method: Challenge::GetRewards
RewardClaimRequest.RewardIDs = {"RewardCompletedId1", "RewardCompletedId2"};
AccelByte::FMultiRegistry::GetApiClient()->Challenge.ClaimReward(RewardClaimRequest,
THandler<TArray<FAccelByteModelsChallengeReward>>::CreateLambda([]
(const TArray<FAccelByteModelsChallengeReward>& Response)
{
for (auto ChallengeReward : Response)
{
UE_LOG(LogTemp, Warning, TEXT("Item Name: %s Qty: %f"),
*ChallengeReward.ItemName, ChallengeReward.Qty);
}
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT("[%d]: %s"),
ErrorCode, *ErrorMessage);
}));