/// <summary>
        ///     Loads this instance.
        /// </summary>
        public virtual void Load(LogicJSONObject jsonObject)
        {
            LogicJSONNumber idHigh = jsonObject.GetJSONNumber("id_hi");
            LogicJSONNumber idLow  = jsonObject.GetJSONNumber("id_lo");

            if (idHigh != null)
            {
                if (idLow != null)
                {
                    this._id = new LogicLong(idHigh.GetIntValue(), idLow.GetIntValue());
                }
            }

            LogicJSONObject senderObject = jsonObject.GetJSONObject("sender");

            if (senderObject != null)
            {
                LogicJSONString nameObject = senderObject.GetJSONString("name");

                if (nameObject != null)
                {
                    this._senderName = nameObject.GetStringValue();
                }

                LogicJSONNumber expLevelObject = senderObject.GetJSONNumber("exp_lvl");

                if (expLevelObject != null)
                {
                    this._senderExpLevel = expLevelObject.GetIntValue();
                }

                LogicJSONNumber leagueTypeObject = senderObject.GetJSONNumber("league_type");

                if (leagueTypeObject != null)
                {
                    this._senderLeagueType = leagueTypeObject.GetIntValue();
                }

                LogicJSONNumber ageSecsObject = senderObject.GetJSONNumber("age_secs");

                if (ageSecsObject != null)
                {
                    this._ageSeconds = ageSecsObject.GetIntValue();
                }

                LogicJSONBoolean isDismissedObject = senderObject.GetJSONBoolean("is_dismissed");

                if (isDismissedObject != null)
                {
                    this._dismiss = isDismissedObject.IsTrue();
                }

                LogicJSONBoolean isNewObject = senderObject.GetJSONBoolean("is_new");

                if (isNewObject != null)
                {
                    this._new = isNewObject.IsTrue();
                }
            }
        }
            public CouchbaseBucketEntry(LogicJSONString str)
            {
                string[] name = str.GetStringValue().Split(':');

                this.Name        = name[0];
                this.ServerIndex = int.Parse(name[1]);
            }
 public ServerConnectionEntry(LogicJSONString jsonString)
 {
     string[] connectionString = jsonString.GetStringValue().Split(':');
     Logging.Assert(connectionString.Length == 2, "Malformed connection string!");
     this.ServerIP   = connectionString[0];
     this.ServerPort = int.Parse(connectionString[1]);
 }
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("ChatStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_eventType = (AllianceEventStreamEntryType)jsonObject.GetJSONNumber("event_type").GetIntValue();

            LogicJSONNumber eventAvatarIdHighObject = jsonObject.GetJSONNumber("event_avatar_id_high");
            LogicJSONNumber eventAvatarIdLowObject  = jsonObject.GetJSONNumber("event_avatar_id_low");

            if (eventAvatarIdHighObject != null && eventAvatarIdLowObject != null)
            {
                this.m_eventAvatarId = new LogicLong(eventAvatarIdHighObject.GetIntValue(), eventAvatarIdLowObject.GetIntValue());

                LogicJSONString eventAvatarNameObject = jsonObject.GetJSONString("event_avatar_name");

                if (eventAvatarNameObject != null)
                {
                    this.m_eventAvatarName = eventAvatarNameObject.GetStringValue();
                }
            }
        }
Beispiel #5
0
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("AllianceInvitationAvatarStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_titleTID       = jsonObject.GetJSONString("title").GetStringValue();
            this.m_descriptionTID = jsonObject.GetJSONString("description").GetStringValue();

            LogicJSONString buttonString = jsonObject.GetJSONString("button");

            if (buttonString != null)
            {
                this.m_buttonTID = buttonString.GetStringValue();
            }

            LogicJSONString helpshiftUrlString = jsonObject.GetJSONString("helpshift_url");

            if (helpshiftUrlString != null)
            {
                this.m_helpshiftLink = helpshiftUrlString.GetStringValue();
            }

            LogicJSONString urlString = jsonObject.GetJSONString("url");

            if (urlString != null)
            {
                this.m_urlLink = urlString.GetStringValue();
            }

            LogicJSONNumber diamondsNumber = jsonObject.GetJSONNumber("diamonds");

            if (diamondsNumber != null)
            {
                this.m_diamondCount = diamondsNumber.GetIntValue();
            }

            LogicJSONBoolean supportMessageBoolean = jsonObject.GetJSONBoolean("support_msg");

            if (supportMessageBoolean != null)
            {
                this.m_supportMessage = supportMessageBoolean.IsTrue();
            }

            LogicJSONBoolean claimedBoolean = jsonObject.GetJSONBoolean("claimed");

            if (claimedBoolean != null)
            {
                this.m_claimed = claimedBoolean.IsTrue();
            }
        }
