public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); this.m_scaledResourceData = (LogicResourceData)LogicJSONHelper.GetLogicData(jsonObject, "scaledResource"); this.m_scaledResourceMultiplier = LogicJSONHelper.GetInt(jsonObject, "scaledResourceMultiplier"); }
public override void WriteToJSON(LogicJSONObject jsonObject) { base.WriteToJSON(jsonObject); LogicJSONHelper.SetLogicData(jsonObject, "scaledResource", this.m_scaledResourceData); jsonObject.Put("scaledResourceMultiplier", new LogicJSONNumber(this.m_scaledResourceMultiplier)); }
/// <summary> /// Loads the fingerprint file. /// </summary> private static void LoadFingeprint() { ResourceManager.FingerprintJson = ResourceManager.LoadAssetFile("fingerprint.json"); if (ResourceManager.FingerprintJson != null) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(ResourceManager.FingerprintJson); ResourceManager.FingerprintSha = LogicJSONHelper.GetJSONString(jsonObject, "sha"); ResourceManager.FingerprintVersion = LogicJSONHelper.GetJSONString(jsonObject, "version"); string[] version = ResourceManager.FingerprintVersion.Split('.'); if (version.Length == 3) { ResourceManager._version = new int[3]; for (int i = 0; i < 3; i++) { ResourceManager._version[i] = int.Parse(version[i]); } } else { Debugger.Error("ResourceManager::loadFingeprint invalid fingerprint version: " + ResourceManager.FingerprintVersion); } ZLibHelper.CompressInZLibFormat(LogicStringUtil.GetBytes(ResourceManager.FingerprintJson), out ResourceManager.CompressedFingeprintJson); } else { Debugger.Error("ResourceManager::loadFingeprint fingerprint.json not exist"); } }
public virtual void Load(LogicJSONObject jsonObject) { LogicJSONNumber senderAvatarIdHighObject = jsonObject.GetJSONNumber("sender_avatar_id_high"); LogicJSONNumber senderAvatarIdLowObject = jsonObject.GetJSONNumber("sender_avatar_id_low"); if (senderAvatarIdHighObject != null && senderAvatarIdLowObject != null) { this.m_senderAvatarId = new LogicLong(senderAvatarIdHighObject.GetIntValue(), senderAvatarIdLowObject.GetIntValue()); } LogicJSONNumber senderHomeIdHighObject = jsonObject.GetJSONNumber("sender_home_id_high"); LogicJSONNumber senderHomeIdLowObject = jsonObject.GetJSONNumber("sender_home_id_low"); if (senderHomeIdHighObject != null && senderHomeIdLowObject != null) { this.m_senderHomeId = new LogicLong(senderHomeIdHighObject.GetIntValue(), senderHomeIdLowObject.GetIntValue()); } this.m_senderName = LogicJSONHelper.GetString(jsonObject, "sender_name"); this.m_senderLevel = LogicJSONHelper.GetInt(jsonObject, "sender_level"); this.m_senderLeagueType = LogicJSONHelper.GetInt(jsonObject, "sender_league_type"); this.m_senderRole = (LogicAvatarAllianceRole)LogicJSONHelper.GetInt(jsonObject, "sender_role"); this.m_removed = LogicJSONHelper.GetBool(jsonObject, "removed"); }
public void Load(LogicJSONObject jsonObject) { LogicJSONNumber avatarIdHighObject = jsonObject.GetJSONNumber("avatar_id_high"); LogicJSONNumber avatarIdLowObject = jsonObject.GetJSONNumber("avatar_id_low"); if (avatarIdHighObject != null && avatarIdLowObject != null) { this.m_avatarId = new LogicLong(avatarIdHighObject.GetIntValue(), avatarIdLowObject.GetIntValue()); } LogicJSONNumber homeIdHighObject = jsonObject.GetJSONNumber("home_id_high"); LogicJSONNumber homeIdLowObject = jsonObject.GetJSONNumber("home_id_low"); if (homeIdHighObject != null && homeIdLowObject != null) { this.m_homeId = new LogicLong(homeIdHighObject.GetIntValue(), homeIdLowObject.GetIntValue()); } this.m_name = LogicJSONHelper.GetString(jsonObject, "name"); this.m_allianceRole = (LogicAvatarAllianceRole)LogicJSONHelper.GetInt(jsonObject, "alliance_role"); this.m_expLevel = LogicJSONHelper.GetInt(jsonObject, "xp_level"); this.m_leagueType = LogicJSONHelper.GetInt(jsonObject, "league_type"); this.m_score = LogicJSONHelper.GetInt(jsonObject, "score"); this.m_duelScore = LogicJSONHelper.GetInt(jsonObject, "duel_score"); this.m_donationCount = LogicJSONHelper.GetInt(jsonObject, "donations"); this.m_receivedDonationCount = LogicJSONHelper.GetInt(jsonObject, "received_donations"); this.m_order = LogicJSONHelper.GetInt(jsonObject, "order"); this.m_previousOrder = LogicJSONHelper.GetInt(jsonObject, "prev_order"); this.m_orderVillage2 = LogicJSONHelper.GetInt(jsonObject, "order_v2"); this.m_previousOrderVillage2 = LogicJSONHelper.GetInt(jsonObject, "prev_order_v2"); this.m_warCooldown = LogicJSONHelper.GetInt(jsonObject, "war_cooldown"); this.m_warPreference = LogicJSONHelper.GetInt(jsonObject, "war_preference"); }
public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); this.m_resourceData = (LogicResourceData)LogicJSONHelper.GetLogicData(jsonObject, "resource"); this.m_resourceAmount = LogicJSONHelper.GetInt(jsonObject, "resourceAmount"); }
public void Load(LogicJSONObject jsonObject) { Debugger.DoAssert(this.m_errorHandler != null, "LogicCalendarErrorHandler must not be NULL!"); if (jsonObject == null) { this.m_errorHandler.ErrorFunction(this.m_calendarEvent, this, "Event function malformed."); return; } string name = LogicJSONHelper.GetString(jsonObject, "name"); this.m_functionData = LogicDataTables.GetCalendarEventFunctionByName(name, null); if (this.m_functionData == null) { this.m_errorHandler.ErrorFunction(this.m_calendarEvent, this, string.Format("event function '{0}' not found.", name)); return; } LogicJSONArray parameterArray = jsonObject.GetJSONArray("parameters"); if (parameterArray != null) { for (int i = 0; i < parameterArray.Size(); i++) { this.m_parameters.Add(parameterArray.GetJSONString(i).GetStringValue()); } } this.LoadingFinished(); }
/// <summary> /// Loads this instance from json. /// </summary> internal void Load(LogicJSONObject jsonObject) { this.StartTime = LogicJSONHelper.GetJSONNumber(jsonObject, "st"); this.EndTime = LogicJSONHelper.GetJSONNumber(jsonObject, "et"); this.EndPoint = LogicJSONHelper.GetJSONString(jsonObject, "ip"); this.DeviceModel = LogicJSONHelper.GetJSONString(jsonObject, "dm"); }
public override void Load(LogicJSONObject jsonObject) { LogicJSONObject baseObject = jsonObject.GetJSONObject("base"); if (baseObject == null) { Debugger.Error("JoinAllianceResponseAvatarStreamEntry::load base is NULL"); } base.Load(baseObject); LogicJSONNumber allianceIdHighNumber = jsonObject.GetJSONNumber("alli_id_high"); LogicJSONNumber allianceIdLowNumber = jsonObject.GetJSONNumber("alli_id_low"); if (allianceIdHighNumber != null && allianceIdLowNumber != null) { this.m_allianceId = new LogicLong(allianceIdHighNumber.GetIntValue(), allianceIdLowNumber.GetIntValue()); } this.m_allianceName = LogicJSONHelper.GetString(jsonObject, "alli_name"); this.m_allianceBadgeId = LogicJSONHelper.GetInt(jsonObject, "alli_badge_id"); this.m_message = LogicJSONHelper.GetString(jsonObject, "message"); LogicJSONNumber senderIdHighNumber = jsonObject.GetJSONNumber("sender_id_high"); LogicJSONNumber senderIdLowNumber = jsonObject.GetJSONNumber("sender_id_low"); if (senderIdHighNumber != null && senderIdLowNumber != null) { this.m_senderHomeId = new LogicLong(senderIdHighNumber.GetIntValue(), senderIdLowNumber.GetIntValue()); } }
/// <summary> /// Loads this instance from json. /// </summary> internal void Load(string json) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json); this.Id = new LogicLong(LogicJSONHelper.GetJSONNumber(jsonObject, "id_hi"), LogicJSONHelper.GetJSONNumber(jsonObject, "id_lo")); this.PassToken = LogicJSONHelper.GetJSONString(jsonObject, "pass_t"); this.PlayTimeSecs = LogicJSONHelper.GetJSONNumber(jsonObject, "pt_secs"); this.AccountCreatedDate = LogicJSONHelper.GetJSONString(jsonObject, "acc_cr"); this.TotalBan = LogicJSONHelper.GetJSONNumber(jsonObject, "t_ban"); LogicJSONArray sessionArray = jsonObject.GetJSONArray("sessions"); if (sessionArray != null) { int size = LogicMath.Min(sessionArray.Size(), 20); for (int i = 0; i < size; i++) { LogicJSONObject obj = sessionArray.GetJSONObject(i); AccountSession session = new AccountSession(); session.Load(obj); this.LastSessions.Add(session); } } LogicJSONObject banObject = jsonObject.GetJSONObject("ban"); if (banObject != null) { this.CurrentBan = new AccountBan(); this.CurrentBan.Load(banObject); } }
public override void WriteToJSON(LogicJSONObject jsonObject) { base.WriteToJSON(jsonObject); LogicJSONHelper.SetLogicData(jsonObject, "resource", this.m_resourceData); jsonObject.Put("resourceAmount", new LogicJSONNumber(this.m_resourceAmount)); }
/// <summary> /// Loads this instance from json. /// </summary> public void Load(LogicJSONObject jsonObject) { this._avatarId = new LogicLong(LogicJSONHelper.GetJSONNumber(jsonObject, "avatar_id_hi"), LogicJSONHelper.GetJSONNumber(jsonObject, "avatar_id_lo")); this._homeId = new LogicLong(LogicJSONHelper.GetJSONNumber(jsonObject, "home_id_hi"), LogicJSONHelper.GetJSONNumber(jsonObject, "home_id_lo")); this._avatarName = LogicJSONHelper.GetJSONString(jsonObject, "name"); this._facebookId = LogicJSONHelper.GetJSONString(jsonObject, "facebook_id"); this._expLevel = LogicJSONHelper.GetJSONNumber(jsonObject, "exp_lvl"); this._leagueType = LogicJSONHelper.GetJSONNumber(jsonObject, "league_type"); this._nameChangeState = LogicJSONHelper.GetJSONNumber(jsonObject, "name_change_state"); this._nameSetByUser = LogicJSONHelper.GetJSONBoolean(jsonObject, "name_set"); LogicJSONNumber allianceIdHigh = jsonObject.GetJSONNumber("alliance_id_hi"); LogicJSONNumber allianceIdLow = jsonObject.GetJSONNumber("alliance_id_lo"); if (allianceIdHigh != null && allianceIdLow != null) { this._allianceId = new LogicLong(allianceIdHigh.GetIntValue(), allianceIdLow.GetIntValue()); this._allianceName = LogicJSONHelper.GetJSONString(jsonObject, "alliance_name"); this._allianceExpLevel = LogicJSONHelper.GetJSONNumber(jsonObject, "alliance_exp_lvl"); this._allianceRole = LogicJSONHelper.GetJSONNumber(jsonObject, "alliance_role"); this._badgeId = LogicJSONHelper.GetJSONNumber(jsonObject, "badge_id"); } else { this._badgeId = -1; } }
private static void LoadFingerprint() { ResourceManager.FINGERPRINT_JSON = ResourceManager.LoadAssetString("fingerprint.json"); if (ResourceManager.FINGERPRINT_JSON != null) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(ResourceManager.FINGERPRINT_JSON); ResourceManager.FINGERPRINT_SHA = LogicJSONHelper.GetString(jsonObject, "sha"); ResourceManager.FINGERPRINT_VERSION = LogicJSONHelper.GetString(jsonObject, "version"); string[] version = ResourceManager.FINGERPRINT_VERSION.Split('.'); if (version.Length == 3) { ResourceManager.m_version = new int[3]; for (int i = 0; i < 3; i++) { ResourceManager.m_version[i] = int.Parse(version[i]); } } else { Logging.Error("ResourceManager.loadFingerprint: invalid fingerprint version: " + ResourceManager.FINGERPRINT_VERSION); } ZLibHelper.CompressInZLibFormat(LogicStringUtil.GetBytes(ResourceManager.FINGERPRINT_JSON), out ResourceManager.COMPRESSED_FINGERPRINT_DATA); } else { Logging.Error("ResourceManager.loadFingerprint: fingerprint.json not exist"); } }
public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); this.m_buildingData = (LogicBuildingData)LogicJSONHelper.GetLogicData(jsonObject, "building"); this.m_buildingCount = LogicJSONHelper.GetInt(jsonObject, "buildingNumber"); this.m_buildingLevel = LogicJSONHelper.GetInt(jsonObject, "buildingLevel"); }
public override void WriteToJSON(LogicJSONObject jsonObject) { base.WriteToJSON(jsonObject); LogicJSONHelper.SetLogicData(jsonObject, "building", this.m_buildingData); jsonObject.Put("buildingNumber", new LogicJSONNumber(this.m_buildingCount)); jsonObject.Put("buildingLevel", new LogicJSONNumber(this.m_buildingLevel)); }
/// <summary> /// Initializes this instance. /// </summary> internal static void Initialize() { ResourceManager.FingerprintJson = File.ReadAllText("Assets/fingerprint.json"); LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(ResourceManager.FingerprintJson); ResourceManager.FingerprintSha = LogicJSONHelper.GetJSONString(jsonObject, "sha"); ResourceManager.FingerprintVersion = LogicJSONHelper.GetJSONString(jsonObject, "version"); }
public void Load(LogicJSONObject jsonObject) { Debugger.DoAssert(jsonObject != null, "Unable to load targeting"); this.m_minTownHallLevel = LogicJSONHelper.GetInt(jsonObject, "minTownHallLevel") & 0x7FFFFFFF; this.m_maxTownHallLevel = LogicJSONHelper.GetInt(jsonObject, "maxTownHallLevel") & 0x7FFFFFFF; this.m_minGemsLevel = LogicJSONHelper.GetInt(jsonObject, "minGemsPurchased") & 0x7FFFFFFF; this.m_maxGemsLevel = LogicJSONHelper.GetInt(jsonObject, "maxGemsPurchased") & 0x7FFFFFFF; }
public override void Load(LogicJSONObject jsonObject) { base.Load(jsonObject); this.m_duelLootLimitCooldownInMinutes = LogicJSONHelper.GetInt(jsonObject, "lootLimitCooldownInMinutes", 1320); this.m_duelBonusPercentWin = LogicJSONHelper.GetInt(jsonObject, "duelBonusPercentWin", 100); this.m_duelBonusPercentLose = LogicJSONHelper.GetInt(jsonObject, "duelBonusPercentLose", 0); this.m_duelBonusPercentDraw = LogicJSONHelper.GetInt(jsonObject, "duelBonusPercentDraw", 0); this.m_duelBonusMaxDiamondCostPercent = LogicJSONHelper.GetInt(jsonObject, "duelBonusMaxDiamondCostPercent", 100); }
/// <summary> /// Reads this instance from json. /// </summary> public void ReadFromJSON(LogicJSONObject jsonObject) { LogicJSONNumber id = jsonObject.GetJSONNumber("id"); if (id != null && id.GetIntValue() != 0) { this._data = LogicDataTables.GetDataById(id.GetIntValue()); } this._count = LogicJSONHelper.GetJSONNumber(jsonObject, "cnt"); }
/// <summary> /// Loads the account info from json. /// </summary> internal void LoadAccount() { if (File.Exists("Files/save.json")) { LogicJSONObject jsonRoot = (LogicJSONObject)LogicJSONParser.Parse(File.ReadAllText("Files/save.json")); this._account.AccountHighId = LogicJSONHelper.GetJSONNumber(jsonRoot, "High"); this._account.AccountLowId = LogicJSONHelper.GetJSONNumber(jsonRoot, "Low"); this._account.AccountPassToken = LogicJSONHelper.GetJSONString(jsonRoot, "Pass"); } }
public void ReadFromJSON(LogicJSONObject jsonObject) { this.m_bestSeasonState = LogicJSONHelper.GetInt(jsonObject, "best_season_state"); this.m_bestSeasonYear = LogicJSONHelper.GetInt(jsonObject, "best_season_year"); this.m_bestSeasonMonth = LogicJSONHelper.GetInt(jsonObject, "best_season_month"); this.m_bestSeasonRank = LogicJSONHelper.GetInt(jsonObject, "best_season_rank"); this.m_bestSeasonScore = LogicJSONHelper.GetInt(jsonObject, "best_season_score"); this.m_lastSeasonState = LogicJSONHelper.GetInt(jsonObject, "last_season_state"); this.m_lastSeasonYear = LogicJSONHelper.GetInt(jsonObject, "last_season_year"); this.m_lastSeasonMonth = LogicJSONHelper.GetInt(jsonObject, "last_season_month"); this.m_lastSeasonRank = LogicJSONHelper.GetInt(jsonObject, "last_season_rank"); this.m_lastSeasonScore = LogicJSONHelper.GetInt(jsonObject, "last_season_score"); }
/// <summary> /// Loads this instance from json. /// </summary> internal void Load(string json) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json); this.Id = new LogicLong(LogicJSONHelper.GetJSONNumber(jsonObject, "id_hi"), LogicJSONHelper.GetJSONNumber(jsonObject, "id_lo")); LogicJSONObject entryObject = jsonObject.GetJSONObject("entry"); if (entryObject != null) { this.AvatarEntry.Load(entryObject); } }
/// <summary> /// Loads this instance from json. /// </summary> public void Load(LogicJSONObject json) { this._homeId = new LogicLong(LogicJSONHelper.GetJSONNumber(json, "home_id_high"), LogicJSONHelper.GetJSONNumber(json, "home_id_low")); this._shieldDurationSeconds = LogicJSONHelper.GetJSONNumber(json, "shield_duration_secs"); this._guardDurationSeconds = LogicJSONHelper.GetJSONNumber(json, "guard_duration_secs"); this._nextMaintenanceSeconds = LogicJSONHelper.GetJSONNumber(json, "next_maintenance_secs"); LogicJSONObject level = json.GetJSONObject("level"); if (level != null) { this._compressibleHomeJson.Load(level); } }
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); } } }
public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); LogicJSONArray jsonArray = jsonObject.GetJSONArray("dels"); if (jsonArray != null) { for (int i = 0; i < jsonArray.Size(); i++) { LogicJSONObject obj = jsonArray.GetJSONObject(i); if (obj != null) { this.m_deliverables.Add(LogicJSONHelper.GetLogicDeliverable(obj)); } } } }
public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); this.m_decoData = (LogicDecoData)LogicJSONHelper.GetLogicData(jsonObject, "decoration"); }
public override void WriteToJSON(LogicJSONObject jsonObject) { base.WriteToJSON(jsonObject); LogicJSONHelper.SetLogicData(jsonObject, "decoration", this.m_decoData); }
/// <summary> /// Loads this instance from json. /// </summary> internal void Load(LogicJSONObject jsonObject) { this.BanReason = LogicJSONHelper.GetJSONString(jsonObject, "rs"); this.EndBanTime = LogicJSONHelper.GetJSONNumber(jsonObject, "et"); }
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!"); } }
/// <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"); }