public static Resists Clone(this Resists resists) { return(new Resists { Physical = resists.Physical, Fire = resists.Fire, Cold = resists.Cold, Poison = resists.Poison, Energy = resists.Energy, }); }
public static void Add(this Resists baseResists, params Resists[] bonuses) { foreach (var bonus in bonuses) { baseResists.Physical += bonus.Physical; baseResists.Fire += bonus.Fire; baseResists.Cold += bonus.Cold; baseResists.Poison += bonus.Poison; baseResists.Energy += bonus.Energy; } }
public ArmorEvaluatorService(Armor armor, int maxResistBonus) { if (armor == null) { throw new ArgumentNullException(nameof(armor)); } PhysicalLowest = armor.CurrentResists.Physical <= armor.CurrentResists.Fire && armor.CurrentResists.Physical <= armor.CurrentResists.Cold && armor.CurrentResists.Physical <= armor.CurrentResists.Poison && armor.CurrentResists.Physical <= armor.CurrentResists.Energy; FireLowest = armor.CurrentResists.Fire <= armor.CurrentResists.Physical && armor.CurrentResists.Fire <= armor.CurrentResists.Cold && armor.CurrentResists.Fire <= armor.CurrentResists.Poison && armor.CurrentResists.Fire <= armor.CurrentResists.Energy; ColdLowest = armor.CurrentResists.Cold <= armor.CurrentResists.Fire && armor.CurrentResists.Cold <= armor.CurrentResists.Physical && armor.CurrentResists.Cold <= armor.CurrentResists.Poison && armor.CurrentResists.Cold <= armor.CurrentResists.Energy; PoisonLowest = armor.CurrentResists.Poison <= armor.CurrentResists.Fire && armor.CurrentResists.Poison <= armor.CurrentResists.Cold && armor.CurrentResists.Poison <= armor.CurrentResists.Physical && armor.CurrentResists.Poison <= armor.CurrentResists.Energy; EnergyLowest = armor.CurrentResists.Energy <= armor.CurrentResists.Fire && armor.CurrentResists.Energy <= armor.CurrentResists.Cold && armor.CurrentResists.Energy <= armor.CurrentResists.Poison && armor.CurrentResists.Energy <= armor.CurrentResists.Physical; _baseArmor = armor; _maxResistBonus = maxResistBonus; _maxImbueables = new Resists { Physical = armor.BaseResists.Physical + maxResistBonus, Fire = armor.BaseResists.Fire + maxResistBonus, Cold = armor.BaseResists.Cold + maxResistBonus, Poison = armor.BaseResists.Poison + maxResistBonus, Energy = armor.BaseResists.Energy + maxResistBonus, }; }
private void btn_ImportFile_Click(object sender, EventArgs e) { try { var importerService = new ImporterService(); var fileText = importerService.ReadFile(FileToImport); var lines = importerService.SplitString(fileText, '\n'); var dict = new Dictionary <string, int>(); var easyUoRecord = new EasyUoRecord(); var actualtype = easyUoRecord.GetType(); foreach (var propertyInfo in actualtype.GetProperties()) { foreach (ColumnNumber columnNumber in propertyInfo.GetCustomAttributes(typeof(ColumnNumber), false)) { dict.Add(propertyInfo.Name, columnNumber.Value); break; } } var armors = new List <Armor>(); foreach (var line in lines) { var data = importerService.SplitString(line, '.'); var dataArray = data?.ToArray(); if (data == null || dataArray.Length == 0) { continue; } // Check for Resource based on Color var itemColor = int.Parse(dataArray[dict[nameof(easyUoRecord.Color)]]); var resource = _resources.FirstOrDefault(r => r.Color == itemColor); if (resource == null) { var result = MessageBox.Show($@"Unable find known color for '{itemColor}'." + "\r\n\r\nWould you like to skip the record?", @"Unknown Color", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { continue; } return; } // This tells us the Base Resists for this item var itemType = dataArray[dict[nameof(easyUoRecord.ItemType)]]; var armorRecords = _knownItemTypes[itemType]; var baseArmor = armorRecords.FirstOrDefault(r => r.Color == itemColor); if (baseArmor == null) { // Type to Color is a one to many relationship var result = MessageBox.Show($@"Unable find Type '{itemType}' with Color '{itemColor}'." + "\r\n\r\nWould you like to skip the record?", @"Unexpected item Type/Color combination", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { continue; } return; } // Fetch the basics var currentResists = new Resists { Physical = int.Parse(dataArray[dict[nameof(easyUoRecord.Physical)]]), Fire = int.Parse(dataArray[dict[nameof(easyUoRecord.Fire)]]), Cold = int.Parse(dataArray[dict[nameof(easyUoRecord.Cold)]]), Poison = int.Parse(dataArray[dict[nameof(easyUoRecord.Poison)]]), Energy = int.Parse(dataArray[dict[nameof(easyUoRecord.Energy)]]), }; var armor = new Armor { CurrentResists = currentResists, Slot = baseArmor.Slot, }; armor.Id = dataArray[dict[nameof(armor.Id)]]; // Set it's minimums armor.BaseResists = _resistConfigurations[baseArmor.BaseResistConfigurationId]; // Check if it's imbued already armor.EvaluateImbuedResists(_maxResistBonus); // Add the bonus to the base if it it's not the default color if (itemColor != baseArmor.Color) { var resourceResists = _resistConfigurations[resource.BonusResistConfigurationId]; armor.CurrentResists.Add(resourceResists); } else { armor.NeedsBonus = true; } armors.Add(armor); } _armorPieces = armors; MessageBox.Show($@"Imported '{_armorPieces.Count}' records."); btn_MakeSuit.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void incraseResist(Resists index, int value) { _resists[index].baseValue += value; _resists[index].currentValue += value; }
public int currentResist(Resists index) { return _resists[index].currentValue; }
public int baseResist(Resists index) { return _resists[index].baseValue; }