Beispiel #1
0
 public CallbackTuple(SuccessHandler success, ErrorHandler failure, FriendlyErrorHandler friendlyFailure, CodedErrorHandler codedFailure)
 {
     Success         = success;
     Failure         = failure;
     FriendlyFailure = friendlyFailure;
     CodedFailure    = codedFailure;
 }
Beispiel #2
0
 public static void FetchTournaments(SuccessHandler success, FriendlyErrorHandler failure)
 {
     fetchedTournamentsCallback = () => {
         success();
     };
     ArbiterBinding.FetchTournaments(FetchTournamentsSuccessHandler, failure);
 }
Beispiel #3
0
        public static void ReportScoreForChallenge(string challengeId, string score, Arbiter.ReportScoreForChallengeCallback success, FriendlyErrorHandler failure)
        {
            reportScoreForChallengeSuccessHandler = success;
            reportScoreForChallengeErrorHandler   = failure;
#if UNITY_EDITOR
            ReportIgnore("ReportScoreForChallenge");
#elif UNITY_IOS
            _reportScoreForChallenge(challengeId, score);
#endif
        }
Beispiel #4
0
        public static void FetchTournaments(Arbiter.TournamentsCallback success, FriendlyErrorHandler failure)
        {
            fetchTournamentsSuccessHandler = success;
            fetchTournamentsErrorHandler   = failure;
#if UNITY_EDITOR
            ReportIgnore("FetchTournaments");
            List <Arbiter.Tournament> fakeTournaments = new List <Arbiter.Tournament>();
            fetchTournamentsSuccessHandler(fakeTournaments);
#elif UNITY_IOS
            _fetchTournaments();
#endif
        }
Beispiel #5
0
        public static void RequestCashChallenge(Dictionary <string, string> filters, Arbiter.RequestCashChallengeCallback success, FriendlyErrorHandler failure)
        {
            requestCashChallengeSuccessHandler = success;
            requestCashChallengeErrorHandler   = failure;
#if UNITY_EDITOR
            ReportIgnore("RequestCashChallenge");
            if (success != null)
            {
                success(new Arbiter.CashChallenge("1234", "55", "100", "200", Arbiter.CashChallenge.StatusType.Busy, null));
            }
#elif UNITY_IOS
            _requestCashChallenge(SerializeDictionary(filters));
#endif
        }
Beispiel #6
0
 private static void SetCallbacksWithFriendlyErrors(string key, SuccessHandler success, FriendlyErrorHandler failure)
 {
     if (success == null)
     {
         success = () => {}
     }
     ;
     if (failure == null)
     {
         failure = (e, d) => {}
     }
     ;
     callbacks[key] = new CallbackTuple(success, (e) => {}, failure);
 }
Beispiel #7
0
        public static void AcceptCashChallenge(string challengeId, SuccessHandler success, FriendlyErrorHandler failure)
        {
            SetCallbacksWithFriendlyErrors(ACCEPT_SCORE_CHALLENGE, success, failure);
#if UNITY_EDITOR
            ReportIgnore("AcceptCashChallenge");
#elif UNITY_IOS
            _acceptCashChallenge(challengeId);
#endif
        }
Beispiel #8
0
        public static void RequestTournament(string buyIn, Dictionary <string, string> filters, SuccessHandler success, FriendlyErrorHandler failure)
        {
            SetCallbacksWithFriendlyErrors(REQUEST_TOURNAMENT, success, failure);
#if UNITY_EDITOR
            ReportIgnore("RequestTournament");
            if (success != null)
            {
                success();
            }
#elif UNITY_IOS
            _requestTournament(buyIn, SerializeDictionary(filters));
#endif
        }
Beispiel #9
0
 public static void ReportScoreForChallenge(string challengeId, string score, Arbiter.ReportScoreForChallengeCallback success, FriendlyErrorHandler failure)
 {
     ArbiterBinding.ReportScoreForChallenge(challengeId, score, success, failure);
 }
Beispiel #10
0
    public static void AcceptCashChallenge(string challengeId, SuccessHandler success, FriendlyErrorHandler failure)
    {
        CodedErrorHandler failWrapper = (c, e, d) => { failure(e, d); };

        ArbiterBinding.AcceptCashChallenge(challengeId, success, failWrapper);
    }
Beispiel #11
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);
 }
Beispiel #12
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);
 }
Beispiel #13
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);
    }
Beispiel #14
0
 public static void AcceptCashChallenge(string challengeId, SuccessHandler success, FriendlyErrorHandler failure)
 {
     ArbiterBinding.AcceptCashChallenge(challengeId, success, failure);
 }