public void SetAllianceSettings(string description, AllianceType type, int badgeId, int requiredScore, int requiredDuelScore, int warFrequency, LogicData originData, bool publicWarLog, bool arrangedWarEnabled)
        {
            int allianceLevel = this.Header.GetAllianceLevel();

            if (description == null)
            {
                description = string.Empty;
            }
            if (description.Length > 128)
            {
                description = description.Substring(0, 128);
            }

            type = (AllianceType)LogicMath.Clamp((int)type, (int)AllianceType.OPEN, (int)AllianceType.CLOSED);

            AllianceBadgeUtil.ParseAllianceBadgeLayer(badgeId, out LogicAllianceBadgeLayerData middle, out LogicAllianceBadgeLayerData background, out LogicAllianceBadgeLayerData foreground);

            if (middle != null && middle.GetRequiredClanLevel() > allianceLevel)
            {
                middle = AllianceBadgeUtil.GetFirstUnlockedAllianceBadgeLayerByType(LogicAllianceBadgeLayerType.MIDDLE, allianceLevel);
            }
            if (background != null && background.GetRequiredClanLevel() > allianceLevel)
            {
                background = AllianceBadgeUtil.GetFirstUnlockedAllianceBadgeLayerByType(LogicAllianceBadgeLayerType.BACKGROUND, allianceLevel);
            }
            if (foreground != null && foreground.GetRequiredClanLevel() > allianceLevel)
            {
                foreground = AllianceBadgeUtil.GetFirstUnlockedAllianceBadgeLayerByType(LogicAllianceBadgeLayerType.FOREGROUND, allianceLevel);
            }

            badgeId = AllianceBadgeUtil.GetAllianceBadgeId(middle, background, foreground);

            if (originData != null && originData.GetDataType() != LogicDataType.REGION)
            {
                originData = null;
            }

            this.Description = description;
            this.Header.SetAllianceType(type);
            this.Header.SetAllianceBadgeId(badgeId);
            this.Header.SetRequiredScore(requiredScore);
            this.Header.SetRequiredDuelScore(requiredDuelScore);
            this.Header.SetWarFrequency(warFrequency);
            this.Header.SetOriginData(originData);
            this.Header.SetPublicWarLog(publicWarLog);
            this.Header.SetArrangedWarEnabled(arrangedWarEnabled);

            if (this.Members.Count != 0)
            {
                LogicAllianceSettingsChangedCommand allianceSettingsChangedCommand = new LogicAllianceSettingsChangedCommand();

                allianceSettingsChangedCommand.SetAllianceData(this.Id, badgeId);

                this.AllowServerCommand(allianceSettingsChangedCommand);
                this.SendPiranhaMessage(this.GetAllianceFulEntryUpdateMessage(), 1);
            }
        }
        /// <summary>
        ///     Creates a gameobject with specified data.
        /// </summary>
        public static LogicGameObject CreateGameObject(LogicData data, LogicLevel level, int villageType)
        {
            LogicGameObject gameObject = null;

            switch (data.GetDataType())
            {
            case 0:
                gameObject = new LogicBuilding(data, level, villageType);
                break;

            case 3:
                gameObject = new LogicCharacter(data, level, villageType);
                break;

            case 7:
                gameObject = new LogicObstacle(data, level, villageType);
                break;

            case 11:
                gameObject = new LogicTrap(data, level, villageType);
                break;

            case 25:
                gameObject = new LogicSpell(data, level, villageType);
                break;

            case 38:
                gameObject = new LogicVillageObject(data, level, villageType);
                break;

            default:
            {
                Debugger.Warning("Trying to create game object with data that does not inherit LogicGameObjectData. GlobalId=" + data.GetGlobalID());
                break;
            }
            }

            return(gameObject);
        }