コード例 #1
0
        public void TestValidateProgressionEvent()
        {
            // Store result
            bool isValid;

            // Valids
            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", "level_001", "phase_001");
            Assert.True(isValid, "Should allow progression 01-02-03");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", "level_001", "");
            Assert.True(isValid, "Should allow progression 01-02");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", "level_001", null);
            Assert.True(isValid, "Should allow progression 01-02");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", "", "");
            Assert.True(isValid, "Should allow progression 01");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", null, null);
            Assert.True(isValid, "Should allow progression 01");

            // Invalids
            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "", "", "");
            Assert.False(isValid, "Should falset allow false progressions");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, null, null, null);
            Assert.False(isValid, "Should falset allow false progressions");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", "", "phase_001");
            Assert.False(isValid, "Should falset allow progression 01-03");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "world_001", null, "phase_001");
            Assert.False(isValid, "Should falset allow progression 01-03");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "", "level_001", "phase_001");
            Assert.False(isValid, "Should falset allow progression 02-03");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, null, "level_001", "phase_001");
            Assert.False(isValid, "Should falset allow progression 02-03");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "", "level_001", "");
            Assert.False(isValid, "Should falset allow progression 02");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, null, "level_001", null);
            Assert.False(isValid, "Should falset allow progression 02");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, "", "", "phase_001");
            Assert.False(isValid, "Should falset allow progression 03");

            isValid = GAValidator.ValidateProgressionEvent(EGAProgressionStatus.Start, null, null, "phase_001");
            Assert.False(isValid, "Should falset allow progression 03");
        }
コード例 #2
0
ファイル: GA_Wrapper.cs プロジェクト: DevilN31/Rush-Hour
        public static void AddProgressionEventWithScore(GAProgressionStatus progressionStatus, string progression01, string progression02, string progression03, int score, IDictionary <string, object> fields)
        {
            string fieldsAsString = DictionaryToJsonString(fields);

#if UNITY_EDITOR
            if (GAValidator.ValidateProgressionEvent(progressionStatus, progression01, progression02, progression03))
            {
                addProgressionEventWithScore((int)progressionStatus, progression01, progression02, progression03, score, fieldsAsString);
            }
#else
            addProgressionEventWithScore((int)progressionStatus, progression01, progression02, progression03, score, fieldsAsString);
#endif
        }
コード例 #3
0
        public static void AddProgressionEvent(EGAProgressionStatus progressionStatus, string progression01, string progression02, string progression03, double score, bool sendScore)
        {
            string progressionStatusString = ProgressionStatusToString(progressionStatus);

            // Validate event params
            if (!GAValidator.ValidateProgressionEvent(progressionStatus, progression01, progression02, progression03))
            {
                GAHTTPApi.Instance.SendSdkErrorEvent(EGASdkErrorType.Rejected);
                return;
            }

            // Create empty eventData
            JSONClass eventDict = new JSONClass();

            // Progression identifier
            string progressionIdentifier;

            if (string.IsNullOrEmpty(progression02))
            {
                progressionIdentifier = progression01;
            }
            else if (string.IsNullOrEmpty(progression03))
            {
                progressionIdentifier = progression01 + ":" + progression02;
            }
            else
            {
                progressionIdentifier = progression01 + ":" + progression02 + ":" + progression03;
            }

            // Append event specifics
            eventDict["category"] = CategoryProgression;
            eventDict["event_id"] = progressionStatusString + ":" + progressionIdentifier;

            // Attempt
            double attempt_num = 0;

            // Add score if specified and status is not start
            if (sendScore && progressionStatus != EGAProgressionStatus.Start)
            {
                eventDict.Add("score", new JSONData(score));
            }

            // Count attempts on each progression fail and persist
            if (progressionStatus == EGAProgressionStatus.Fail)
            {
                // Increment attempt number
                GAState.IncrementProgressionTries(progressionIdentifier);
            }

            // increment and add attempt_num on complete and delete persisted
            if (progressionStatus == EGAProgressionStatus.Complete)
            {
                // Increment attempt number
                GAState.IncrementProgressionTries(progressionIdentifier);

                // Add to event
                attempt_num = GAState.GetProgressionTries(progressionIdentifier);
                eventDict.Add("attempt_num", new JSONData(attempt_num));

                // Clear
                GAState.ClearProgressionTries(progressionIdentifier);
            }

            // Add custom dimensions
            AddDimensionsToEvent(eventDict);

            // Log
            GALogger.I("Add PROGRESSION event: {status:" + progressionStatusString + ", progression01:" + progression01 + ", progression02:" + progression02 + ", progression03:" + progression03 + ", score:" + score + ", attempt:" + attempt_num + "}");

            // Send to store
            AddEventToStore(eventDict);
        }
