public virtual void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject senderObject = jsonObject.GetJSONObject("sender");

            if (senderObject != null)
            {
                LogicJSONNumber avatarIdHighNumber = senderObject.GetJSONNumber("avatar_id_hi");

                if (avatarIdHighNumber != null)
                {
                    this.m_senderAvatarId = new LogicLong(avatarIdHighNumber.GetIntValue(), senderObject.GetJSONNumber("avatar_id_lo").GetIntValue());
                }

                this.m_senderName       = senderObject.GetJSONString("name").GetStringValue();
                this.m_senderExpLevel   = senderObject.GetJSONNumber("exp_lvl").GetIntValue();
                this.m_senderLeagueType = senderObject.GetJSONNumber("league_type").GetIntValue();

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

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

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

                if (isNewObject != null)
                {
                    this.m_new = isNewObject.IsTrue();
                }
            }
        }
Пример #2
0
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("Replay LogicChangeUnitVillage2Command load failed! Base missing!");
            }

            base.LoadFromJSON(baseObject);

            LogicJSONNumber newDataNumber = jsonRoot.GetJSONNumber("n");

            if (newDataNumber != null)
            {
                this.m_newUnitData = (LogicCharacterData)LogicDataTables.GetDataById(newDataNumber.GetIntValue(), LogicDataType.CHARACTER);
            }

            LogicJSONNumber oldDataNumber = jsonRoot.GetJSONNumber("o");

            if (oldDataNumber != null)
            {
                this.m_oldUnitData = (LogicCharacterData)LogicDataTables.GetDataById(oldDataNumber.GetIntValue(), LogicDataType.CHARACTER);
            }
        }
Пример #3
0
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("Replay LogicCastSpellCommand load failed! Base missing!");
            }

            base.LoadFromJSON(baseObject);

            LogicJSONNumber dataNumber = jsonRoot.GetJSONNumber("d");

            if (dataNumber != null)
            {
                this.m_data = (LogicSpellData)LogicDataTables.GetDataById(dataNumber.GetIntValue(), LogicDataType.SPELL);
            }

            if (this.m_data == null)
            {
                Debugger.Error("Replay LogicCastSpellCommand load failed! Data is NULL!");
            }

            this.m_x = jsonRoot.GetJSONNumber("x").GetIntValue();
            this.m_y = jsonRoot.GetJSONNumber("y").GetIntValue();

            LogicJSONNumber dataLevelNumber = jsonRoot.GetJSONNumber("dl");

            if (dataLevelNumber != null)
            {
                this.m_allianceSpell = true;
                this.m_upgLevel      = dataLevelNumber.GetIntValue();
            }
        }
        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();
                }
            }
        }
Пример #5
0
        public static async Task <LogicArrayList <AllianceHeaderEntry> > GetAllianceHeaderList(LogicArrayList <LogicLong> ids)
        {
            LogicArrayList <AllianceHeaderEntry> allianceList = new LogicArrayList <AllianceHeaderEntry>(ids.Size());

            Task <IOperationResult <string> >[] results = new Task <IOperationResult <string> > [ids.Size()];

            for (int i = 0; i < ids.Size(); i++)
            {
                results[i] = ServerSearch.AllianceDatabase.Get(ids[i]);
            }

            for (int i = 0; i < ids.Size(); i++)
            {
                IOperationResult <string> result = await results[i];

                if (result.Success)
                {
                    LogicJSONObject     jsonObject          = LogicJSONParser.ParseObject(result.Value);
                    AllianceHeaderEntry allianceHeaderEntry = new AllianceHeaderEntry();

                    allianceHeaderEntry.Load(jsonObject);
                    allianceHeaderEntry.SetAllianceId(new LogicLong(jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_HIGH).GetIntValue(),
                                                                    jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_LOW).GetIntValue()));
                    allianceList.Add(allianceHeaderEntry);
                }
            }

            return(allianceList);
        }
        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());
            }

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

            if (donationArray != null)
            {
                for (int i = 0; i < donationArray.Size(); i++)
                {
                    LogicJSONArray array = donationArray.GetJSONArray(i);

                    if (array != null && array.Size() == 2)
                    {
                        LogicData data = LogicDataTables.GetDataById(array.GetJSONNumber(0).GetIntValue());

                        if (data != null)
                        {
                            this.m_donationData.Add((LogicCombatItemData)data);
                            this.m_donationLevel.Add(array.GetJSONNumber(1).GetIntValue());
                        }
                    }
                }
            }
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

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

            base.Load(baseObject);

            this.m_battleLogJSON  = jsonObject.GetJSONString("battleLog").GetStringValue();
            this.m_message        = jsonObject.GetJSONString("message").GetStringValue();
            this.m_opponentName   = jsonObject.GetJSONString("opponent_name").GetStringValue();
            this.m_attack         = jsonObject.GetJSONBoolean("attack").IsTrue();
            this.m_majorVersion   = jsonObject.GetJSONNumber("replay_major_v").GetIntValue();
            this.m_buildVersion   = jsonObject.GetJSONNumber("replay_build_v").GetIntValue();
            this.m_contentVersion = jsonObject.GetJSONNumber("replay_content_v").GetIntValue();

            LogicJSONNumber replayShardId = jsonObject.GetJSONNumber("replay_shard_id");

            if (replayShardId != null)
            {
                this.m_replayShardId = replayShardId.GetIntValue();
                this.m_replayId      = new LogicLong(jsonObject.GetJSONNumber("replay_id_hi").GetIntValue(), jsonObject.GetJSONNumber("replay_id_lo").GetIntValue());
            }
        }
        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");
        }
