public NewGameController(IEnumerable <TracableStream> staticDataSources) { foreach (var aiFactory in PlayerAssets.AIDefinitions.Values) { aiPlayers.Add(new PlayerType(PlayerControlType.LocalAI, aiFactory)); } //TODO(v0.8) move to controller user players.Add(new NewGamePlayerInfo("Marko Kovač", colors.Take(), null, localHuman)); players.Add(new NewGamePlayerInfo(generateAiName(), colors.Take(), null, aiPlayers.Pick())); this.Statics = StaticsDB.Load(staticDataSources); this.evaluator = new SystemEvaluator(this.Statics); foreach (var populator in MapAssets.StarPopulators) { populator.SetGameData( this.Statics.StarTraits, this.Statics.PlanetTraits, this.Statics.PlanetForumlas.ToDictionary(x => x.Key, x => x.Value.ImplicitTraits) ); } this.CustomStart = LastStartingCondition ?? DefaultStartingCondition; this.StarPositioner = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPositionerConfig, MapAssets.StarPositioners); this.StarConnector = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarConnectorConfig, MapAssets.StarConnectors); this.StarPopulator = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPopulatorConfig, MapAssets.StarPopulators); }
/// <summary> /// Add a uPicklist and/or PickItem to the database /// /// </summary> /// <param name="lvi"></param> private void AddPicklist(UltraListViewItem lvi) { // Recover the data fields string listName = lvi.Text; string itemName = lvi.SubItems[0].Text; // Does the Picklist exist? PickList pickList = _listPickLists.FindPickList(listName); if (pickList == null) { pickList = new PickList(); pickList.Name = listName; pickList.Add(); _listPickLists.Add(pickList); } // Does the pickitem already exist within the Picklist? PickItem pickItem = pickList.FindPickItem(itemName); if (pickItem == null) { pickItem = new PickItem(); pickItem.Name = itemName; pickItem.ParentID = pickList.PicklistID; pickItem.Add(); } }
public NewGameController(IEnumerable <NamedStream> staticDataSources) { foreach (var aiFactory in PlayerAssets.AIDefinitions.Values) { aiPlayers.Add(new PlayerType(PlayerControlType.LocalAI, aiFactory)); } //TODO(v0.9) move to controller user this.players.AddRange( Settings.Get.LastGame.PlayersConfig != null && Settings.Get.LastGame.PlayersConfig.Length > 1 ? loadPlayerSetup(Settings.Get.LastGame.PlayersConfig) : this.defaultPlayerSetup() ); this.Statics = StaticsDB.Load(staticDataSources); this.evaluator = new SystemEvaluator(this.Statics); foreach (var populator in MapAssets.StarPopulators) { populator.SetGameData( this.Statics.StarTraits, this.Statics.PlanetTraits, this.Statics.PlanetForumlas.ToDictionary(x => x.Key, x => x.Value.ImplicitTraits) ); } this.CustomStart = LastStartingCondition ?? DefaultStartingCondition; this.StarPositioner = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPositionerConfig, MapAssets.StarPositioners); this.StarConnector = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarConnectorConfig, MapAssets.StarConnectors); this.StarPopulator = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPopulatorConfig, MapAssets.StarPopulators); }
public StarNamer(int starCount) { //UNDONE(v0.5): Currently picks any subset of available names //TODO(v0.5): Make namer respect constellation designations (no beta without alpha) Language lang = LocalizationManifest.Get.DefaultLanguage; int properNamesCount = lang[ProperStarName.ContextName].KeySet().Count; for (int i = 0; i < properNamesCount; i++) { starNames.Add(new ProperStarName(i)); } int constellationCount = lang[ConstellationStarName.ConstellationsContext].KeySet().Count / 2; int designationCount = lang[ConstellationStarName.DesignationContext].KeySet().Count; for (int constell = 0; constell < constellationCount; constell++) { for (int desig = 0; desig < designationCount; desig++) { starNames.Add(new ConstellationStarName(constell, desig)); } } }
public StarNamer(int starCount, Random random) { var lang = LocalizationManifest.Get.DefaultLanguage; var constellationCount = lang[ConstellationStarName.ConstellationsContext].KeySet().Count / 2; var designationCount = LocalizationManifest.Get.DefaultLanguage[ConstellationStarName.DesignationContext].KeySet().Count; var usedDesignations = new Dictionary <int, int>(); var constellationMaxNames = new Dictionary <int, int>(); var constellationPool = new PickList <int>(random); for (int i = 0; i <= constellationCount; i++) { usedDesignations.Add(i, 0); constellationMaxNames.Add(i, designationCount - 1); constellationPool.Add(i); } constellationMaxNames[constellationCount] = lang[ProperStarName.ContextName].KeySet().Count - 1; for (int i = 0; i < starCount; i++) { usedDesignations[constellationPool.PickOrTake(x => usedDesignations[x] >= constellationMaxNames[x])]++; } // Proper names var namePool = new PickList <int>(); for (int i = 0; i < lang[ProperStarName.ContextName].KeySet().Count; i++) { namePool.Add(i); } for (int i = 0; i < usedDesignations[constellationCount]; i++) { this.starNames.Add(new ProperStarName(namePool.Take())); } // Constellation names usedDesignations.Remove(constellationCount); foreach (var constellation in usedDesignations) { for (int i = 0; i < constellation.Value; i++) { this.starNames.Add((constellation.Value == 1) ? (IStarName) new ConstellationStarName(constellation.Key) : (IStarName) new ConstellationStarName(constellation.Key, i) ); } } }
/// <summary> /// Called as we exit from edit mode - we need to ensure that what we have entered is valid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ulvPickItems_ItemExitingEditMode(object sender, ItemExitingEditModeEventArgs e) { UltraListViewItem lvi = e.Item; PickItem editedPickItem = lvi.Tag as PickItem; //string name = (string)e.Editor.Value; string name = e.Editor.Value.ToString(); // If the name is blank then it will be invalid if (name == "") { MessageBox.Show("Please specify a unique name for this pickitem", "Enter Name", MessageBoxButtons.OK, MessageBoxIcon.Information); e.Cancel = true; return; } // Get the picklist so we check it's items PickList picklist = _activeItem.Tag as PickList; // Does the specified value duplicate an existing pickitem? foreach (PickItem item in picklist) { if ((item.Name == name) && (item.PickItemID != editedPickItem.PickItemID)) { MessageBox.Show( "The specified name matches that of an existing item in this picklist, please specify a unique name for this pickitem", "Duplicate Name", MessageBoxButtons.OK, MessageBoxIcon.Stop); e.Cancel = true; return; } } // If it's a new pickitem then we need to add it to the parent list also if (editedPickItem.PickItemID == 0) { picklist.Add(editedPickItem); } // Update the PickItem in the database editedPickItem.Name = name; editedPickItem.Update(); // Prevent editing again for now this.ulvPickItems.ItemSettings.AllowEdit = Infragistics.Win.DefaultableBoolean.False; }
private void bnOK_Click(object sender, EventArgs e) { string strPickItemName = tbPickItemName.Text.ToString(); // If the name is blank then it will be invalid if (strPickItemName == "") { MessageBox.Show("Please specify a unique name for this pickitem", "Enter Name", MessageBoxButtons.OK, MessageBoxIcon.Information); tbPickItemName.Focus(); this.DialogResult = DialogResult.None; return; } // Get the picklist so we check it's items PickList picklist = m_activeItem.Tag as PickList; // Does the specified value duplicate an existing pickitem? foreach (PickItem item in picklist) { if ((item.Name == strPickItemName) && (item.PickItemID != _pickItem.PickItemID)) { MessageBox.Show( "The specified name matches that of an existing item in this picklist, please specify a unique name for this pickitem", "Duplicate Name", MessageBoxButtons.OK, MessageBoxIcon.Stop); tbPickItemName.Focus(); this.DialogResult = DialogResult.None; return; } } // If it's a new pickitem then we need to add it to the parent list also if (_pickItem.PickItemID == 0) { picklist.Add(_pickItem); } // Update the PickItem in the database _pickItem.Name = strPickItemName; _pickItem.Update(); }
public NewGameController() { foreach (var aiFactory in PlayerAssets.AIDefinitions) { aiPlayers.Add(new PlayerType(PlayerControlType.LocalAI, aiFactory)); } players.Add(new NewGamePlayerInfo("Marko Kovač", colors.Take(), null, localHuman)); players.Add(new NewGamePlayerInfo(generateAiName(), colors.Take(), null, aiPlayers.Pick())); this.CustomStart = LastStartingCondition ?? DefaultStartingCondition; this.StarPositioner = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPositionerConfig, MapAssets.StarPositioners); this.StarConnector = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarConnectorConfig, MapAssets.StarConnectors); this.StarPopulator = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPopulatorConfig, MapAssets.StarPopulators); }