コード例 #4
0
        public static void AddProgressionEvent(EGAProgressionStatus progressionStatus, string progression01, string progression02, string progression03, double score, bool sendScore, IDictionary <string, object> fields, bool mergeFields)
        {
            if (!GAState.IsEventSubmissionEnabled)
            {
                return;
            }

            string progressionStatusString = ProgressionStatusToString(progressionStatus);

            // Validate event params
            if (!GAValidator.ValidateProgressionEvent(progressionStatus, progression01, progression02, progression03))
            {
                //GAHTTPApi.Instance.SendSdkErrorEvent(EGASdkErrorType.Rejected);
                return;
            }

            // Create empty eventData
            JSONObject eventDict = new JSONObject();

            // Progression identifier
            string progressionIdentifier;

            if (string.IsNullOrEmpty(progression02))
            {
                progressionIdentifier = progression01;
            }
            else if (string.IsNullOrEmpty(progression03))
            {
                progressionIdentifier = progression01 + ":" + progression02;
            }
            else
            {
                progressionIdentifier = progression01 + ":" + progression02 + ":" + progression03;
            }

            // Append event specifics
            eventDict["category"] = CategoryProgression;
            eventDict["event_id"] = progressionStatusString + ":" + progressionIdentifier;

            // Attempt
            double attempt_num = 0;

            // Add score if specified and status is not start
            if (sendScore && progressionStatus != EGAProgressionStatus.Start)
            {
                eventDict.Add("score", new JSONNumber(score));
            }

            // Count attempts on each progression fail and persist
            if (progressionStatus == EGAProgressionStatus.Fail)
            {
                // Increment attempt number
                GAState.IncrementProgressionTries(progressionIdentifier);
            }

            // increment and add attempt_num on complete and delete persisted
            if (progressionStatus == EGAProgressionStatus.Complete)
            {
                // Increment attempt number
                GAState.IncrementProgressionTries(progressionIdentifier);

                // Add to event
                attempt_num = GAState.GetProgressionTries(progressionIdentifier);
                eventDict.Add("attempt_num", new JSONNumber(attempt_num));

                // Clear
                GAState.ClearProgressionTries(progressionIdentifier);
            }

            // Add custom dimensions
            AddDimensionsToEvent(eventDict);

            IDictionary <string, object> fieldsToUse = new Dictionary <string, object>(fields != null && fields.Count > 0 ? fields : GAState.CurrentGlobalCustomEventFields);

            if (mergeFields && fields != null && fields.Count > 0)
            {
                foreach (KeyValuePair <string, object> pair in GAState.CurrentGlobalCustomEventFields)
                {
                    if (!fieldsToUse.ContainsKey(pair.Key))
                    {
                        fieldsToUse.Add(pair.Key, pair.Value);
                    }
                }
            }
            // Add custom fields
            AddFieldsToEvent(eventDict, GAState.ValidateAndCleanCustomFields(fieldsToUse));

            // Log
            GALogger.I("Add PROGRESSION event: {status:" + progressionStatusString + ", progression01:" + progression01 + ", progression02:" + progression02 + ", progression03:" + progression03 + ", score:" + score + ", attempt:" + attempt_num + "}");

            // Send to store
            AddEventToStore(eventDict);
        }