Пример #9
0
        /// <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 override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

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

            base.Load(baseObject);

            this.m_diamondReward = jsonObject.GetJSONNumber("diamond_reward").GetIntValue();
            this.m_giftCount     = jsonObject.GetJSONNumber("gift_count").GetIntValue();

            LogicJSONArray collectedPlayersArray = jsonObject.GetJSONArray("collected_players");

            for (int i = 0; i < collectedPlayersArray.Size(); i++)
            {
                LogicJSONArray idArray = collectedPlayersArray.GetJSONArray(i);
                LogicLong      id      = new LogicLong(idArray.GetJSONNumber(0).GetIntValue(), idArray.GetJSONNumber(1).GetIntValue());

                if (this.m_collectedPlayers.IndexOf(id) == -1)
                {
                    this.m_collectedPlayers.Add(id);
                }
            }
        }
        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());
            }
        }
Пример #12
0
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("Replay LogicPlaceAttackerCommand load failed! Base missing!");
            }

            base.LoadFromJSON(baseObject);

            LogicJSONNumber dataNumber = jsonRoot.GetJSONNumber("d");

            if (dataNumber != null)
            {
                this.m_data = (LogicCharacterData)LogicDataTables.GetDataById(dataNumber.GetIntValue(), LogicDataType.CHARACTER);
            }

            if (this.m_data == null)
            {
                Debugger.Error("Replay LogicPlaceAttackerCommand load failed! Character is NULL!");
            }

            this.m_x = jsonRoot.GetJSONNumber("x").GetIntValue();
            this.m_y = jsonRoot.GetJSONNumber("y").GetIntValue();
        }
Пример #13
0
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("Replay LogicPlaceAlliancePortalCommand load failed! Base missing!");
            }

            base.LoadFromJSON(baseObject);

            LogicJSONNumber dataNumber = jsonRoot.GetJSONNumber("d");

            if (dataNumber != null)
            {
                this.m_data = (LogicAlliancePortalData)LogicDataTables.GetDataById(dataNumber.GetIntValue(), LogicDataType.ALLIANCE_PORTAL);
            }

            if (this.m_data == null)
            {
                Debugger.Error("Replay LogicPlaceAlliancePortalCommand load failed! Data is NULL!");
            }

            this.m_x = jsonRoot.GetJSONNumber("x").GetIntValue();
            this.m_y = jsonRoot.GetJSONNumber("y").GetIntValue();
        }
Пример #14
0
        /// <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;
            }
        }
Пример #15
0
        /// <summary>
        ///     Loads this instance from json.
        /// </summary>
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject != null)
            {
                base.LoadFromJSON(baseObject);
            }
            else
            {
                Debugger.Error("Replay LogicDebugCommand load failed! Base missing!");
            }

            LogicJSONNumber debugActionObject = jsonRoot.GetJSONNumber("dA");

            if (debugActionObject != null)
            {
                this._debugAction = debugActionObject.GetIntValue();
            }

            LogicJSONNumber intArg1Object = jsonRoot.GetJSONNumber("gi");

            if (intArg1Object != null)
            {
                this._intArg1 = intArg1Object.GetIntValue();
            }

            LogicJSONNumber intArg2Object = jsonRoot.GetJSONNumber("int");

            if (intArg2Object != null)
            {
                this._intArg2 = intArg2Object.GetIntValue();
            }
        }
