/// <summary>
 /// Initializes a new instance of the <see cref="SystemCreatorEditorSettings" /> class for SystemCreators that have preset values.
 /// </summary>
 /// <param name="presetStarCat">The preset star cat.</param>
 /// <param name="presetPlanetCats">The preset planet cats.</param>
 /// <param name="presetMoonCats">The preset moon cats.</param>
 /// <param name="desirability">The desirability.</param>
 public SystemCreatorEditorSettings(StarCategory presetStarCat, IList<PlanetoidCategory> presetPlanetCats,
     IList<PlanetoidCategory[]> presetMoonCats, SystemDesirability desirability) {
     PresetStarCategory = presetStarCat;
     IsCompositionPreset = true;
     if (presetPlanetCats.Count > TempGameValues.TotalOrbitSlotsPerSystem - 1) {
         D.Error("{0} should be <= {1}.", presetPlanetCats.Count, TempGameValues.TotalOrbitSlotsPerSystem - 1);
     }
     PresetPlanetCategories = presetPlanetCats;
     PresetMoonCategories = presetMoonCats;
     Desirability = desirability;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemCreatorEditorSettings" /> class for SystemCreators that do not have preset values.
 /// </summary>
 /// <param name="nonPresetPlanetQty">The non preset planet qty.</param>
 /// <param name="desirability">The desirability.</param>
 public SystemCreatorEditorSettings(int nonPresetPlanetQty, SystemDesirability desirability) {
     IsCompositionPreset = false;
     NonPresetPlanetQty = nonPresetPlanetQty;
     Desirability = desirability;
 }
 private PlanetStat MakeRandomPlanetStat(PlanetoidCategory pCategory, SystemDesirability desirability) {
     float radius = pCategory.Radius();
     float closeOrbitInnerRadius = radius + TempGameValues.PlanetCloseOrbitInnerRadiusAdder;
     float maxHitPts = 100F; // TODO vary by desirability
     int capacity = 25;  // TODO vary by desirability
     var resourceYield = CreateRandomResourceYield(desirability, ResourceCategory.Common, ResourceCategory.Strategic);
     return new PlanetStat(radius, 1000000F, maxHitPts, pCategory, capacity, resourceYield, closeOrbitInnerRadius);
 }
 private PlanetoidStat MakeRandomMoonStat(PlanetoidCategory mCategory, SystemDesirability desirability) {
     float radius = mCategory.Radius();
     float maxHitPts = 10F;  // TODO vary by desirability
     int capacity = 5;   // TODO vary by desirability
     var resourceYield = CreateRandomResourceYield(desirability, ResourceCategory.Common);
     return new PlanetoidStat(radius, 10000F, maxHitPts, mCategory, capacity, resourceYield);
 }
 private ResourceYield CreateRandomResourceYield(SystemDesirability desirability, params ResourceCategory[] resCategories) {
     ResourceYield sum = default(ResourceYield);
     resCategories.ForAll(resCat => sum += CreateRandomResourceYield(resCat, desirability));
     return sum;
 }
    private ResourceYield CreateRandomResourceYield(ResourceCategory resCategory, SystemDesirability desirability) {
        float minYield;
        float maxYield;
        int minNumberOfResources;
        switch (resCategory) {
            case ResourceCategory.Common:
                switch (desirability) {
                    case SystemDesirability.Desirable:
                        minNumberOfResources = 2;
                        minYield = 1F;
                        maxYield = 5F;
                        break;
                    case SystemDesirability.Normal:
                        minNumberOfResources = 1;
                        minYield = 1F;
                        maxYield = 4F;
                        break;
                    case SystemDesirability.Challenged:
                        minNumberOfResources = 1;
                        minYield = 0F;
                        maxYield = 3F;
                        break;
                    case SystemDesirability.None:
                    default:
                        throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
                }
                break;
            case ResourceCategory.Strategic:
                switch (desirability) {
                    case SystemDesirability.Desirable:
                        minNumberOfResources = 1;
                        minYield = 1F;
                        maxYield = 3F;
                        break;
                    case SystemDesirability.Normal:
                        minNumberOfResources = 0;
                        minYield = 1F;
                        maxYield = 2F;
                        break;
                    case SystemDesirability.Challenged:
                        minNumberOfResources = 0;
                        minYield = 0F;
                        maxYield = 2F;
                        break;
                    case SystemDesirability.None:
                    default:
                        throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
                }
                break;
            case ResourceCategory.Luxury:   // No Luxury Resources yet
            case ResourceCategory.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(resCategory));
        }

        var categoryResources = Enums<ResourceID>.GetValues(excludeDefault: true).Where(res => res.GetResourceCategory() == resCategory);
        int categoryResourceCount = categoryResources.Count();
        D.Assert(categoryResourceCount > minNumberOfResources);
        int numberOfResourcesToCreate = RandomExtended.Range(minNumberOfResources, categoryResourceCount);

        IList<ResourceYield.ResourceValuePair> resValuePairs = new List<ResourceYield.ResourceValuePair>(numberOfResourcesToCreate);
        var resourcesChosen = categoryResources.Shuffle().Take(numberOfResourcesToCreate);
        resourcesChosen.ForAll(resID => {
            var rvp = new ResourceYield.ResourceValuePair(resID, UnityEngine.Random.Range(minYield, maxYield));
            resValuePairs.Add(rvp);
        });
        return new ResourceYield(resValuePairs.ToArray());
    }
 private int GetPassiveCountermeasureQty(SystemDesirability desirability, int max) {
     Utility.ValidateForRange(max, 1, 3);    // 10.8.16 HACK if this fails, the values are lower/higher than I currently intend
     switch (desirability) {
         case SystemDesirability.Desirable:
             return RandomExtended.Range(1, max);
         case SystemDesirability.Normal:
             return RandomExtended.Range(0, max);
         case SystemDesirability.Challenged:
             return RandomExtended.Range(0, max - 1);
         case SystemDesirability.None:
         default:
             throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
     }
 }
 private StarStat MakeRandomStarStat(StarCategory category, SystemDesirability desirability, out float systemOrbitSlotsStartRadius) {
     float radius = TempGameValues.StarRadius;
     float closeOrbitInnerRadius = radius + 2F;
     systemOrbitSlotsStartRadius = closeOrbitInnerRadius + TempGameValues.ShipCloseOrbitSlotDepth;
     int capacity = 100; // TODO vary by desirability
     return new StarStat(category, radius, closeOrbitInnerRadius, capacity, CreateRandomResourceYield(desirability, ResourceCategory.Common, ResourceCategory.Strategic));
 }
 private string MakeAndRecordStarDesign(StarCategory cat, SystemDesirability desirability, out float systemOrbitSlotsStartRadius) {
     string designName = GetUniqueDesignName(cat.GetValueName());
     StarStat stat = MakeRandomStarStat(cat, desirability, out systemOrbitSlotsStartRadius);
     StarDesign design = new StarDesign(designName, stat);
     _gameMgr.CelestialDesigns.Add(design);
     return designName;
 }
 private string MakeAndRecordMoonDesign(PlanetoidCategory cat, SystemDesirability desirability) {
     string designName = GetUniqueDesignName(cat.GetValueName());
     PlanetoidStat stat = MakeRandomMoonStat(cat, desirability);
     int passiveCmQty = GetPassiveCountermeasureQty(desirability, max: 1);
     var passiveCMs = _availablePassiveCountermeasureStats.Shuffle().Take(passiveCmQty);
     MoonDesign design = new MoonDesign(designName, stat, passiveCMs);
     _gameMgr.CelestialDesigns.Add(design);
     return designName;
 }
    private IList<string[]> MakeMoonDesignsAndOrbitSlots(IList<PlanetoidCategory> pCatsByPlanetIndex, IList<PlanetoidCategory[]> mCatsByPlanetIndex, SystemDesirability desirability, out IList<OrbitData[]> assignedOrbitSlotsByPlanetIndex) {
        int planetIndexQty = pCatsByPlanetIndex.Count;

        assignedOrbitSlotsByPlanetIndex = new List<OrbitData[]>(planetIndexQty);
        IList<string[]> moonDesignNamesByPlanetIndex = new List<string[]>(planetIndexQty);

        for (int pIndex = 0; pIndex < planetIndexQty; pIndex++) {
            PlanetoidCategory[] moonCats = mCatsByPlanetIndex[pIndex];
            IList<string> moonDesignNames = new List<string>(moonCats.Length);
            IList<OrbitData> moonOrbitSlots = new List<OrbitData>(moonCats.Length);
            if (moonCats.Any()) {

                PlanetoidCategory pCat = pCatsByPlanetIndex[pIndex];
                D.AssertNotDefault((int)pCat);   // there are moons so this shouldn't be None
                float planetCloseOrbitInnerRadius = pCat.Radius() + TempGameValues.PlanetCloseOrbitInnerRadiusAdder;
                float moonOrbitSlotStartDepth = planetCloseOrbitInnerRadius;

                for (int mSlotIndex = 0; mSlotIndex < moonCats.Length; mSlotIndex++) {
                    PlanetoidCategory mCat = moonCats[mSlotIndex];
                    OrbitData assignedMoonOrbitSlot;
                    if (TryAssignMoonOrbitSlot(mCat, mSlotIndex, moonOrbitSlotStartDepth, out assignedMoonOrbitSlot)) {
                        moonOrbitSlots.Add(assignedMoonOrbitSlot);  //moonOrbitSlots[mSlotIndex] = assignedMoonOrbitSlot;
                        //D.Log(ShowDebugLog, "{0} fit moonCat {1} in orbit slot {2} around planetCat {3}.",
                        //    DebugName, mCat.GetValueName(), mSlotIndex, pCat.GetValueName());

                        string moonDesignName = MakeAndRecordMoonDesign(mCat, desirability);
                        moonDesignNames.Add(moonDesignName);    //moonDesignNames[mSlotIndex] = moonDesignName;

                        moonOrbitSlotStartDepth += assignedMoonOrbitSlot.OuterRadius;
                    }
                    else {
                        //D.Log(ShowDebugLog, "{0} could not fit moonCat {1} in orbit slot {2} around planetCat {3}.",
                        //    DebugName, mCat.GetValueName(), mSlotIndex, pCat.GetValueName());
                    }
                }
            }
            // else no moons for this planetIndex either because 1) none were desired, 
            // or 2) the planet was removed due to lack of an available orbit slot

            assignedOrbitSlotsByPlanetIndex.Add(moonOrbitSlots.ToArray());  //assignedOrbitSlotsByPlanetIndex[pIndex] = moonOrbitSlots.ToArray();
            moonDesignNamesByPlanetIndex.Add(moonDesignNames.ToArray());    //moonDesignNamesByPlanetIndex[pIndex] = moonDesignNames.ToArray();
        }
        return moonDesignNamesByPlanetIndex;
    }
    private IList<string> MakePlanetDesignsAndOrbitSlots(IList<PlanetoidCategory> pCats, SystemDesirability desirability, Stack<OrbitData> innerOrbitSlots, Stack<OrbitData> goldilocksOrbitSlots, Stack<OrbitData> outerOrbitSlots, out IList<OrbitData> assignedOrbitSlots, out IList<int> unassignedPlanetIndices) {
        IList<string> designNames = new List<string>(pCats.Count);
        assignedOrbitSlots = new List<OrbitData>(pCats.Count);
        unassignedPlanetIndices = new List<int>(pCats.Count);
        for (int pIndex = 0; pIndex < pCats.Count; pIndex++) {
            PlanetoidCategory pCat = pCats[pIndex];
            OrbitData assignedSlot;
            if (TryAssignPlanetOrbitSlot(pCat, innerOrbitSlots, goldilocksOrbitSlots, outerOrbitSlots, out assignedSlot)) {
                assignedOrbitSlots.Add(assignedSlot);   //assignedOrbitSlots[pIndex] = assignedSlot;
                //D.Log(ShowDebugLog, "{0} fit planetCat {1} in system orbit slot {2}.", DebugName, pCat.GetValueName(), pIndex);

                string designName = MakeAndRecordPlanetDesign(pCat, /*passiveCmQty*/desirability);
                designNames.Add(designName);    //designNames[pIndex] = designName;
            }
            else {
                unassignedPlanetIndices.Add(pIndex);
                D.Log(ShowDebugLog, "{0} could not fit planetCat {1} in system orbit slot {2}.", GetType().Name, pCat.GetValueName(), pIndex);
            }
        }
        return designNames;
    }
    private SystemCreator DeployAndConfigureCreatorTo(string systemName, Vector3 location, SystemDesirability systemDesirability, StarCategory starCat, IList<PlanetoidCategory> planetCatsByPlanetIndex) {
        float systemOrbitSlotsStartRadius;
        string starDesignName = MakeAndRecordStarDesign(starCat, systemDesirability, out systemOrbitSlotsStartRadius);

        Stack<OrbitData> innerOrbitSlots;
        Stack<OrbitData> goldilocksOrbitSlots;
        Stack<OrbitData> outerOrbitSlots;

        GenerateSystemOrbitSlots(systemOrbitSlotsStartRadius, out innerOrbitSlots, out goldilocksOrbitSlots, out outerOrbitSlots);
        OrbitData settlementOrbitSlot = goldilocksOrbitSlots.Pop();
        D.AssertNotNull(settlementOrbitSlot);

        IList<int> unassignedPlanetIndices;
        IList<OrbitData> planetOrbitSlots;
        IList<string> planetDesignNames = MakePlanetDesignsAndOrbitSlots(planetCatsByPlanetIndex, systemDesirability, innerOrbitSlots, goldilocksOrbitSlots, outerOrbitSlots, out planetOrbitSlots, out unassignedPlanetIndices);

        IList<PlanetoidCategory[]> moonCatsByPlanetIndex = GetRandomMoonCats(planetCatsByPlanetIndex);

        if (unassignedPlanetIndices.Count > Constants.Zero) {
            // one or more planets could not be assigned an orbit slot and design so eliminate any moons for that planet
            foreach (var pIndex in unassignedPlanetIndices) {
                moonCatsByPlanetIndex[pIndex] = Enumerable.Empty<PlanetoidCategory>().ToArray();
                planetCatsByPlanetIndex[pIndex] = default(PlanetoidCategory);
            }
        }

        IList<OrbitData[]> moonOrbitSlots;
        IList<string[]> moonDesignNames = MakeMoonDesignsAndOrbitSlots(planetCatsByPlanetIndex, moonCatsByPlanetIndex, systemDesirability, out moonOrbitSlots);

        SystemCreatorConfiguration config = new SystemCreatorConfiguration(systemName, starDesignName, settlementOrbitSlot, planetDesignNames,
            planetOrbitSlots, moonDesignNames, moonOrbitSlots);
        SystemCreator creator = _systemFactory.MakeCreatorInstance(location);
        creator.Configuration = config;
        return creator;
    }
    /// <summary>
    /// Gets the planet categories based on SystemDesirability.
    /// IMPROVE categories should vary by species.
    /// </summary>
    /// <param name="systemDesirability">The system desirability.</param>
    /// <param name="isHomeSystem">if set to <c>true</c> [is home system].</param>
    /// <returns></returns>
    /// <exception cref="System.NotImplementedException"></exception>
    private IList<PlanetoidCategory> GetPlanetCategories(SystemDesirability systemDesirability, bool isHomeSystem = false) {
        int minPlanetQty;
        IEnumerable<PlanetoidCategory> planetCatsToChooseFrom;

        switch (systemDesirability) {
            case SystemDesirability.Desirable:
                minPlanetQty = isHomeSystem ? 4 : 3;
                planetCatsToChooseFrom = _desirablePlanetCategories;
                break;
            case SystemDesirability.Normal:
                minPlanetQty = isHomeSystem ? 3 : 1;
                planetCatsToChooseFrom = _acceptablePlanetCategories;
                break;
            case SystemDesirability.Challenged:
                minPlanetQty = isHomeSystem ? 2 : 0;
                planetCatsToChooseFrom = _undesirablePlanetCategories;
                break;
            case SystemDesirability.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(systemDesirability));
        }
        int planetQty = RandomExtended.Range(minPlanetQty, TempGameValues.TotalOrbitSlotsPerSystem - 1);
        IList<PlanetoidCategory> planetCatsByPlanetIndex = RandomExtended.Choices<PlanetoidCategory>(planetCatsToChooseFrom, planetQty);
        return planetCatsByPlanetIndex;
    }
    protected override void RecordPopupListState(GuiElementID popupListID, string selection, string convertedSelection) {
        base.RecordPopupListState(popupListID, selection, convertedSelection);
        //D.Log("{0}.RecordPopupListState() called. ID = {1}, Selection = {2}.", GetType().Name, popupListID.GetValueName(), selectionName);
        switch (popupListID) {
            case GuiElementID.UniverseSizePopupList:
                _universeSizeSelection = Enums<UniverseSizeGuiSelection>.Parse(selection);
                _universeSize = Enums<UniverseSize>.Parse(convertedSelection);
                break;
            case GuiElementID.SystemDensityPopupList:
                _systemDensitySelection = Enums<SystemDensityGuiSelection>.Parse(selection);
                _systemDensity = Enums<SystemDensity>.Parse(convertedSelection);
                break;
            case GuiElementID.PlayerCountPopupList:
                _playerCount = int.Parse(selection);
                break;

            case GuiElementID.UserPlayerSpeciesPopupList:
                _userPlayerSpeciesSelection = Enums<SpeciesGuiSelection>.Parse(selection);
                _userPlayerSpecies = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer1SpeciesPopupList:
                _aiPlayersSpeciesSelections[0] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[0] = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer2SpeciesPopupList:
                _aiPlayersSpeciesSelections[1] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[1] = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer3SpeciesPopupList:
                _aiPlayersSpeciesSelections[2] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[2] = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer4SpeciesPopupList:
                _aiPlayersSpeciesSelections[3] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[3] = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer5SpeciesPopupList:
                _aiPlayersSpeciesSelections[4] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[4] = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer6SpeciesPopupList:
                _aiPlayersSpeciesSelections[5] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[5] = Enums<Species>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer7SpeciesPopupList:
                _aiPlayersSpeciesSelections[6] = Enums<SpeciesGuiSelection>.Parse(selection);
                _aiPlayersSpecies[6] = Enums<Species>.Parse(convertedSelection);
                break;

            case GuiElementID.UserPlayerColorPopupList:
                _userPlayerColor = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer1ColorPopupList:
                _aiPlayersColors[0] = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer2ColorPopupList:
                _aiPlayersColors[1] = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer3ColorPopupList:
                _aiPlayersColors[2] = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer4ColorPopupList:
                _aiPlayersColors[3] = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer5ColorPopupList:
                _aiPlayersColors[4] = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer6ColorPopupList:
                _aiPlayersColors[5] = Enums<GameColor>.Parse(selection);
                break;
            case GuiElementID.AIPlayer7ColorPopupList:
                _aiPlayersColors[6] = Enums<GameColor>.Parse(selection);
                break;

            case GuiElementID.AIPlayer1IQPopupList:
                _aiPlayersIQs[0] = Enums<IQ>.Parse(selection);
                break;
            case GuiElementID.AIPlayer2IQPopupList:
                _aiPlayersIQs[1] = Enums<IQ>.Parse(selection);
                break;
            case GuiElementID.AIPlayer3IQPopupList:
                _aiPlayersIQs[2] = Enums<IQ>.Parse(selection);
                break;
            case GuiElementID.AIPlayer4IQPopupList:
                _aiPlayersIQs[3] = Enums<IQ>.Parse(selection);
                break;
            case GuiElementID.AIPlayer5IQPopupList:
                _aiPlayersIQs[4] = Enums<IQ>.Parse(selection);
                break;
            case GuiElementID.AIPlayer6IQPopupList:
                _aiPlayersIQs[5] = Enums<IQ>.Parse(selection);
                break;
            case GuiElementID.AIPlayer7IQPopupList:
                _aiPlayersIQs[6] = Enums<IQ>.Parse(selection);
                break;

            case GuiElementID.UserPlayerTeamPopupList:
                _userPlayerTeam = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer1TeamPopupList:
                _aiPlayersTeams[0] = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer2TeamPopupList:
                _aiPlayersTeams[1] = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer3TeamPopupList:
                _aiPlayersTeams[2] = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer4TeamPopupList:
                _aiPlayersTeams[3] = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer5TeamPopupList:
                _aiPlayersTeams[4] = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer6TeamPopupList:
                _aiPlayersTeams[5] = Enums<TeamID>.Parse(selection);
                break;
            case GuiElementID.AIPlayer7TeamPopupList:
                _aiPlayersTeams[6] = Enums<TeamID>.Parse(selection);
                break;

            case GuiElementID.UserPlayerStartLevelPopupList:
                _userPlayerStartLevelSelection = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _userPlayerStartLevel = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer1StartLevelPopupList:
                _aiPlayersStartLevelSelections[0] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[0] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer2StartLevelPopupList:
                _aiPlayersStartLevelSelections[1] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[1] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer3StartLevelPopupList:
                _aiPlayersStartLevelSelections[2] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[2] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer4StartLevelPopupList:
                _aiPlayersStartLevelSelections[3] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[3] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer5StartLevelPopupList:
                _aiPlayersStartLevelSelections[4] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[4] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer6StartLevelPopupList:
                _aiPlayersStartLevelSelections[5] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[5] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer7StartLevelPopupList:
                _aiPlayersStartLevelSelections[6] = Enums<EmpireStartLevelGuiSelection>.Parse(selection);
                _aiPlayersStartLevels[6] = Enums<EmpireStartLevel>.Parse(convertedSelection);
                break;

            case GuiElementID.UserPlayerHomeDesirabilityPopupList:
                _userPlayerHomeSystemDesirabilitySelection = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _userPlayerHomeSystemDesirability = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer1HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[0] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[0] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer2HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[1] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[1] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer3HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[2] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[2] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer4HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[3] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[3] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer5HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[4] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[4] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer6HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[5] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[5] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer7HomeDesirabilityPopupList:
                _aiPlayersHomeSystemDesirabilitySelections[6] = Enums<SystemDesirabilityGuiSelection>.Parse(selection);
                _aiPlayersHomeSystemDesirability[6] = Enums<SystemDesirability>.Parse(convertedSelection);
                break;

            case GuiElementID.AIPlayer1UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[0] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[0] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer2UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[1] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[1] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer3UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[2] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[2] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer4UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[3] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[3] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer5UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[4] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[4] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer6UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[5] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[5] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;
            case GuiElementID.AIPlayer7UserSeparationPopupList:
                _aiPlayersUserSeparationSelections[6] = Enums<PlayerSeparationGuiSelection>.Parse(selection);
                _aiPlayersUserSeparations[6] = Enums<PlayerSeparation>.Parse(convertedSelection);
                break;

            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(popupListID));
        }
    }