コード例 #1
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Submits the results of the match. You must stuff the match result into a dictionary that will be parsed and passed to the SDK API servers..
    /// Current parameters:
    ///     matchID
    ///     tournamentID
    ///     score
    /// </summary>
    /// <returns>
    /// True if the match results were submitted.
    /// </returns>
    /// <param name="matchResult">
    /// A dictionary filled with values the SDK needs to use to properly pass the result to the API servers. Examples: score, tournamentID, matchID, etc.
    /// </param>
    public static bool SubmitMatchResult(Dictionary <string, object> matchResult)
    {
        if (matchResult == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "submitting undefined match result");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "submitting match result: " + FuelSDKCommon.Serialize(matchResult));
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            JSONClass matchResultJSON = FuelSDKCommon.toJSONClass(matchResult);

            if (matchResultJSON == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "unable to coerce match result dictionary into a JSON class");
            }
            else
            {
                succeeded = GetFuelSDKPlatform().SubmitMatchResult(matchResultJSON.ToString());
            }
        }

        if (succeeded)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "match result was submitted");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "match result was not submitted");
        }

        return(succeeded);
    }