Пример #16
0
        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");
        }
Пример #17
0
        public void Load(LogicJSONObject jsonObject)
        {
            this.m_compressibleHomeJson.Load(jsonObject.GetJSONObject("homeJSON"));

            this.m_shieldDurationSeconds = jsonObject.GetJSONNumber("shield_t").GetIntValue();
            this.m_guardDurationSeconds  = jsonObject.GetJSONNumber("guard_t").GetIntValue();
            this.m_personalBreakSeconds  = jsonObject.GetJSONNumber("personal_break_t").GetIntValue();
        }
Пример #18
0
        public override void Load(LogicJSONObject jsonObject)
        {
            this.LoadUpgradeLevel(jsonObject);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            LogicJSONNumber constTimeObject = jsonObject.GetJSONNumber("const_t");

            if (constTimeObject != null)
            {
                int constTime = constTimeObject.GetIntValue();

                if (!LogicDataTables.GetGlobals().ClampBuildingTimes())
                {
                    if (this.m_upgLevel < this.GetVillageObjectData().GetUpgradeLevelCount() - 1)
                    {
                        constTime = LogicMath.Min(constTime, this.GetVillageObjectData().GetBuildTime(this.m_upgLevel + 1));
                    }
                }

                this.m_constructionTimer = new LogicTimer();
                this.m_constructionTimer.StartTimer(constTime, this.m_level.GetLogicTime(), false, -1);

                LogicJSONNumber constTimeEndObject = jsonObject.GetJSONNumber("const_t_end");

                if (constTimeEndObject != null)
                {
                    this.m_constructionTimer.SetEndTimestamp(constTimeEndObject.GetIntValue());
                }

                LogicJSONNumber conffObject = jsonObject.GetJSONNumber("con_ff");

                if (conffObject != null)
                {
                    this.m_constructionTimer.SetFastForward(conffObject.GetIntValue());
                }

                LogicVillageObjectData villageObjectData = this.GetVillageObjectData();

                if (villageObjectData.IsRequiresBuilder() && !villageObjectData.IsAutomaticUpgrades())
                {
                    this.m_level.GetWorkerManagerAt(this.m_villageType).AllocateWorker(this);
                }

                this.m_upgrading = this.m_upgLevel != -1;
            }

            this.m_upgLevel = LogicMath.Clamp(this.m_upgLevel, 0, this.GetVillageObjectData().GetUpgradeLevelCount() - 1);

            base.Load(jsonObject);

            this.SetPositionXY((this.GetVillageObjectData().GetTileX100() << 9) / 100,
                               (this.GetVillageObjectData().GetTileY100() << 9) / 100);
        }
