Exemplo n.º 1
0
        public void Finish(string matchId, byte[] data, MatchOutcome outcome, Action <bool> callback)
        {
            Logger.d(string.Format("iOSTbmpClient.Finish matchId={0}, outcome={1}", matchId, outcome.ToString()));
            // We probably need to convert our match outcome into something we can read in


            var           resultsOutput   = new List <Dictionary <string, object> >();
            List <string> allParticipants = outcome.ParticipantIds;
            Dictionary <string, object> nextResult;

            foreach (string participantID in allParticipants)
            {
                Logger.d("Getting results for " + participantID);
                nextResult = new Dictionary <string, object>();
                // Maybe don't add them if their result is unset? Check with Bruno on this one
                if (outcome.GetResultFor(participantID) != MatchOutcome.ParticipantResult.Unset)
                {
                    nextResult["participantId"] = participantID;
                    nextResult["placing"]       = outcome.GetPlacementFor(participantID);
                    nextResult["result"]        = convertParticipantResultToiOSInt(outcome.GetResultFor(participantID));
                }
                resultsOutput.Add(nextResult);
            }
            string resultsAsJson = Json.Serialize(resultsOutput);

            Logger.d("JSonified results are " + resultsAsJson);

            sCallbackSuccessId++;
            sMatchSuccessCallbacks.Add(sCallbackSuccessId, callback);
            GPGSTBMPFinishMatch(matchId, data, data.Length, resultsAsJson, sCallbackSuccessId, TbmpMatchSuccessCallback);
        }