private CalculatorResults Calculate(Armor armor, int targetLevel) { if (armor == null) return new CalculatorResults(Strings.ArmorNotFound); CalculatorResults results = new CalculatorResults(); if (armor.NormalStats != null) { results.NormalAttack = Calculate(armor.NormalStats.AttackStart, armor.NormalStats.AttackUp, targetLevel); results.NormalDefense = Calculate(armor.NormalStats.DefenseStart, armor.NormalStats.DefenseUp, targetLevel); } if (armor.PlusStats != null) { results.PlusAttack = Calculate(armor.PlusStats.AttackStart, armor.PlusStats.AttackUp, targetLevel); results.PlusDefense = Calculate(armor.PlusStats.DefenseStart, armor.PlusStats.DefenseUp, targetLevel); } return results; }
private CalculatorResults Calculate(Armor armor, int targetLevel, Armor feedArmor) { if (armor == null || feedArmor == null) return new CalculatorResults(Strings.ArmorNotFound); CalculatorResults results = Calculate(armor, targetLevel); int feedCost = GetFeedCost(armor, feedArmor); if (feedCost <= 0) return new CalculatorResults(Strings.ArmorDataMissing); int totalFeedCost = LevelTable.GetTotalFeedCost(armor.Rarity, targetLevel); if (totalFeedCost <= 0) return new CalculatorResults(Strings.LevelDataMissing); int feedCount = (int)Math.Ceiling((decimal)(totalFeedCost / feedCost)); results.FeedCount = feedCount; results.CraftCost = feedArmor.CraftCost * feedCount; results.MaterialCount = feedArmor.MaterialCount * feedCount; int currentLevel = 1; int cumulativeJump = 0; while (feedCount > 0) { Level level = LevelTable.GetLevel(currentLevel); if (level == null) break; int count = (feedCount > 4) ? 4 : feedCount; results.FeedCost += level.Gold * count; cumulativeJump += feedCost * count; currentLevel = LevelTable.GetLevelFromExperience(armor.Rarity, cumulativeJump); feedCount -= count; } return results; }
private int GetFeedCost(Armor armor, Armor feedArmor) { int feedCost = feedArmor.FeedCost; if (armor.SameElementAs(feedArmor)) { feedCost = (int)(feedCost * 1.25); } return feedCost; }
public bool SameElementAs(Armor armor) { return (armor.Element1 == Element1 || (Element2 != null && armor.Element1 == Element2.Value) || (armor.Element2 != null && armor.Element2.Value == Element1) || (Element2 != null && armor.Element2 != null && armor.Element2.Value == Element2.Value)); }