Пример #19
0
        public virtual void Load(LogicJSONObject jsonObject)
        {
            LogicJSONArray idArray = jsonObject.GetJSONArray(RankingEntry.JSON_ATTRIBUTE_ID);

            this.m_id            = new LogicLong(idArray.GetJSONNumber(0).GetIntValue(), idArray.GetJSONNumber(1).GetIntValue());
            this.m_name          = jsonObject.GetJSONString(RankingEntry.JSON_ATTRIBUTE_NAME).GetStringValue();
            this.m_order         = jsonObject.GetJSONNumber(RankingEntry.JSON_ATTRIBUTE_ORDER).GetIntValue();
            this.m_previousOrder = jsonObject.GetJSONNumber(RankingEntry.JSON_ATTRIBUTE_PREVIOUS_ORDER).GetIntValue();
            this.m_score         = jsonObject.GetJSONNumber(RankingEntry.JSON_ATTRIBUTE_SCORE).GetIntValue();
        }
        public static void LoadDebugJSONArray(LogicLevel level, LogicJSONArray jsonArray, LogicGameObjectType gameObjectType, int villageType)
        {
            if (jsonArray != null)
            {
                LogicGameObjectManager           gameObjectManager = level.GetGameObjectManagerAt(villageType);
                LogicArrayList <LogicGameObject> prevGameObjects   = new LogicArrayList <LogicGameObject>();

                prevGameObjects.AddAll(gameObjectManager.GetGameObjects(gameObjectType));

                for (int i = 0; i < prevGameObjects.Size(); i++)
                {
                    gameObjectManager.RemoveGameObject(prevGameObjects[i]);
                }

                for (int i = 0; i < jsonArray.Size(); i++)
                {
                    LogicJSONObject  jsonObject    = jsonArray.GetJSONObject(i);
                    LogicJSONNumber  dataNumber    = jsonObject.GetJSONNumber("data");
                    LogicJSONNumber  lvlNumber     = jsonObject.GetJSONNumber("lvl");
                    LogicJSONBoolean lockedBoolean = jsonObject.GetJSONBoolean("locked");
                    LogicJSONNumber  xNumber       = jsonObject.GetJSONNumber("x");
                    LogicJSONNumber  yNumber       = jsonObject.GetJSONNumber("y");

                    if (dataNumber != null && xNumber != null && yNumber != null)
                    {
                        LogicGameObjectData data = (LogicGameObjectData)LogicDataTables.GetDataById(dataNumber.GetIntValue());

                        if (data != null)
                        {
                            LogicGameObject gameObject = LogicGameObjectFactory.CreateGameObject(data, level, villageType);

                            if (gameObjectType == LogicGameObjectType.BUILDING)
                            {
                                ((LogicBuilding)gameObject).StartConstructing(true);
                            }

                            if (lockedBoolean != null && lockedBoolean.IsTrue())
                            {
                                ((LogicBuilding)gameObject).Lock();
                            }

                            gameObject.Load(jsonObject);
                            gameObjectManager.AddGameObject(gameObject, -1);

                            if (lvlNumber != null)
                            {
                                LogicDebugUtil.SetBuildingUpgradeLevel(level, gameObject.GetGlobalID(), lvlNumber.GetIntValue(), villageType);
                            }
                        }
                    }
                }
            }
        }
        public static T Load <T>(string json) where T : CouchbaseDocument, new()
        {
            LogicJSONObject jsonObject = LogicJSONParser.ParseObject(json);

            T document = new T();

            document.Id = LogicLong.ToLong(jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_HIGH).GetIntValue(),
                                           jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_LOW).GetIntValue());
            document.Load(jsonObject);

            return(document);
        }
        public void LoadPosition(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);
        }
Пример #23
0
        public virtual void Load(LogicJSONObject jsonObject)
        {
            LogicJSONNumber allianceIdHighNumber = jsonObject.GetJSONNumber("alliance_id_hi");

            if (allianceIdHighNumber != null)
            {
                this.m_allianceId       = new LogicLong(allianceIdHighNumber.GetIntValue(), jsonObject.GetJSONNumber("alliance_id_lo").GetIntValue());
                this.m_allianceName     = jsonObject.GetJSONString("alliance_name").GetStringValue();
                this.m_allianceBadgeId  = jsonObject.GetJSONNumber("alliance_badge").GetIntValue();
                this.m_allianceExpLevel = jsonObject.GetJSONNumber("alliance_xp_lvl").GetIntValue();
            }

            this.m_accountId = new LogicLong(jsonObject.GetJSONNumber("acc_id_hi").GetIntValue(), jsonObject.GetJSONNumber("acc_id_lo").GetIntValue());
            this.m_avatarId  = new LogicLong(jsonObject.GetJSONNumber("avatar_id_hi").GetIntValue(), jsonObject.GetJSONNumber("avatar_id_lo").GetIntValue());

            LogicJSONNumber homeIdHighNumber = jsonObject.GetJSONNumber("home_id_hi");

            if (homeIdHighNumber != null)
            {
                this.m_homeId = new LogicLong(homeIdHighNumber.GetIntValue(), jsonObject.GetJSONNumber("home_id_lo").GetIntValue());
            }

            this.m_name             = jsonObject.GetJSONString("name").GetStringValue();
            this.m_remainingSeconds = jsonObject.GetJSONNumber("remainingSecs").GetIntValue();
        }
