// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Standard Library
using System;
// GameKit
using AWS.GameKit.Common.Models;
using AWS.GameKit.Runtime.FeatureUtils;
using AWS.GameKit.Runtime.Models;
namespace AWS.GameKit.Runtime.Features.GameKitAchievements
{
///
/// Achievements feature.
///
public class Achievements : GameKitFeatureBase, IAchievementsProvider
{
public override FeatureType FeatureType => FeatureType.Achievements;
///
/// Call to get an instance of the GameKit Achievements feature.
///
/// An instance of the Achievements feature that can be used to call Achievement related methods.
public static Achievements Get()
{
return GameKitFeature.Get();
}
///
/// Lists non-hidden achievements, and will call delegates after every page.
///
/// Secret achievements will be included, and developers will be responsible for processing those as they see fit.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_HTTP_REQUEST_FAILED: The backend HTTP request failed. Check the logs to see what the HTTP response code was.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The backend returned a malformed JSON payload. This should not happen. If it does, it indicates there is a bug in the backend code.
///
/// Object containing call preferences
/// Delegate that is called while the function is executing, once for each page of achievements
/// Delegate that is called once the function has finished executing
public void ListAchievementsForPlayer(ListAchievementsDesc listAchievementsDesc, Action callback, Action onCompleteCallback)
{
Call(Feature.ListAchievements, listAchievementsDesc, callback, onCompleteCallback);
}
///
/// Gets the specified achievement for currently logged in user, and passes it to ResultDelegate
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_HTTP_REQUEST_FAILED: The backend HTTP request failed. Check the logs to see what the HTTP response code was.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The backend returned a malformed JSON payload. This should not happen. If it does, it indicates there is a bug in the backend code.
/// - GAMEKIT_ERROR_ACHIEVEMENTS_INVALID_ID: The Achievement ID given is empty or malformed.
///
/// Identifier of the achievement to return
/// Delegate that is called once the function has finished executing
public void GetAchievementForPlayer(string achievementId, Action callback)
{
Call(Feature.GetAchievement, achievementId, callback);
}
///
/// Increments the currently logged in user's progress on a specific achievement.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_HTTP_REQUEST_FAILED: The backend HTTP request failed. Check the logs to see what the HTTP response code was.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The backend returned a malformed JSON payload. This should not happen. If it does, it indicates there is a bug in the backend code.
///
/// Object containing the identifier of the achievement and how much to increment by
/// Delegate that is called once the function has finished executing
public void UpdateAchievementForPlayer(UpdateAchievementDesc updateAchievementDesc, Action callback)
{
Call(Feature.UpdateAchievement, updateAchievementDesc, callback);
}
///
/// Gets the AWS CloudFront url which all achievement icons for this game/environment can be accessed from.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
///
/// Delegate that is called once the function has finished executing
public void GetAchievementIconBaseUrl(Action callback)
{
Call(Feature.GetAchievementIconsBaseUrl, callback);
}
}
}