Пример #1
0
 public object Get(GetUserStatisticsRequest request)
 {
     return(new GetUserStatisticsResponse
     {
         UserStatistics = GetUserStatistics(request.UserId, request.NumberOfDaysBack),
     });
 }
Пример #2
0
        public void UserStatisticsApi()
        {
            int testStatExpected, testStatActual;

            var getRequest   = new GetUserStatisticsRequest();
            var getStatTask1 = PlayFabClientAPI.GetUserStatisticsAsync(getRequest);

            WaitForResultSuccess(getStatTask1, "UserStatistics should have been retrieved from Api call");
            if (!getStatTask1.Result.Result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatExpected))
            {
                testStatExpected = TEST_STAT_BASE;
            }
            testStatExpected = ((testStatExpected + 1) % TEST_STAT_BASE) + TEST_STAT_BASE; // This test is about the expected value changing (incrementing through from TEST_STAT_BASE to TEST_STAT_BASE * 2 - 1)

            var updateRequest = new UpdateUserStatisticsRequest();

            updateRequest.UserStatistics = new Dictionary <string, int>();
            updateRequest.UserStatistics[TEST_STAT_NAME] = testStatExpected;
            var updateTask = PlayFabClientAPI.UpdateUserStatisticsAsync(updateRequest);

            WaitForResultSuccess(updateTask, "UpdateUserStatistics failed");

            getRequest = new GetUserStatisticsRequest();
            var getStatTask2 = PlayFabClientAPI.GetUserStatisticsAsync(getRequest);

            WaitForResultSuccess(getStatTask2, "UserStatistics should have been retrieved from Api call");
            getStatTask2.Result.Result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatActual);
            UUnitAssert.IntEquals(testStatExpected, testStatActual);
        }
Пример #3
0
    // Example for getting the user statistics for a player.
    IEnumerator GetUserStats(float sec = 0)
    {
        yield return(new WaitForSeconds(sec));

        GetUserStatisticsRequest request = new GetUserStatisticsRequest();

        PlayFabClientAPI.GetUserStatistics(request, OnGetUserStatsSuccess, OnPlayFabError);
    }
Пример #4
0
        public static void GetUserStatistics(string playFabId)
        {
            var request = new GetUserStatisticsRequest();

            request.PlayFabId = playFabId;
            PlayFabServerAPI.GetUserStatistics(request, GetUserStatisticsCallback,
                                               PfSharedControllerEx.FailCallback("GetUserStatistics"));
        }
Пример #5
0
//	public void UpdatePlayerXP(int xp) {
//		UpdateUserDataRequest updateReq = new UpdateUserDataRequest ();
//		updateReq.Data = new System.Collections.Generic.Dictionary<string, string> ();
//		updateReq.Data.Add("XP", xp.ToString());
//		PlayFabClientAPI.UpdateUserData (updateReq, OnUpdatePlayerXPSuccess, OnPlayFabError);
//	}

//	private IEnumerator GetPlayerData(float sec = 0) {
//		yield return new WaitForSeconds (sec);
//		GetUserCombinedInfoRequest infoReq = new GetUserCombinedInfoRequest ();
//		PlayFabClientAPI.GetUserCombinedInfo (infoReq, OnPlayFabGetUserInfo, OnPlayFabError);
//	}

    private IEnumerator CoGetPlayerXP(float sec = 0)
    {
        yield return(new WaitForSeconds(sec));

        GetUserStatisticsRequest xpReq = new GetUserStatisticsRequest();

        PlayFabClientAPI.GetUserStatistics(xpReq, OnPlayFabGetUserStatistics, OnPlayFabError);
    }
Пример #6
0
        private void UpdateUserStatsCallback(UpdateUserStatisticsResult result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            var getRequest = new GetUserStatisticsRequest();

            PlayFabClientAPI.GetUserStatistics(getRequest, PlayFabUUnitUtils.ApiActionWrapper <GetUserStatisticsResult>(testContext, GetUserStatsCallback2), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Пример #7
0
        public void UserStatisticsApi(UUnitTestContext testContext)
        {
            if (!TITLE_CAN_UPDATE_SETTINGS)
            {
                testContext.EndTest(UUnitFinishState.SKIPPED, "This title cannot update statistics from the client");
                return;
            }

            var getRequest = new GetUserStatisticsRequest();

            PlayFabClientAPI.GetUserStatistics(getRequest, PlayFabUUnitUtils.ApiActionWrapper <GetUserStatisticsResult>(testContext, GetUserStatsCallback1), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Пример #8
0
        private void populateContainers()
        {
            publishedGames.Clear();
            statisticsContainer.Clear();
            var games = new GetAllUserPublishedGamesRequest();

            games.Success += (u) =>
            {
                foreach (var game in u)
                {
                    publishedGames.Add(new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = 400,
                        Children         = new Drawable[]
                        {
                            new GamePreviewContainer(game)
                            {
                                GameNameSize = 90,
                                MadeBySize   = 60
                            }
                        },
                    });
                }
            };
            api.Queue(games);

            var stats = new GetUserStatisticsRequest();

            stats.Success += (u) =>
            {
                foreach (var stat in u)
                {
                    statisticsContainer.Add(new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = 300,
                        Child            = new StatisticContainer(stat)
                    });
                }
            };
            api.Queue(stats);
        }
        public void UserStatisticsApi()
        {
            int testStatExpected, testStatActual;

            var getRequest = new GetUserStatisticsRequest();

            PlayFabClientAPI.GetUserStatistics(getRequest, GetUserStatsCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.Equals("User Stats Received", lastReceivedMessage);
            testStatExpected = ((testStatReturn + 1) % TEST_STAT_BASE) + TEST_STAT_BASE; // This test is about the expected value changing (incrementing through from TEST_STAT_BASE to TEST_STAT_BASE * 2 - 1)

            var updateRequest = new UpdateUserStatisticsRequest();

            updateRequest.UserStatistics = new Dictionary <string, int>();
            updateRequest.UserStatistics[TEST_STAT_NAME] = testStatExpected;
            PlayFabClientAPI.UpdateUserStatistics(updateRequest, UpdateUserStatsCallback, SharedErrorCallback);
            WaitForApiCalls();

            // Test update result - no data returned, so error or no error, based on Title settings
            if (!TITLE_CAN_UPDATE_SETTINGS)
            {
                UUnitAssert.Equals("error message from PlayFab", lastReceivedMessage);
                return; // The rest of this tests changing settings - Which we verified we cannot do
            }
            else // if (CAN_UPDATE_SETTINGS)
            {
                UUnitAssert.Equals("User Stats Updated", lastReceivedMessage);
            }

            getRequest = new GetUserStatisticsRequest();
            PlayFabClientAPI.GetUserStatistics(getRequest, GetUserStatsCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.Equals("User Stats Received", lastReceivedMessage);
            testStatActual = testStatReturn;
            UUnitAssert.Equals(testStatExpected, testStatActual);
        }
Пример #10
0
        public static void GetUserStatistics()
        {
            var request = new GetUserStatisticsRequest();

            PlayFabClientAPI.GetUserStatistics(request, GetUserStatisticsCallback, PfSharedControllerEx.FailCallback("GetUserStatistics"));
        }
Пример #11
0
    /// <summary>
    /// Method used to get user statistics from PlayFab.
    /// </summary>
    public void GetUserStatistics()
    {
        GetUserStatisticsRequest request = new GetUserStatisticsRequest();

        PlayFabClientAPI.GetUserStatistics(request, OnUserStatisticsLoaded, OnGetUserStatisticsError);
    }