Example #1
0
 public static void FetchTournaments(SuccessHandler success, FriendlyErrorHandler failure)
 {
     fetchedTournamentsCallback = () => {
         success();
     };
     ArbiterBinding.FetchTournaments(FetchTournamentsSuccessHandler, failure);
 }
Example #2
0
    void Start()
    {
        if (accessToken.Length == 0 || gameApiKey.Length == 0)
        {
            Debug.LogWarning("Arbiter Error: Missing Access Token or Game Api Key in the Arbiter Prefab inpesctor settings.");
        }

        _accessToken = accessToken;
        _gameApiKey  = gameApiKey;

        var arbiters = FindObjectsOfType(typeof(Arbiter));

        if (arbiters.Length > 1)
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);


        GameObject abGO = new GameObject("ArbiterBinding");

        abGO.AddComponent <ArbiterBinding>();
        GameObject.DontDestroyOnLoad(abGO);

        wallet = null;
        user   = null;

        ErrorHandler initializeErrorHandler = (errors) => {
            Debug.LogError("Cannot initialize Arbiter. Resolve errors below:");
            errors.ForEach(e => Debug.LogError(e));
        };

        ArbiterBinding.Init(_gameApiKey, _accessToken, InitializeSuccess, initializeErrorHandler);
    }
Example #3
0
 public static void ReportScore(string tournamentId, int score, ReportScoreCallback callback)
 {
     if (callback == null)
     {
         Debug.LogError("Must pass in a non-null handler to Arbiter.ReportScore");
     }
     ArbiterBinding.ReportScore(tournamentId, score, callback, defaultErrorHandler);
 }
Example #4
0
 public static void RequestCashChallenge(Dictionary <string, string> filters, RequestCashChallengeCallback callback, FriendlyErrorHandler failure)
 {
     if (filters == null)
     {
         filters = new Dictionary <string, string>();
     }
     ArbiterBinding.RequestCashChallenge(filters, callback, failure);
 }
Example #5
0
 public static void RequestTournament(string buyIn, Dictionary <string, string> filters, SuccessHandler callback, FriendlyErrorHandler failure)
 {
     if (filters == null)
     {
         filters = new Dictionary <string, string>();
     }
     ArbiterBinding.RequestTournament(buyIn, filters, callback, failure);
 }
Example #6
0
 public static void ShowIncompleteTournaments(ShowIncompleteTournamentsCallback callback)
 {
     if (callback == null)
     {
         callback = (tournamentId) => {}
     }
     ;
     ArbiterBinding.ShowIncompleteTournaments(callback);
 }
Example #7
0
 public static void ShowUnviewedTournaments(SuccessHandler callback)
 {
     if (!UserExists)
     {
         Debug.LogWarning("Make sure user is logged in before showing their unviewed tournaments!");
         return;
     }
     ArbiterBinding.ShowUnviewedTournaments(callback, defaultErrorHandler);
 }
Example #8
0
    private static void tryFetchWallet(SuccessHandler success, ErrorHandler failure)
    {
        if (!IsAuthenticated)
        {
            Debug.LogWarning("Cannot get an Arbiter Wallet without first logging in");
            return;
        }

        ArbiterBinding.FetchWallet(success, failure);
    }
Example #9
0
    public static void JoinTournament(string buyIn, Dictionary <string, string> filters, JoinTournamentCallback success, FriendlyErrorHandler failure)
    {
        Func <Tournament, bool> isScorableByCurrentUser = (tournament) => {
            return((tournament.Status == Tournament.StatusType.Initializing ||
                    tournament.Status == Tournament.StatusType.InProgress) &&
                   tournament.UserCanReportScore(user.Id));
        };

        TournamentsCallback gotTournamentsPollHelper = (tournaments) => {
            List <Tournament> joinableTournaments = tournaments.Where(iTourn => isScorableByCurrentUser(iTourn)).ToList();
            if (joinableTournaments.Count > 0)
            {
                tournamentPoller.Stop();
                success(joinableTournaments[0]);
            }
            // Else wait for the poller to call this anon func again...
        };

        int       retries     = 0;
        const int MAX_RETRIES = 6;
        Action    askAgain    = () => {
            retries++;
            if (retries > MAX_RETRIES)
            {
                List <string> errors = new List <string>();
                errors.Add("Tournament request limit exceeded. Ceasing new requests.");
                List <string> descriptions = new List <string>();
                descriptions.Add("The tournament timed-out. Please try again later.");
                failure(errors, descriptions);
                tournamentPoller.Stop();
            }
            else
            {
                ArbiterBinding.FetchTournaments(gotTournamentsPollHelper, failure);
            }
        };

        SuccessHandler gotRequestResponse = () => {
            tournamentPoller.SetAction(askAgain);
        };

        TournamentsCallback gotTournamentsFirstTimeHelper = (tournaments) => {
            List <Tournament> joinableTournaments = tournaments.Where(iTourn => isScorableByCurrentUser(iTourn)).ToList();
            if (joinableTournaments.Count > 0)
            {
                success(joinableTournaments[0]);
            }
            else
            {
                RequestTournament(buyIn, filters, gotRequestResponse, failure);
            }
        };

        ArbiterBinding.FetchTournaments(gotTournamentsFirstTimeHelper, failure);
    }