Beispiel #6
0
        /// <summary>
        ///     Gets the specified json string.
        /// </summary>
        public static string GetJSONString(LogicJSONObject jsonObject, string key)
        {
            LogicJSONString jsonString = jsonObject.GetJSONString(key);

            if (jsonString != null)
            {
                return(jsonString.GetStringValue());
            }

            return(null);
        }
Beispiel #7
0
        public void LoadDefenderNameFromJson(LogicJSONObject jsonObject)
        {
            LogicJSONString defenderNameObject = jsonObject.GetJSONString("defenderName");

            if (defenderNameObject != null)
            {
                this.m_defenderName = defenderNameObject.GetStringValue();
            }
            else
            {
                this.m_defenderName = string.Empty;
            }
        }
Beispiel #8
0
        public void LoadAttackerNameFromJson(LogicJSONObject jsonObject)
        {
            LogicJSONString attackerNameObject = jsonObject.GetJSONString("attackerName");

            if (attackerNameObject != null)
            {
                this.m_attackerName = attackerNameObject.GetStringValue();
            }
            else
            {
                this.m_attackerName = string.Empty;
            }
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("ChatStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_castleLevel              = LogicJSONHelper.GetInt(jsonObject, "castle_level");
            this.m_castleUsedCapacity       = LogicJSONHelper.GetInt(jsonObject, "castle_used");
            this.m_castleUsedSpellCapacity  = LogicJSONHelper.GetInt(jsonObject, "castle_sp_used");
            this.m_castleTotalCapacity      = LogicJSONHelper.GetInt(jsonObject, "castle_total");
            this.m_castleTotalSpellCapacity = LogicJSONHelper.GetInt(jsonObject, "castle_sp_total");

            LogicJSONString messageObject = jsonObject.GetJSONString("message");

            if (messageObject != null)
            {
                this.m_message = messageObject.GetStringValue();
            }

            LogicJSONArray donationArray = jsonObject.GetJSONArray("donators");

            if (donationArray != null)
            {
                for (int i = 0; i < donationArray.Size(); i++)
                {
                    DonationContainer donationContainer = new DonationContainer();
                    donationContainer.Load(donationArray.GetJSONObject(i));
                    this.m_donationContainerList.Add(donationContainer);
                }
            }

            LogicJSONArray unitArray = jsonObject.GetJSONArray("units");

            if (unitArray != null)
            {
                this.m_unitCount = new LogicArrayList <LogicUnitSlot>();

                for (int i = 0; i < unitArray.Size(); i++)
                {
                    LogicUnitSlot unitSlot = new LogicUnitSlot(null, -1, 0);
                    unitSlot.ReadFromJSON(unitArray.GetJSONObject(i));
                    this.m_unitCount.Add(unitSlot);
                }
            }
        }
        /// <summary>
        ///     Loads this instance from json.
        /// </summary>
        public void Load(LogicJSONObject jsonObject)
        {
            LogicJSONString sString = jsonObject.GetJSONString("s");

            if (sString != null)
            {
                this._stringValue = sString.GetStringValue();
            }

            LogicJSONString cString = jsonObject.GetJSONString("c");

            if (cString != null)
            {
                this._compressedData   = Convert.FromBase64String(cString.GetStringValue());
                this._compressedLength = this._compressedData.Length;
            }
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("ChatStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            LogicJSONString messageObject = jsonObject.GetJSONString("message");

            if (messageObject != null)
            {
                this.m_message = messageObject.GetStringValue();
            }
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("VersusChallengeStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_message = jsonObject.GetJSONString("message").GetStringValue();

            LogicJSONString battleLogString = jsonObject.GetJSONString("battleLog");

            if (battleLogString != null)
            {
                this.m_battleLogJSON = battleLogString.GetStringValue();
            }
        }
Beispiel #13
0
        /// <summary>
        ///     Verifies the version of assets.
        /// </summary>
        private static void VerifyAssets()
        {
            string json = ResourceManager.LoadAssetFile("fingerprint.json");

            if (json != null)
            {
                LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json);
                LogicJSONString shaObject  = jsonObject.GetJSONString("sha");

                string lastSha = WebManager.DownloadConfigString("/sha");

                if (shaObject.GetStringValue() != lastSha)
                {
                    ResourceManager.DownloadLastAssets(jsonObject);
                }
            }
            else
            {
                ResourceManager.DownloadLastAssets(null);
            }
        }
Beispiel #14
0
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("ReplayVersusBattleStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_message          = jsonObject.GetJSONString("message").GetStringValue();
            this.m_snapshotHomeJSON = Convert.FromBase64String(jsonObject.GetJSONString("snapshot_home").GetStringValue());
            this.m_warLayout        = jsonObject.GetJSONBoolean("war_layout").IsTrue();

            LogicJSONString battleLogString = jsonObject.GetJSONString("battleLog");

            if (battleLogString != null)
            {
                this.m_battleLogJSON = battleLogString.GetStringValue();
            }
        }
Beispiel #15
0
        private static void LoadCurrentFingerprint()
        {
            LogicJSONObject jsonObject    = (LogicJSONObject)LogicJSONParser.Parse(File.ReadAllText("assets/fingerprint.json"));
            LogicJSONString versionString = jsonObject.GetJSONString("version");

            if (!string.IsNullOrEmpty(versionString.GetStringValue()))
            {
                string[] version = versionString.GetStringValue().Split('.');

                if (version.Length == 3)
                {
                    Program.m_currentVersion = new int[3];

                    for (int i = 0; i < 3; i++)
                    {
                        Program.m_currentVersion[i] = int.Parse(version[i]);
                    }
                }
            }

            Program.m_currentSha = jsonObject.GetJSONString("sha").GetStringValue();
        }
        public static string GetString(LogicJSONObject jsonObject, string key, string defaultValue, bool throwIfNotExist)
        {
            if (jsonObject != null)
            {
                if (key.Length != 0)
                {
                    LogicJSONString stringValue = jsonObject.GetJSONString(key);

                    if (stringValue != null)
                    {
                        return(stringValue.GetStringValue());
                    }

                    if (!throwIfNotExist)
                    {
                        return(defaultValue);
                    }

                    Debugger.Error(string.Format("Json string with key='{0}' not found!", key));
                }
            }

            return(null);
        }
Beispiel #17
0
        /// <summary>
        ///     Loads the service config.
        /// </summary>
        private static void LoadConfig()
        {
            string json = WebManager.DownloadConfigString("/core/services.json");

            if (json != null)
            {
                LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json);

                LogicJSONString versionObject = jsonObject.GetJSONString("version");

                if (versionObject != null)
                {
                    ServiceSettings._serviceVersion = versionObject.GetStringValue();
                }

                LogicJSONObject nodeObject = jsonObject.GetJSONObject("node");

                if (nodeObject != null)
                {
                    LogicJSONArray proxyArray = nodeObject.GetJSONArray("proxy");

                    if (proxyArray != null)
                    {
                        ServiceSettings._serviceIPs[1] = new string[proxyArray.Size()];

                        for (int i = 0; i < proxyArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[1][i] = proxyArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray accountArray = nodeObject.GetJSONArray("account");

                    if (accountArray != null)
                    {
                        ServiceSettings._serviceIPs[2] = new string[accountArray.Size()];

                        for (int i = 0; i < accountArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[2][i] = accountArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray globalArray = nodeObject.GetJSONArray("global_chat");

                    if (globalArray != null)
                    {
                        ServiceSettings._serviceIPs[6] = new string[globalArray.Size()];

                        for (int i = 0; i < globalArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[6][i] = globalArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray avatarArray = nodeObject.GetJSONArray("avatar");

                    if (avatarArray != null)
                    {
                        ServiceSettings._serviceIPs[9] = new string[avatarArray.Size()];

                        for (int i = 0; i < avatarArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[9][i] = avatarArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray homeArray = nodeObject.GetJSONArray("zone");

                    if (homeArray != null)
                    {
                        ServiceSettings._serviceIPs[10] = new string[homeArray.Size()];

                        for (int i = 0; i < homeArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[10][i] = homeArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray allianceArray = nodeObject.GetJSONArray("party");

                    if (allianceArray != null)
                    {
                        ServiceSettings._serviceIPs[11] = new string[allianceArray.Size()];

                        for (int i = 0; i < allianceArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[11][i] = allianceArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray leagueArray = nodeObject.GetJSONArray("ranking");

                    if (leagueArray != null)
                    {
                        ServiceSettings._serviceIPs[13] = new string[leagueArray.Size()];

                        for (int i = 0; i < leagueArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[13][i] = leagueArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray battleArray = nodeObject.GetJSONArray("battle");

                    if (battleArray != null)
                    {
                        ServiceSettings._serviceIPs[27] = new string[battleArray.Size()];

                        for (int i = 0; i < battleArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[27][i] = battleArray.GetJSONString(i).GetStringValue();
                        }
                    }
                }

                LogicJSONObject databaseObject = jsonObject.GetJSONObject("database");

                if (databaseObject != null)
                {
                    LogicJSONArray urls = databaseObject.GetJSONArray("urls");

                    if (urls != null)
                    {
                        ServiceSettings._databaseUrls = new string[urls.Size()];

                        for (int i = 0; i < urls.Size(); i++)
                        {
                            ServiceSettings._databaseUrls[i] = urls.GetJSONString(i).GetStringValue();
                        }
                    }

                    ServiceSettings._databaseUser     = LogicJSONHelper.GetJSONString(databaseObject, "user");
                    ServiceSettings._databasePassword = LogicJSONHelper.GetJSONString(databaseObject, "pass");
                }
            }
        }
Beispiel #18
0
        /// <summary>
        ///     Downloads assets from config server.
        /// </summary>
        private static void DownloadAssets(LogicJSONObject currentFingerprint, string fingerprint)
        {
            LogicJSONArray  currentFileArray = currentFingerprint?.GetJSONArray("files");
            LogicJSONObject jsonObject       = (LogicJSONObject)LogicJSONParser.Parse(fingerprint);
            LogicJSONArray  fileArray        = jsonObject.GetJSONArray("files");

            if (currentFileArray != null)
            {
                if (fileArray.Size() != currentFileArray.Size())
                {
                    currentFileArray = null;
                }
            }

            string shaFingerprint = LogicJSONHelper.GetJSONString(jsonObject, "sha");

            Logging.Print("Download " + shaFingerprint + " assets...");

            Parallel.For(0, fileArray.Size(), new ParallelOptions {
                MaxDegreeOfParallelism = 4
            }, i =>
            {
                LogicJSONObject fileObject = fileArray.GetJSONObject(i);

                if (fileObject != null)
                {
                    string fileName = LogicJSONHelper.GetJSONString(fileObject, "file");
                    string sha      = LogicJSONHelper.GetJSONString(fileObject, "sha");

                    if (currentFileArray != null)
                    {
                        for (int j = 0; j < currentFileArray.Size(); j++)
                        {
                            LogicJSONObject currentFileObject     = currentFileArray.GetJSONObject(j);
                            LogicJSONString currentFileNameObject = currentFileObject.GetJSONString("file");

                            if (fileName == currentFileNameObject.GetStringValue())
                            {
                                LogicJSONString currentShaObject = currentFileObject.GetJSONString("sha");

                                if (sha == currentShaObject.GetStringValue())
                                {
                                    return;
                                }
                            }
                        }
                    }

                    WebClient client = new WebClient();
                    byte[] data      = client.DownloadData(ServiceCore.ConfigurationServer + "/assets/" + shaFingerprint + "/" + fileName);
                    client.Dispose();

                    if (data != null)
                    {
                        Logging.Print("file " + fileName + " downloaded");

                        switch (Path.GetExtension(fileName))
                        {
                        case ".csv":
                            using (MemoryStream inputStream = new MemoryStream(data))
                            {
                                using (MemoryStream outputStream = new MemoryStream())
                                {
                                    Decoder decompresser = new Decoder();

                                    byte[] properties      = new byte[5];
                                    byte[] fileLengthBytes = new byte[4];

                                    inputStream.Read(properties, 0, 5);
                                    inputStream.Read(fileLengthBytes, 0, 4);

                                    int fileLength = fileLengthBytes[0] | fileLengthBytes[1] << 8 | fileLengthBytes[2] << 16 | fileLengthBytes[3] << 24;

                                    decompresser.SetDecoderProperties(properties);
                                    decompresser.Code(inputStream, outputStream, inputStream.Length, fileLength, null);

                                    data = outputStream.ToArray();
                                }
                            }

                            break;
                        }

                        Directory.CreateDirectory("Assets/" + fileName.Replace(Path.GetFileName(fileName), string.Empty));
                        File.WriteAllBytes("Assets/" + fileName, data);
                    }
                    else
                    {
                        Logging.Warning("file " + fileName + " not exist");
                    }
                }
            });

            File.WriteAllText("Assets/fingerprint.json", fingerprint);
            Logging.Print("Download completed");
        }
Beispiel #19
0
        public void Load(LogicJSONObject jsonObject)
        {
            this.m_json = jsonObject;

            if (jsonObject != null)
            {
                LogicJSONObject village1Object = jsonObject.GetJSONObject("Village1");
                Debugger.DoAssert(village1Object != null, "pVillage1 = NULL!");

                LogicJSONString specialObstacleObject = village1Object.GetJSONString("SpecialObstacle");

                if (specialObstacleObject != null)
                {
                    this.m_specialObstacle = LogicDataTables.GetObstacleByName(specialObstacleObject.GetStringValue(), null);
                }

                LogicJSONObject village2Object = jsonObject.GetJSONObject("Village2");
                Debugger.DoAssert(village2Object != null, "pVillage2 = NULL!");

                this.m_maxTownHallLevel = LogicJSONHelper.GetInt(village2Object, "TownHallMaxLevel");

                LogicJSONArray scoreChangeForLosingArray = village2Object.GetJSONArray("ScoreChangeForLosing");
                Debugger.DoAssert(scoreChangeForLosingArray != null, "ScoreChangeForLosing array is null");

                this.m_milestoneScoreChangeForLosing  = new LogicArrayList <int>(scoreChangeForLosingArray.Size());
                this.m_percentageScoreChangeForLosing = new LogicArrayList <int>(scoreChangeForLosingArray.Size());

                for (int i = 0; i < scoreChangeForLosingArray.Size(); i++)
                {
                    LogicJSONObject obj = scoreChangeForLosingArray.GetJSONObject(i);

                    if (obj != null)
                    {
                        LogicJSONNumber milestoneObject  = obj.GetJSONNumber("Milestone");
                        LogicJSONNumber percentageObject = obj.GetJSONNumber("Percentage");

                        if (milestoneObject != null && percentageObject != null)
                        {
                            this.m_milestoneScoreChangeForLosing.Add(milestoneObject.GetIntValue());
                            this.m_percentageScoreChangeForLosing.Add(percentageObject.GetIntValue());
                        }
                    }
                }

                LogicJSONArray strengthRangeForScoreArray = village2Object.GetJSONArray("StrengthRangeForScore");
                Debugger.DoAssert(strengthRangeForScoreArray != null, "StrengthRangeForScore array is null");

                this.m_milestoneStrengthRangeForScore  = new LogicArrayList <int>(strengthRangeForScoreArray.Size());
                this.m_percentageStrengthRangeForScore = new LogicArrayList <int>(strengthRangeForScoreArray.Size());

                for (int i = 0; i < strengthRangeForScoreArray.Size(); i++)
                {
                    LogicJSONObject obj = strengthRangeForScoreArray.GetJSONObject(i);

                    if (obj != null)
                    {
                        LogicJSONNumber milestoneObject  = obj.GetJSONNumber("Milestone");
                        LogicJSONNumber percentageObject = obj.GetJSONNumber("Percentage");

                        if (milestoneObject != null && percentageObject != null)
                        {
                            this.m_milestoneStrengthRangeForScore.Add(milestoneObject.GetIntValue());
                            this.m_percentageStrengthRangeForScore.Add(percentageObject.GetIntValue());
                        }
                    }
                }

                LogicJSONObject killSwitchesObject = jsonObject.GetJSONObject("KillSwitches");
                Debugger.DoAssert(killSwitchesObject != null, "pKillSwitches = NULL!");

                this.m_battleWaitForProjectileDestruction = LogicJSONHelper.GetBool(killSwitchesObject, "BattleWaitForProjectileDestruction");
                this.m_battleWaitForDieDamage             = LogicJSONHelper.GetBool(killSwitchesObject, "BattleWaitForDieDamage");

                LogicJSONObject globalsObject = jsonObject.GetJSONObject("Globals");
                Debugger.DoAssert(globalsObject != null, "pGlobals = NULL!");

                this.m_giftPackExtension = LogicJSONHelper.GetString(globalsObject, "GiftPackExtension");

                this.m_duelLootLimitCooldownInMinutes = LogicJSONHelper.GetInt(globalsObject, "DuelLootLimitCooldownInMinutes");
                this.m_duelBonusLimitWinsPerDay       = LogicJSONHelper.GetInt(globalsObject, "DuelBonusLimitWinsPerDay");
                this.m_duelBonusPercentWin            = LogicJSONHelper.GetInt(globalsObject, "DuelBonusPercentWin");
                this.m_duelBonusPercentLose           = LogicJSONHelper.GetInt(globalsObject, "DuelBonusPercentLose");
                this.m_duelBonusPercentDraw           = LogicJSONHelper.GetInt(globalsObject, "DuelBonusPercentDraw");
                this.m_duelBonusMaxDiamondCostPercent = LogicJSONHelper.GetInt(globalsObject, "DuelBonusMaxDiamondCostPercent");
            }
            else
            {
                Debugger.Error("pConfiguration = NULL!");
            }
        }
Beispiel #20
0
        public virtual void Load(LogicJSONObject jsonObject)
        {
            if (jsonObject == null)
            {
                this.m_errorHandler.Error(this, "Json cannot be null");
            }

            this.m_id      = LogicJSONHelper.GetInt(jsonObject, "id", -1);
            this.m_version = LogicJSONHelper.GetInt(jsonObject, "version", 0);

            this.m_newTrainingBoostBarracksCost = LogicDataTables.GetGlobals().GetNewTrainingBoostBarracksCost();
            this.m_newTrainingBoostSpellCost    = LogicDataTables.GetGlobals().GetNewTrainingBoostLaboratoryCost();

            this.m_startTime = LogicCalendarEvent.ConvertStringToTimestamp(LogicJSONHelper.GetString(jsonObject, "startTime"), false);
            this.m_endTime   = LogicCalendarEvent.ConvertStringToTimestamp(LogicJSONHelper.GetString(jsonObject, "endTime"), true);

            if (this.m_startTime >= this.m_endTime)
            {
                this.m_errorHandler.ErrorField(this, "endTime", "End time must be after start time.");
            }

            LogicJSONString visibleTimeString = jsonObject.GetJSONString("visibleTime");

            if (visibleTimeString != null)
            {
                this.m_visibleTime = LogicCalendarEvent.ConvertStringToTimestamp(visibleTimeString.GetStringValue(), false);

                if (this.m_visibleTime > this.m_startTime)
                {
                    this.m_errorHandler.ErrorField(this, "visibleTime", "Visible time must be before or at start time.");
                }
            }
            else
            {
                this.m_visibleTime = 0;
            }

            this.m_clashBoxEntryName = jsonObject.GetJSONString("clashBoxEntryName").GetStringValue();

            LogicJSONString eventEntryNameString = jsonObject.GetJSONString("eventEntryName");

            this.m_eventEntryData = LogicDataTables.GetEventEntryByName(eventEntryNameString.GetStringValue(), null);

            if (eventEntryNameString.GetStringValue().Length > 0)
            {
                if (this.m_eventEntryData == null)
                {
                    this.m_errorHandler.ErrorField(this, "eventEntryName", string.Format("Invalid event entry name: {0}.", eventEntryNameString.GetStringValue()));
                }

                if (this.m_visibleTime == 0)
                {
                    this.m_errorHandler.ErrorField(this, "visibleTime", "Visible time must be set if event entry name is set.");
                }
            }

            if (this.m_visibleTime != 0)
            {
                if (this.m_eventEntryData == null)
                {
                    this.m_errorHandler.ErrorField(this, "eventEntryName", "Event entry name must be set if visible time is set.");
                }
            }

            this.m_inboxEntryId    = LogicJSONHelper.GetInt(jsonObject, "inboxEntryId", -1);
            this.m_notificationTid = LogicJSONHelper.GetString(jsonObject, "notificationTid");
            this.m_image           = LogicJSONHelper.GetString(jsonObject, "image");
            this.m_sc           = LogicJSONHelper.GetString(jsonObject, "sc");
            this.m_localization = LogicJSONHelper.GetString(jsonObject, "localization");

            LogicJSONObject targetingObject = jsonObject.GetJSONObject("targeting");

            if (targetingObject != null)
            {
                this.m_targeting = new LogicCalendarTargeting(jsonObject);
            }

            LogicJSONArray functionArray = jsonObject.GetJSONArray("functions");

            if (functionArray != null)
            {
                for (int i = 0; i < functionArray.Size(); i++)
                {
                    this.m_functions.Add(new LogicCalendarFunction(this, i, functionArray.GetJSONObject(i), this.m_errorHandler));
                }
            }
        }