public void SetType(AffixType type) { currentInfo = AffixInfo.GetAffixInfo(type); NameDisplay.text = currentInfo.Name; DescriptionDisplay.SetText(currentInfo.Description); ValueInfoDisplay.SetInfo(currentInfo.ValueInfo); }
/// <summary> /// Returns a list of random affixes in this pool, making sure they are all of different types. The tiers will be determined through the provided Lottery. /// </summary> /// <param name="totalTiers">The total number of tiers of affixes to be generated</param> /// <param name="tierDistribution">The distribution of tiers</param> /// <returns></returns> public Affix[] GetUniqueRandomAffixes(int totalTiers, Lottery <int> tierDistribution, HashSet <AffixType> blacklist) { List <Affix> affixes = new List <Affix>(); lottery.StartBatchDraw(blacklist); while (totalTiers > 0) { // Get the tier of the Affix to be generated and cap it if it exceeds the total number of tiers left int tier = tierDistribution.Draw(); tier = tier > totalTiers ? totalTiers : tier; AffixType type = GetRandomType(); if (type == AffixType.None) { // We've run out of AffixTypes to draw from break; } affixes.Add(AffixInfo.GetAffixInfo(type).GenerateAffix(tier)); totalTiers -= tier; } lottery.EndBatchDraw(); return(affixes.ToArray()); }
private void AffixInfosListBox_SelectedIndexChanged(object sender, EventArgs e) { if (_last_index != -1 && AffixInfosListBox.SelectedIndex == _last_index) { return; } if (HasUnsavedChanges()) { if (MessageBox.Show("Unsaved changes will be lost. Proceed?", "Unsaved Changes", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { AffixInfosListBox.SelectedIndex = _last_index; return; } } if (AffixInfosListBox.SelectedIndex == -1) { currentInfo = null; } else { currentInfo = AffixInfo.GetAffixInfo((AffixType)AffixInfosListBox.Items[AffixInfosListBox.SelectedIndex]); if (localType != currentInfo.Type) { UpdateCurrentAffixInfoDisplay(); } localType = currentInfo.Type; } _last_index = AffixInfosListBox.SelectedIndex; }
public Affix(AffixType type, AffixValue value, int tier) { Type = type; Value = value; Tier = tier; info = AffixInfo.GetAffixInfo(type); }
/// <summary> /// Returns a list of random Affixes of types in this pool, making sure each is of a different type. All Affixes will be of the given tier. /// </summary> /// <param name="n">The number of Affixes to draw</param> /// <returns></returns> public Affix[] GetUniqueRandomAffixes(int n, int tier) { List <Affix> affixes = new List <Affix>(); AffixType[] types = GetUniqueRandomTypes(n); foreach (AffixType type in types) { affixes.Add(AffixInfo.GetAffixInfo(type).GenerateAffix(tier)); } return(affixes.ToArray()); }
public async Task RenameSelectedType() { if (selectedType == AffixType.None) { return; } if (!AffixInfoDisplay.IsValid) { DialogBasic.Show("Renaming requires that all changes are saved first, but there are invalid entries. Please fix all errors before trying again."); return; } if (AffixInfoDisplay.IsChanged) { if ((await DialogCancellable.Show("Renaming requires that all changes be saved first. Save now?").result).IsCancelled) { return; } if (await SaveSelectedType() == false) { DialogBasic.Show("There was a problem saving. Please recheck the values and try again."); return; } } var result = await DialogStringInput.ShowBlocking($"Enter a new name for '{selectedType.Name}'", name => !AffixType.Exists(name) && AffixType.IsValidName(name), ShowInvalidNameMessage).result; if (result.IsOK) { string name = result.Value; var oldInfo = AffixInfo.GetAffixInfo(selectedType); AffixInfo.Deregister(selectedType); Serializer.DeleteAffixInfo(oldInfo.Type); var newType = AffixType.Replace(selectedType.ID, name); var newInfo = new AffixInfo(newType, oldInfo.ValueInfo, oldInfo.Description); AffixInfo.Register(newInfo); Serializer.SaveAffixInfoToDisk(newInfo); var display = displays[selectedType]; displays.Remove(selectedType); displays.Add(newType, display); display.SetAffixType(newType); SelectType(newType); } }
/// <summary> /// Generates the Affixes and BaseAffixes for an item /// </summary> protected void GenerateAffixes(Item item) { item.Affixes.Clear(); item.BaseAffixes.Clear(); foreach (AffixType affixType in BaseAffixes) { item.BaseAffixes.Add(AffixInfo.GetAffixInfo(affixType).GenerateAffix(item.Tier)); } // Create new lottery to decide tier roll of each affix // TODO: make nicer Lottery<int> tierLottery = new Lottery<int>(); tierLottery.Enter(item.Tier, 10); if (item.Tier > 1) tierLottery.Enter(item.Tier - 1, 5); if (item.Tier > 2) tierLottery.Enter(item.Tier - 2, 2); if (item.Tier > 3) tierLottery.Enter(item.Tier - 3, 1); int quality = item.Quality; // Guaranteed affixes don't care about possible pool foreach (AffixType affixType in GuaranteedAffixes) { int tier = tierLottery.Draw(); tier = tier > quality ? quality : tier; item.Affixes.Add(AffixInfo.GetAffixInfo(affixType).GenerateAffix(tier)); quality -= tier; } // Fill up the rest of the affixes Affix[] randomAffixes = PossibleAffixes.GetUniqueRandomAffixes(quality, tierLottery, new HashSet<AffixType>(GuaranteedAffixes)); foreach (Affix affix in randomAffixes) { item.Affixes.Add(affix); } }
void GenerateTestAffixContainer() { AffixContainer container = new AffixContainer(); Affix health1 = AffixInfo.GetAffixInfo(AffixType.Health).GenerateAffix(2); container.Add(health1); container.Add(AffixInfo.GetAffixInfo(AffixType.Health).GenerateAffix(2)); container.Add(health1); container.Add(AffixInfo.GetAffixInfo(AffixType.PhysDmgFlat).GenerateAffix(3)); print(container); container.Remove(health1); print(container); Affix fireRate = AffixInfo.GetAffixInfo(AffixType.FireRate).GenerateAffix(5); container.Remove(fireRate); Affix health2 = AffixInfo.GetAffixInfo(AffixType.Health).GenerateAffix(3); container.Remove(health2); }
/// <summary> /// Returns a random Affix of a type in this pool. The Affix will be of the given tier. /// </summary> /// <returns></returns> public Affix GetRandomAffix(int tier) { AffixType type = GetRandomType(); return(AffixInfo.GetAffixInfo(type).GenerateAffix(tier)); }