Example #10
0
    /// <summary>
    /// This is only necessary to call if there is no cached user credentials on device. But calling it redundantly is harmless.
    /// </summary>
    public static void LoginWithDeviceId(SuccessHandler success, ErrorHandler failure)
    {
        SuccessHandler successWrapper = () => {
            FirePostAuthenticateActionsIfAble();
            if (success != null)
            {
                success();
            }
        };

        WaitUntilInitted(() => {
            ArbiterBinding.LoginWithDeviceId(successWrapper, failure);
        });
    }
Example #11
0
 /// <summary>
 /// A debug logger that adds the given custom data to some state in the SDK and logs in Arbiter debug servers.
 /// </summary>
 /// <param name="gameDataToInclude">Game data to include with the debug log report.</param>
 public static void DumpLogs(string logData)
 {
     ArbiterBinding.DumpLogs(logData);
 }
Example #12
0
 public static void ShowWalkThrough(string walkThroughId, SuccessHandler callback)
 {
     ArbiterBinding.ShowWalkThrough(walkThroughId, callback);
 }
Example #13
0
 private static void ShowNativeDialog(string title, string message)
 {
     ArbiterBinding.ShowNativeDialog(title, message, nativeDialogCallback);
 }
Example #14
0
 public static void ReportScoreForChallenge(string challengeId, string score, Arbiter.ReportScoreForChallengeCallback success, FriendlyErrorHandler failure)
 {
     ArbiterBinding.ReportScoreForChallenge(challengeId, score, success, failure);
 }
Example #15
0
 public static void ShowCashChallengeRules(string challengeId, SuccessHandler callback)
 {
     ArbiterBinding.ShowCashChallengeRules(challengeId, callback);
 }
Example #16
0
 public static void Logout(SuccessHandler success, ErrorHandler failure)
 {
     wallet = null;
     user   = null;
     ArbiterBinding.Logout(success, failure);
 }
Example #17
0
 public static void RejectCashChallenge(string challengeId, SuccessHandler success)
 {
     ArbiterBinding.RejectCashChallenge(challengeId, success);
 }
Example #18
0
 public static void DisplayWalletDashboardOnDepositTab(SuccessHandler callback)
 {
     ArbiterBinding.ShowWalletPanelOnDepositTab(callback);
     walletPoller.Reset();
 }
Example #19
0
 public static void AcceptCashChallengeUseNativeErrorDialogue(string challengeId, SuccessHandler success, SuccessHandler errorDialogueComplete)
 {
     nativeDialogCallback = errorDialogueComplete;
     ArbiterBinding.AcceptCashChallenge(challengeId, success, ShowDescriptionInNativeAlert);
 }
Example #20
0
 public static void LoginWithGameCenter(SuccessHandler success, ErrorHandler failure)
 {
     WaitUntilInitted(() => {
         ArbiterBinding.LoginWithGameCenter(success, failure);
     });
 }
Example #21
0
 public static void SendPromoCredits(string amount, SuccessHandler success, ErrorHandler failure)
 {
     ArbiterBinding.SendPromoCredits(amount, success, failure);
     walletPoller.Reset();
 }
Example #22
0
 public static void AcceptCashChallenge(string challengeId, SuccessHandler success, FriendlyErrorHandler failure)
 {
     ArbiterBinding.AcceptCashChallenge(challengeId, success, failure);
 }
Example #23
0
 public static void ShowPreviousTournaments(SuccessHandler callback)
 {
     ArbiterBinding.ShowPreviousTournaments(callback, defaultErrorHandler);
 }
Example #24
0
 public static void ShowTournamentDetails(string tournamentId, SuccessHandler callback)
 {
     ArbiterBinding.ShowTournamentDetailsPanel(tournamentId, callback);
 }
Example #25
0
 internal static void DumpLogs()
 {
     ArbiterBinding.DumpLogs("");
 }
Example #26
0
    public static void AcceptCashChallenge(string challengeId, SuccessHandler success, FriendlyErrorHandler failure)
    {
        CodedErrorHandler failWrapper = (c, e, d) => { failure(e, d); };

        ArbiterBinding.AcceptCashChallenge(challengeId, success, failWrapper);
    }
Example #27
0
 public static void Logout(SuccessHandler success, ErrorHandler failure)
 {
     teardownPollers();
     ArbiterBinding.Logout(success, failure);
 }
Example #28
0
 public static void VerifyUser(SuccessHandler success, ErrorHandler failure)
 {
     ArbiterBinding.VerifyUser(success, failure);
 }