Пример #24
0
        public override void Load(LogicJSONObject root)
        {
            if (this.m_timer != null)
            {
                this.m_timer.Destruct();
                this.m_timer = null;
            }

            this.m_unit = null;

            LogicJSONObject jsonObject = root.GetJSONObject("unit_upg");

            if (jsonObject != null)
            {
                LogicJSONNumber unitTypeObject         = jsonObject.GetJSONNumber("unit_type");
                LogicJSONNumber idObject               = jsonObject.GetJSONNumber("id");
                LogicJSONNumber timerObject            = jsonObject.GetJSONNumber("t");
                LogicJSONNumber timerEndObject         = jsonObject.GetJSONNumber("t_end");
                LogicJSONNumber timerFastForwardObject = jsonObject.GetJSONNumber("t_ff");

                this.m_unitType = unitTypeObject != null?unitTypeObject.GetIntValue() : 0;

                if (idObject != null)
                {
                    if (timerObject != null)
                    {
                        LogicData data = LogicDataTables.GetDataById(idObject.GetIntValue(), this.m_unitType == 0 ? LogicDataType.CHARACTER : LogicDataType.SPELL);

                        if (data != null)
                        {
                            this.m_unit = (LogicCombatItemData)data;

                            this.m_timer = new LogicTimer();
                            this.m_timer.StartTimer(timerObject.GetIntValue(), this.m_parent.GetLevel().GetLogicTime(), false, -1);

                            if (timerEndObject != null)
                            {
                                this.m_timer.SetEndTimestamp(timerEndObject.GetIntValue());
                            }

                            if (timerFastForwardObject != null)
                            {
                                this.m_timer.SetFastForward(timerFastForwardObject.GetIntValue());
                            }
                        }
                    }
                }
            }
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            base.Load(jsonObject);

            this.m_badgeId     = jsonObject.GetJSONNumber(AllianceRankingEntry.JSON_ATTRIBUTE_BADGE_ID).GetIntValue();
            this.m_expLevel    = jsonObject.GetJSONNumber(AllianceRankingEntry.JSON_ATTRIBUTE_EXP_LEVEL).GetIntValue();
            this.m_memberCount = jsonObject.GetJSONNumber(AllianceRankingEntry.JSON_ATTRIBUTE_MEMBER_COUNT).GetIntValue();

            LogicJSONNumber originNumber = jsonObject.GetJSONNumber(AllianceRankingEntry.JSON_ATTRIBUTE_ORIGIN);

            if (originNumber != null)
            {
                this.m_originData = LogicDataTables.GetDataById(originNumber.GetIntValue());
            }
        }
