public override void Save(LogicJSONObject jsonObject) { LogicJSONObject baseObject = new LogicJSONObject(); base.Save(baseObject); jsonObject.Put("base", baseObject); jsonObject.Put("battle_result", new LogicJSONNumber(this.m_resultType)); jsonObject.Put("attacker_stars", new LogicJSONNumber(this.m_attackerStars)); jsonObject.Put("attacker_destruction_percentage", new LogicJSONNumber(this.m_attackerDestructionPercentage)); jsonObject.Put("opponent_stars", new LogicJSONNumber(this.m_opponentStars)); jsonObject.Put("opponent_destruction_percentage", new LogicJSONNumber(this.m_opponentDestructionPercentage)); jsonObject.Put("golds", new LogicJSONNumber(this.m_goldCount)); jsonObject.Put("elixirs", new LogicJSONNumber(this.m_elixirCount)); jsonObject.Put("scores", new LogicJSONNumber(this.m_scoreCount)); jsonObject.Put("battle_ended", new LogicJSONBoolean(this.m_battleEnded)); if (this.m_attackerReplayId != null) { jsonObject.Put("attacker_replay_id_hi", new LogicJSONNumber(this.m_attackerReplayId.GetHigherInt())); jsonObject.Put("attacker_replay_id_lo", new LogicJSONNumber(this.m_attackerReplayId.GetLowerInt())); jsonObject.Put("attacker_replay_shard_id", new LogicJSONNumber(this.m_attackerReplayShardId)); jsonObject.Put("attacker_replay_major_v", new LogicJSONNumber(this.m_attackerReplayMajorVersion)); jsonObject.Put("attacker_replay_build_v", new LogicJSONNumber(this.m_attackerReplayBuildVersion)); jsonObject.Put("attacker_replay_content_v", new LogicJSONNumber(this.m_attackerReplayContentVersion)); } if (this.m_opponentReplayId != null) { jsonObject.Put("opponent_replay_id_hi", new LogicJSONNumber(this.m_opponentReplayId.GetHigherInt())); jsonObject.Put("opponent_replay_id_lo", new LogicJSONNumber(this.m_opponentReplayId.GetLowerInt())); jsonObject.Put("opponent_replay_shard_id", new LogicJSONNumber(this.m_opponentReplayShardId)); jsonObject.Put("opponent_replay_major_v", new LogicJSONNumber(this.m_opponentReplayMajorVersion)); jsonObject.Put("opponent_replay_build_v", new LogicJSONNumber(this.m_opponentReplayBuildVersion)); jsonObject.Put("opponent_replay_content_v", new LogicJSONNumber(this.m_opponentReplayContentVersion)); } jsonObject.Put("attacker_battleLog", new LogicJSONString(this.m_attackerBattleLog)); jsonObject.Put("opponent_battleLog", new LogicJSONString(this.m_opponentBattleLog)); }
public override void Save(LogicJSONObject jsonObject) { LogicJSONObject baseObject = new LogicJSONObject(); base.Save(baseObject); jsonObject.Put("base", baseObject); jsonObject.Put("title", new LogicJSONString(this.m_titleTID)); jsonObject.Put("description", new LogicJSONString(this.m_descriptionTID)); if (this.m_buttonTID != null) { jsonObject.Put("button", new LogicJSONString(this.m_buttonTID)); } if (this.m_helpshiftLink != null) { jsonObject.Put("helpshift_url", new LogicJSONString(this.m_helpshiftLink)); } if (this.m_urlLink != null) { jsonObject.Put("url", new LogicJSONString(this.m_urlLink)); } if (this.m_diamondCount != 0) { jsonObject.Put("diamonds", new LogicJSONNumber(this.m_diamondCount)); } if (this.m_supportMessage) { jsonObject.Put("support_msg", new LogicJSONBoolean(this.m_supportMessage)); } if (this.m_claimed) { jsonObject.Put("claimed", new LogicJSONBoolean(this.m_claimed)); } }
public void LoadGameObjectsJsonArray(LogicLevel level, LogicJSONArray array, int villageType) { if (array != null) { for (int i = 0; i < array.Size(); i++) { LogicJSONObject jsonObject = array.GetJSONObject(i); if (jsonObject != null) { LogicGameObjectData data = (LogicGameObjectData)LogicDataTables.GetDataById(jsonObject.GetJSONNumber("data").GetIntValue()); if (data != null) { LogicGameObject gameObject = LogicGameObjectFactory.CreateGameObject(data, level, villageType); gameObject.Load(jsonObject); level.GetGameObjectManagerAt(1).AddGameObject(gameObject, -1); } } } } }
/// <summary> /// Loads this instance from json. /// </summary> public virtual void Load(LogicJSONObject jsonObject) { LogicJSONNumber xNumber = jsonObject.GetJSONNumber("x"); LogicJSONNumber yNumber = jsonObject.GetJSONNumber("y"); for (int i = 0; i < this._components.Count; i++) { LogicComponent component = this._components[i]; if (component != null) { component.Load(jsonObject); } } if (xNumber == null || yNumber == null) { Debugger.Error("LogicGameObject::load - x or y is NULL!"); } this.SetInitialPosition(xNumber.GetIntValue() << 9, yNumber.GetIntValue() << 9); }
public override void Save(LogicJSONObject jsonObject) { LogicJSONObject baseObject = new LogicJSONObject(); base.Save(baseObject); jsonObject.Put("base", baseObject); jsonObject.Put("diamond_reward", new LogicJSONNumber(this.m_diamondReward)); jsonObject.Put("gift_count", new LogicJSONNumber(this.m_giftCount)); LogicJSONArray collectedPlayersArray = new LogicJSONArray(this.m_collectedPlayers.Size()); for (int i = 0; i < this.m_collectedPlayers.Size(); i++) { LogicJSONArray array = new LogicJSONArray(2); array.Add(new LogicJSONNumber(this.m_collectedPlayers[i].GetHigherInt())); array.Add(new LogicJSONNumber(this.m_collectedPlayers[i].GetLowerInt())); collectedPlayersArray.Add(array); } jsonObject.Put("collected_players", collectedPlayersArray); }
public virtual void LoadFromSnapshot(LogicJSONObject jsonObject) { LogicJSONNumber xNumber = jsonObject.GetJSONNumber("x"); LogicJSONNumber yNumber = jsonObject.GetJSONNumber("y"); if (xNumber == null || yNumber == null) { Debugger.Error("LogicGameObject::load - x or y is NULL!"); } this.SetInitialPosition(xNumber.GetIntValue() << 9, yNumber.GetIntValue() << 9); for (int i = 0; i < LogicComponent.COMPONENT_TYPE_COUNT; i++) { LogicComponent component = this.m_components[i]; if (component != null) { component.LoadFromSnapshot(jsonObject); } } }
/// <summary> /// Saves this instance. /// </summary> public virtual void Save(LogicJSONObject jsonObject) { jsonObject.Put("id_hi", new LogicJSONNumber(this._id.GetHigherInt())); jsonObject.Put("id_lo", new LogicJSONNumber(this._id.GetLowerInt())); LogicJSONObject senderObject = new LogicJSONObject(); if (this._senderAvatarId != null) { senderObject.Put("id_hi", new LogicJSONNumber(this._senderAvatarId.GetHigherInt())); senderObject.Put("id_lo", new LogicJSONNumber(this._senderAvatarId.GetLowerInt())); } senderObject.Put("name", new LogicJSONString(this._senderName)); senderObject.Put("exp_lvl", new LogicJSONNumber(this._senderExpLevel)); senderObject.Put("league_type", new LogicJSONNumber(this._senderLeagueType)); senderObject.Put("age_secs", new LogicJSONNumber(this._ageSeconds)); senderObject.Put("is_dismissed", new LogicJSONBoolean(this._dismiss)); senderObject.Put("is_new", new LogicJSONBoolean(this._new)); jsonObject.Put("sender", senderObject); }
public override void Load(LogicJSONObject jsonObject) { base.Load(jsonObject.GetJSONObject("base")); this.m_resultType = jsonObject.GetJSONNumber("battle_result").GetIntValue(); this.m_attackerStars = jsonObject.GetJSONNumber("attacker_stars").GetIntValue(); this.m_attackerDestructionPercentage = jsonObject.GetJSONNumber("attacker_destruction_percentage").GetIntValue(); this.m_opponentStars = jsonObject.GetJSONNumber("opponent_stars").GetIntValue(); this.m_opponentDestructionPercentage = jsonObject.GetJSONNumber("opponent_destruction_percentage").GetIntValue(); this.m_goldCount = jsonObject.GetJSONNumber("golds").GetIntValue(); this.m_elixirCount = jsonObject.GetJSONNumber("elixirs").GetIntValue(); this.m_scoreCount = jsonObject.GetJSONNumber("scores").GetIntValue(); this.m_battleEnded = jsonObject.GetJSONBoolean("battle_ended").IsTrue(); LogicJSONNumber attackerReplayIdHighNumber = jsonObject.GetJSONNumber("attacker_replay_id_hi"); if (attackerReplayIdHighNumber != null) { this.m_attackerReplayId = new LogicLong(attackerReplayIdHighNumber.GetIntValue(), jsonObject.GetJSONNumber("attacker_replay_id_lo").GetIntValue()); this.m_attackerReplayShardId = jsonObject.GetJSONNumber("attacker_replay_shard_id").GetIntValue(); this.m_attackerReplayMajorVersion = jsonObject.GetJSONNumber("attacker_replay_major_v").GetIntValue(); this.m_attackerReplayBuildVersion = jsonObject.GetJSONNumber("attacker_replay_build_v").GetIntValue(); this.m_attackerReplayContentVersion = jsonObject.GetJSONNumber("attacker_replay_content_v").GetIntValue(); } LogicJSONNumber opponentReplayIdHighNumber = jsonObject.GetJSONNumber("opponent_replay_id_hi"); if (opponentReplayIdHighNumber != null) { this.m_attackerReplayId = new LogicLong(opponentReplayIdHighNumber.GetIntValue(), jsonObject.GetJSONNumber("opponent_replay_id_lo").GetIntValue()); this.m_attackerReplayShardId = jsonObject.GetJSONNumber("opponent_replay_shard_id").GetIntValue(); this.m_attackerReplayMajorVersion = jsonObject.GetJSONNumber("opponent_replay_major_v").GetIntValue(); this.m_attackerReplayBuildVersion = jsonObject.GetJSONNumber("opponent_replay_build_v").GetIntValue(); this.m_attackerReplayContentVersion = jsonObject.GetJSONNumber("opponent_replay_content_v").GetIntValue(); } this.m_attackerBattleLog = jsonObject.GetJSONString("attacker_battleLog").GetStringValue(); this.m_opponentBattleLog = jsonObject.GetJSONString("opponent_battleLog").GetStringValue(); }
public override void Save(LogicJSONObject jsonObject) { LogicJSONObject baseObject = new LogicJSONObject(); base.Save(baseObject); jsonObject.Put("base", baseObject); jsonObject.Put("battleLog", new LogicJSONString(this.m_battleLogJSON)); jsonObject.Put("message", new LogicJSONString(this.m_message)); jsonObject.Put("opponent_name", new LogicJSONString(this.m_opponentName)); jsonObject.Put("attack", new LogicJSONBoolean(this.m_attack)); jsonObject.Put("replay_major_v", new LogicJSONNumber(this.m_majorVersion)); jsonObject.Put("replay_build_v", new LogicJSONNumber(this.m_buildVersion)); jsonObject.Put("replay_content_v", new LogicJSONNumber(this.m_contentVersion)); if (this.m_replayId != null) { jsonObject.Put("replay_shard_id", new LogicJSONNumber(this.m_replayShardId)); jsonObject.Put("replay_id_hi", new LogicJSONNumber(this.m_replayId.GetHigherInt())); jsonObject.Put("replay_id_lo", new LogicJSONNumber(this.m_replayId.GetLowerInt())); } }
public override void Save(LogicJSONObject root, int villageType) { if (this.m_timer != null && this.m_hero != null) { LogicJSONObject jsonObject = new LogicJSONObject(); jsonObject.Put("level", new LogicJSONNumber(this.m_upgLevel)); jsonObject.Put("t", new LogicJSONNumber(this.m_timer.GetRemainingSeconds(this.m_parent.GetLevel().GetLogicTime()))); if (this.m_timer.GetEndTimestamp() != -1) { jsonObject.Put("t_end", new LogicJSONNumber(this.m_timer.GetEndTimestamp())); } if (this.m_timer.GetFastForward() > 0) { jsonObject.Put("t_ff", new LogicJSONNumber(this.m_timer.GetFastForward())); } root.Put("hero_upg", jsonObject); } }
public static LogicCommand LoadCommandFromJSON(LogicJSONObject jsonObject) { LogicJSONNumber jsonNumber = jsonObject.GetJSONNumber("ct"); if (jsonNumber == null) { Debugger.Error("loadCommandFromJSON - Unknown command type"); } else { LogicCommand command = LogicCommandManager.CreateCommand((LogicCommandType)jsonNumber.GetIntValue()); if (command != null) { command.LoadFromJSON(jsonObject.GetJSONObject("c")); } return(command); } return(null); }
public override void Load(LogicJSONObject jsonObject) { LogicJSONArray unitArray = jsonObject.GetJSONArray("units"); if (unitArray != null) { if (this.m_slots.Size() > 0) { Debugger.Error("LogicUnitStorageComponent::load - Unit array size > 0!"); } for (int i = 0, size = unitArray.Size(); i < size; i++) { LogicJSONArray unitObject = unitArray.GetJSONArray(i); if (unitObject != null) { LogicJSONNumber dataObject = unitObject.GetJSONNumber(0); LogicJSONNumber countObject = unitObject.GetJSONNumber(1); if (dataObject != null) { if (countObject != null) { LogicData data = LogicDataTables.GetDataById(dataObject.GetIntValue(), this.m_storageType != 0 ? LogicDataType.SPELL : LogicDataType.CHARACTER); if (data == null) { Debugger.Error("LogicUnitStorageComponent::load - Character data is NULL!"); } this.m_slots.Add(new LogicUnitSlot(data, -1, countObject.GetIntValue())); } } } } } }
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(); } }
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 override void Load(LogicJSONObject jsonObject) { LogicLevel level = this.m_parent.GetLevel(); int villageType = this.m_parent.GetVillageType(); int activeLayout = level.GetActiveLayout(); for (int i = 0; i < 8; i++) { if (i == activeLayout) { this.m_layoutPosition[i].Set(this.m_parent.GetTileX(), this.m_parent.GetTileY()); } else { LogicJSONNumber xNumber = jsonObject.GetJSONNumber(this.GetLayoutVariableNameX(i, false)); LogicJSONNumber yNumber = jsonObject.GetJSONNumber(this.GetLayoutVariableNameY(i, false)); if (xNumber != null && yNumber != null) { this.m_layoutPosition[i].Set(xNumber.GetIntValue(), yNumber.GetIntValue()); } } } for (int i = 0; i < 8; i++) { if (level.GetLayoutState(i, villageType) == 1) { LogicJSONNumber xNumber = jsonObject.GetJSONNumber(this.GetLayoutVariableNameX(i, true)); LogicJSONNumber yNumber = jsonObject.GetJSONNumber(this.GetLayoutVariableNameY(i, true)); if (xNumber != null && yNumber != null) { this.m_editModeLayoutPosition[i].Set(xNumber.GetIntValue(), yNumber.GetIntValue()); } } } }
protected sealed override void Load(LogicJSONObject jsonObject) { LogicJSONArray ownerIdArray = jsonObject.GetJSONArray(StreamDocument.JSON_ATTRIBUTE_OWNER_ID); this.OwnerId = new LogicLong(ownerIdArray.GetJSONNumber(0).GetIntValue(), ownerIdArray.GetJSONNumber(1).GetIntValue()); this.CreateTime = DateTime.Parse(jsonObject.GetJSONString(StreamDocument.JSON_ATTRIBUTE_CREATE_TIME).GetStringValue()); this.Type = (StreamType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_TYPE).GetIntValue(); switch (this.Type) { case StreamType.ALLIANCE: { StreamEntry entry = StreamEntryFactory.CreateStreamEntryByType((StreamEntryType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE).GetIntValue()); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); entry.SetId(this.Id); this.Entry = entry; break; } case StreamType.AVATAR: { AvatarStreamEntry entry = AvatarStreamEntryFactory.CreateStreamEntryByType((AvatarStreamEntryType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE).GetIntValue()); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); entry.SetId(this.Id); this.Entry = entry; break; } case StreamType.REPLAY: { ReplayStreamEntry entry = new ReplayStreamEntry(); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); this.Entry = entry; break; } } }
public static void Load(LogicJSONObject jsonObject) { EnvironmentSettings.Environment = jsonObject.GetJSONString("environment").GetStringValue(); LogicJSONObject serverObject = jsonObject.GetJSONObject("servers"); if (serverObject != null) { EnvironmentSettings.Settings = new ServerSettings(serverObject.GetJSONObject("settings")); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("admin"), 0); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("proxy"), 1); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("account"), 2); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("friend"), 3); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("chat"), 6); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("game"), 9); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("home"), 10); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("stream"), 11); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("league"), 13); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("war"), 25); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("battle"), 27); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("scoring"), 28); EnvironmentSettings.LoadServerArray(serverObject.GetJSONArray("search"), 29); } LogicJSONObject databaseObject = jsonObject.GetJSONObject("database"); if (databaseObject != null) { EnvironmentSettings.HigherIdCounterSize = databaseObject.GetJSONNumber("higher_id_counter_size").GetIntValue(); EnvironmentSettings.Couchbase = new CouchbaseSettings(databaseObject.GetJSONObject("couchbase")); EnvironmentSettings.Redis = new RedisSettings(databaseObject.GetJSONObject("redis")); } EnvironmentSettings.SupportedAppVersions = EnvironmentSettings.LoadStringArray(jsonObject.GetJSONArray("supported_app_versions")); EnvironmentSettings.SupportedCountries = EnvironmentSettings.LoadStringArray(jsonObject.GetJSONArray("supported_countries")); EnvironmentSettings.DeveloperIPs = EnvironmentSettings.LoadStringArray(jsonObject.GetJSONArray("developer_ips")); }
public LogicJSONObject Save() { LogicJSONObject jsonObject = new LogicJSONObject(); jsonObject.Put("avatar_id_high", new LogicJSONNumber(this.m_avatarId.GetHigherInt())); jsonObject.Put("avatar_id_low", new LogicJSONNumber(this.m_avatarId.GetLowerInt())); LogicJSONArray donationArray = new LogicJSONArray(this.m_donationData.Size()); for (int i = 0; i < this.m_donationData.Size(); i++) { LogicJSONArray array = new LogicJSONArray(); array.Add(new LogicJSONNumber(this.m_donationData[i].GetGlobalID())); array.Add(new LogicJSONNumber(this.m_donationLevel[i])); donationArray.Add(array); } jsonObject.Put("donations", donationArray); return(jsonObject); }
/// <summary> /// Loads this instance from json. /// </summary> public void Load(LogicJSONObject jsonObject) { LogicJSONNumber cooldownNumber = jsonObject.GetJSONNumber("cooldown"); LogicJSONNumber targetNumber = jsonObject.GetJSONNumber("target"); if (cooldownNumber != null) { this._cooldownTime = cooldownNumber.GetIntValue(); } else { Debugger.Error("LogicCooldown::load - Cooldown was not found!"); } if (targetNumber != null) { this._targetGlobalId = targetNumber.GetIntValue(); } else { Debugger.Error("LogicCooldown::load - Target was not found!"); } }
public override void LoadFromJSON(LogicJSONObject jsonRoot) { LogicJSONObject baseObject = jsonRoot.GetJSONObject("base"); if (baseObject == null) { Debugger.Error("Replay LogicTriggerHeroAbility load failed! Base missing!"); } base.LoadFromJSON(baseObject); LogicJSONNumber dataNumber = jsonRoot.GetJSONNumber("d"); if (dataNumber != null) { this.m_data = (LogicHeroData)LogicDataTables.GetDataById(dataNumber.GetIntValue(), LogicDataType.HERO); } if (this.m_data == null) { Debugger.Error("Replay LogicTriggerHeroAbility load failed! Hero is NULL!"); } }
protected sealed override void Load(LogicJSONObject jsonObject) { this.Header.Load(jsonObject); this.Header.SetAllianceId(this.Id); this.Description = jsonObject.GetJSONString(AllianceDocument.JSON_ATTRIBUTE_DESCRIPTION).GetStringValue(); LogicJSONArray memberArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_MEMBERS); for (int i = 0; i < memberArray.Size(); i++) { AllianceMemberEntry allianceMemberEntry = new AllianceMemberEntry(); allianceMemberEntry.Load(memberArray.GetJSONObject(i)); this.Members.Add(allianceMemberEntry.GetAvatarId(), allianceMemberEntry); } LogicJSONArray kickedMemberTimeArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES); for (int i = 0; i < kickedMemberTimeArray.Size(); i++) { LogicJSONObject obj = kickedMemberTimeArray.GetJSONObject(i); LogicJSONArray avatarIdArray = obj.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES_ID); LogicLong avatarId = new LogicLong(avatarIdArray.GetJSONNumber(0).GetIntValue(), avatarIdArray.GetJSONNumber(1).GetIntValue()); DateTime kickTime = DateTime.Parse(obj.GetJSONString(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES_TIME).GetStringValue()); this.KickedMembersTimes.Add(avatarId, kickTime); } LogicJSONArray streamArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_STREAM_ENTRY_LIST); for (int i = 0; i < streamArray.Size(); i++) { LogicJSONArray avatarIdArray = streamArray.GetJSONArray(i); LogicLong id = new LogicLong(avatarIdArray.GetJSONNumber(0).GetIntValue(), avatarIdArray.GetJSONNumber(1).GetIntValue()); this.StreamEntryList.Add(id); } }
public static LogicJSONObject Save() { LogicJSONObject jsonObject = new LogicJSONObject(); jsonObject.Put("environment", new LogicJSONString(EnvironmentSettings.Environment)); LogicJSONObject serverObject = new LogicJSONObject(); serverObject.Put("settings", EnvironmentSettings.Settings.Save()); serverObject.Put("admin", EnvironmentSettings.SaveServerArray(0)); serverObject.Put("proxy", EnvironmentSettings.SaveServerArray(1)); serverObject.Put("account", EnvironmentSettings.SaveServerArray(2)); serverObject.Put("friend", EnvironmentSettings.SaveServerArray(3)); serverObject.Put("chat", EnvironmentSettings.SaveServerArray(6)); serverObject.Put("avatar", EnvironmentSettings.SaveServerArray(9)); serverObject.Put("home", EnvironmentSettings.SaveServerArray(10)); serverObject.Put("stream", EnvironmentSettings.SaveServerArray(11)); serverObject.Put("league", EnvironmentSettings.SaveServerArray(13)); serverObject.Put("war", EnvironmentSettings.SaveServerArray(25)); serverObject.Put("battle", EnvironmentSettings.SaveServerArray(27)); serverObject.Put("scoring", EnvironmentSettings.SaveServerArray(28)); serverObject.Put("search", EnvironmentSettings.SaveServerArray(29)); jsonObject.Put("servers", serverObject); LogicJSONObject databaseObject = new LogicJSONObject(); databaseObject.Put("higher_id_counter_size", new LogicJSONNumber(EnvironmentSettings.HigherIdCounterSize)); databaseObject.Put("couchbase", EnvironmentSettings.Couchbase.Save()); databaseObject.Put("redis", EnvironmentSettings.Redis.Save()); jsonObject.Put("supported_app_versions", EnvironmentSettings.SaveStringArray(EnvironmentSettings.SupportedAppVersions)); jsonObject.Put("supported_countries", EnvironmentSettings.SaveStringArray(EnvironmentSettings.SupportedCountries)); jsonObject.Put("developer_ips", EnvironmentSettings.SaveStringArray(EnvironmentSettings.DeveloperIPs)); return(jsonObject); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { LogicGameObjectManager gameObjectManager = level.GetGameObjectManagerAt(1); if (gameObjectManager.GetTownHall() == null) { LogicJSONObject jsonObject = level.GetGameListener().ParseCompressedHomeJSON(this.m_compressedHomeJSON, this.m_compressedHomeJSON.Length); level.SetLoadingVillageType(1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("buildings2"), 1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("obstacles2"), 1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("traps2"), 1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("decos2"), 1); level.SetLoadingVillageType(-1); if (playerAvatar.GetResourceCount(LogicDataTables.GetGold2Data()) == 0) { playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetGold2Data(), LogicDataTables.GetGlobals().GetStartingGold2()); } if (playerAvatar.GetResourceCount(LogicDataTables.GetElixir2Data()) == 0) { playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetElixir2Data(), LogicDataTables.GetGlobals().GetStartingElixir2()); } } return(0); } return(-1); }
public ChecksumHelper CalculateChecksum(LogicJSONObject root, bool includeGameObjects) { ChecksumHelper checksum = new ChecksumHelper(root); checksum.StartObject("LogicGameMode"); checksum.WriteValue("subtick", this.m_level.GetLogicTime().GetTick()); checksum.WriteValue("m_currentTimestamp", this.m_startTimestamp); if (this.m_level.GetHomeOwnerAvatar() != null) { checksum.StartObject("homeOwner"); this.m_level.GetHomeOwnerAvatar().GetChecksum(checksum); checksum.EndObject(); } if (this.m_level.GetVisitorAvatar() != null) { checksum.StartObject("visitor"); this.m_level.GetVisitorAvatar().GetChecksum(checksum); checksum.EndObject(); } this.m_level.GetGameObjectManager().GetChecksum(checksum, includeGameObjects); if (this.m_calendar != null) { checksum.StartObject("calendar"); this.m_calendar.GetChecksum(checksum); checksum.EndObject(); } checksum.WriteValue("checksum", checksum.GetChecksum()); checksum.EndObject(); return(checksum); }
/// <summary> /// Saves this instance. /// </summary> public override void Save(LogicJSONObject jsonObject) { LogicJSONArray unitArray = new LogicJSONArray(); for (int i = 0; i < this._slots.Count; i++) { LogicUnitSlot slot = this._slots[i]; if (slot.GetData() != null && slot.GetCount() > 0) { if (slot.GetLevel() != -1) { Debugger.Error("Invalid unit level."); } LogicJSONArray unitObject = new LogicJSONArray(2); unitObject.Add(new LogicJSONNumber(slot.GetData().GetGlobalID())); unitObject.Add(new LogicJSONNumber(slot.GetCount())); unitArray.Add(unitObject); } } jsonObject.Put("units", unitArray); }
public void Load(string json, int activeTimestamp) { Debugger.DoAssert(json != null, "Event json NULL"); if (json.Length > 0) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json); if (jsonObject != null) { LogicArrayList <LogicCalendarEvent> events = new LogicArrayList <LogicCalendarEvent>(); LogicJSONArray eventArray = jsonObject.GetJSONArray("events"); if (eventArray != null) { for (int i = 0; i < eventArray.Size(); i++) { LogicJSONObject calendarObject = eventArray.GetJSONObject(i); if (calendarObject == null) { Debugger.Error("Events json malformed!"); } events.Add(LogicCalendarEventFactory.LoadFromJSON(calendarObject, null)); } } this.LoadingFinished(events, activeTimestamp); } else { Debugger.Error("Events json malformed!"); } } }
public static int GetInt(LogicJSONObject jsonObject, string key, int defaultValue, bool throwIfNotExist) { if (jsonObject != null) { if (key.Length != 0) { LogicJSONNumber number = jsonObject.GetJSONNumber(key); if (number != null) { return(number.GetIntValue()); } if (!throwIfNotExist) { return(defaultValue); } Debugger.Error(string.Format("Json number with key='{0}' not found!", key)); } } return(-1); }
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); }
public override void Load(LogicJSONObject jsonObject) { base.Load(jsonObject); this.m_expLevel = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_EXP_LEVEL).GetIntValue(); this.m_attackWinCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_ATTACK_WIN_COUNT).GetIntValue(); this.m_attackLoseCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_ATTACK_LOSE_COUNT).GetIntValue(); this.m_defenseWinCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_DEFENSE_WIN_COUNT).GetIntValue(); this.m_defenseLoseCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_DEFENSE_LOSE_COUNT).GetIntValue(); this.m_leagueType = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_LEAGUE_TYPE).GetIntValue(); LogicJSONObject allianceObject = jsonObject.GetJSONObject(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE); if (allianceObject != null) { LogicJSONArray allianceIdArray = allianceObject.GetJSONArray(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_ID); this.m_allianceId = new LogicLong(allianceIdArray.GetJSONNumber(0).GetIntValue(), allianceIdArray.GetJSONNumber(1).GetIntValue()); this.m_allianceName = allianceObject.GetJSONString(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_NAME).GetStringValue(); this.m_allianceBadgeId = allianceObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_BADGE_ID).GetIntValue(); } this.m_homeId = this.GetId().Clone(); }
public override void LoadFromSnapshot(LogicJSONObject jsonObject) { LogicLevel level = this.m_parent.GetLevel(); LogicGameMode gameMode = level.GetGameMode(); if (gameMode.GetVisitType() == 1 || gameMode.GetVisitType() == 4 || gameMode.GetVisitType() == 5) { int idx = 7; if (gameMode.GetVisitType() != 4 || !level.IsArrangedWar()) { int warLayout = level.GetWarLayout(); if (warLayout < 0 || !level.IsWarBase()) { idx = level.GetActiveLayout(); } else { idx = warLayout; } } LogicJSONNumber xNumber = jsonObject.GetJSONNumber(this.GetLayoutVariableNameX(idx, false)); LogicJSONNumber yNumber = jsonObject.GetJSONNumber(this.GetLayoutVariableNameY(idx, false)); if (xNumber != null && yNumber != null) { this.m_parent.SetInitialPosition(xNumber.GetIntValue() << 9, yNumber.GetIntValue() << 9); Debugger.DoAssert(idx < 8, "Layout index out of bands"); this.m_layoutPosition[idx].Set(xNumber.GetIntValue(), yNumber.GetIntValue()); } } }