Пример #26
0
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("Replay LogicTriggerComponentTriggeredCommand load failed! Base missing!");
            }

            base.LoadFromJSON(baseObject);

            this.m_id   = jsonRoot.GetJSONNumber("id").GetIntValue();
            this.m_data = (LogicGameObjectData)LogicDataTables.GetDataById(jsonRoot.GetJSONNumber("dataid").GetIntValue());
            this.m_json = jsonRoot.GetJSONObject("objs");
        }
        protected override void Load(LogicJSONObject jsonObject)
        {
            this.LogicClientAvatar.Load(jsonObject);
            this.LogicClientHome.Load(jsonObject.GetJSONObject(GameDocument.JSON_ATTRIBUTE_HOME));

            this.SaveTime        = jsonObject.GetJSONNumber(GameDocument.JSON_ATTRIBUTE_SAVE_TIME).GetIntValue();
            this.MaintenanceTime = jsonObject.GetJSONNumber(GameDocument.JSON_ATTRIBUTE_MAINTENANCE_TIME).GetIntValue();

            LogicJSONArray recentlyMatchedEnemyArray = jsonObject.GetJSONArray(GameDocument.JSON_ATTRIBUTE_RECENTLY_MATCHED_ENEMIES);

            if (recentlyMatchedEnemyArray != null)
            {
                for (int i = 0; i < recentlyMatchedEnemyArray.Size(); i++)
                {
                    LogicJSONArray value = recentlyMatchedEnemyArray.GetJSONArray(i);

                    this.RecentlyMatchedEnemies.Add(new RecentlyEnemy(new LogicLong(value.GetJSONNumber(0).GetIntValue(), value.GetJSONNumber(1).GetIntValue()), value.GetJSONNumber(2).GetIntValue()));
                }
            }

            LogicJSONArray allianceBookmarksArray = jsonObject.GetJSONArray(GameDocument.JSON_ATTRIBUTE_ALLIANCE_BOOKMARKS_LIST);

            if (allianceBookmarksArray != null)
            {
                this.AllianceBookmarksList.EnsureCapacity(allianceBookmarksArray.Size());

                for (int i = 0; i < allianceBookmarksArray.Size(); i++)
                {
                    LogicJSONArray value = allianceBookmarksArray.GetJSONArray(i);
                    this.AllianceBookmarksList.Add(new LogicLong(value.GetJSONNumber(0).GetIntValue(), value.GetJSONNumber(1).GetIntValue()));
                }
            }

            LogicJSONArray avatarStreamArray = jsonObject.GetJSONArray(GameDocument.JSON_ATTRIBUTE_AVATAR_STREAM_LIST);

            if (avatarStreamArray != null)
            {
                this.AvatarStreamList.EnsureCapacity(avatarStreamArray.Size());

                for (int i = 0; i < avatarStreamArray.Size(); i++)
                {
                    LogicJSONArray value = avatarStreamArray.GetJSONArray(i);
                    this.AvatarStreamList.Add(new LogicLong(value.GetJSONNumber(0).GetIntValue(), value.GetJSONNumber(1).GetIntValue()));
                }
            }

            this.SetLogicId(this.Id);
        }
        public void LoadUpgradeLevel(LogicJSONObject jsonObject)
        {
            LogicJSONNumber lvlObject = jsonObject.GetJSONNumber("lvl");
            LogicTrapData   data      = this.GetTrapData();

            if (lvlObject != null)
            {
                this.m_upgLevel = lvlObject.GetIntValue();
                int maxLvl = data.GetUpgradeLevelCount();

                if (this.m_upgLevel >= maxLvl)
                {
                    Debugger.Warning(string.Format("LogicTrap::load() - Loaded upgrade level {0} is over max! (max = {1}) id {2} data id {3}",
                                                   lvlObject.GetIntValue(),
                                                   maxLvl,
                                                   this.m_globalId,
                                                   data.GetGlobalID()));
                    this.m_upgLevel = maxLvl - 1;
                }
                else
                {
                    if (this.m_upgLevel < -1)
                    {
                        Debugger.Error("LogicTrap::load() - Loaded an illegal upgrade level!");
                    }
                }
            }
        }
        private void LoadAccount(LogicLong id)
        {
            if (id != null)
            {
                string path = string.Format("accounts/{0}-{1}", id.GetHigherInt(), id.GetLowerInt());

                if (File.Exists(path))
                {
                    LogicJSONObject jsonObject = LogicJSONParser.ParseObject(File.ReadAllText(path));

                    this.m_accountInfo = new AccountInfo
                    {
                        AccountId = new LogicLong(jsonObject.GetJSONNumber("id_high").GetIntValue(), jsonObject.GetJSONNumber("id_low").GetIntValue()),
                        PassToken = jsonObject.GetJSONString("passToken").GetStringValue()
                    };
                }
                else
                {
                    Debugger.Warning("ServerConnection.loadAccount: account doesn't exists!");
                }
            }
            else
            {
                this.m_accountInfo = new AccountInfo();
            }
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONBoolean initialSpawnDoneBoolean = jsonObject.GetJSONBoolean("initial_spawn_done");

            if (initialSpawnDoneBoolean != null)
            {
                this.m_initialSpawnDone = initialSpawnDoneBoolean.IsTrue();
            }

            if (this.m_timer != null)
            {
                this.m_timer.Destruct();
                this.m_timer = null;
            }

            this.m_timer = LogicTimer.GetLogicTimer(jsonObject, this.m_parent.GetLevel().GetLogicTime(), "spawn_timer", this.m_intervalSeconds);

            LogicJSONNumber lifetimeSpawnsNumber = jsonObject.GetJSONNumber("lifetime_spawns");

            if (lifetimeSpawnsNumber != null)
            {
                this.m_lifeTimeSpawns = lifetimeSpawnsNumber.GetIntValue();
            }

            LogicJSONArray spawnedArray = jsonObject.GetJSONArray("spawned");

            if (spawnedArray != null)
            {
                for (int i = 0; i < spawnedArray.Size(); i++)
                {
                    this.m_spawned.Add(spawnedArray.GetJSONNumber(i).GetIntValue());
                }
            }
        }